forked from xdan/jodit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
polyfills.ts
71 lines (62 loc) · 1.77 KB
/
polyfills.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import type { CanUndef, IDictionary } from 'jodit/types';
import 'classlist-polyfill';
import 'es6-promise/auto';
import 'core-js/es/symbol';
import 'core-js/es/array/find-index';
import 'core-js/es/array/from';
// for ie11
if (!Array.prototype.includes) {
Array.prototype.includes = function (value: any): boolean {
return this.indexOf(value) > -1;
};
}
// for ie11
if (typeof Object.assign !== 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, 'assign', {
value: function assign(target: IDictionary, varArgs: IDictionary) {
// .length of function is 2
if (target == null) {
throw new TypeError(
'Cannot convert undefined or null to object'
);
}
const to = Object(target);
for (let index = 1; index < arguments.length; index++) {
// eslint-disable-next-line prefer-rest-params
const nextSource = arguments[index];
if (nextSource != null) {
for (const nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (
Object.prototype.hasOwnProperty.call(
nextSource,
nextKey
)
) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
if (!Array.prototype.find) {
Array.prototype.find = function <T>(value: T): CanUndef<T> {
return this.indexOf(value) > -1 ? value : undefined;
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (value: any): boolean {
return this[this.length - 1] === value;
};
}