-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolyfill.js
118 lines (102 loc) · 2.67 KB
/
polyfill.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
!window.addEventListener &&
(function (WP, DP, EP, a, r, d, rest) {
WP[a] = DP[a] = EP[a] = function (type, listener) {
var target = this
rest.unshift([
target,
type,
listener,
function (event) {
event.currentTarget = target
event.preventDefault = function () {
event.returnValue = false
}
event.stopPropagation = function () {
event.cancelBubble = true
}
event.target = event.srcElement || target
listener.call(target, event)
},
])
this.attachEvent('on' + type, rest[0][3])
}
WP[r] = DP[r] = EP[r] = function (
type,
listener
) {
for (var index = 0, register; (register = rest[index]); ++index) {
if (register[0] == this && register[1] == type && register[2] == listener) {
return this.detachEvent('on' + type, rest.splice(index, 1)[0][3])
}
}
}
WP[d] = DP[d] = EP[d] = function (eventObject) {
return this.fireEvent('on' + eventObject.type, eventObject)
}
})(Window.prototype, HTMLDocument.prototype, Element.prototype, 'a', 'r', 'd', [])
if (!window.performance) {
window.performance = {}
window.performance.now =
Date.now ||
function () {
return new Date().getTime()
}
}
if (!Array.isArray) {
Array.isArray = (function (toString) {
var $ = toString.call([])
return function isArray(object) {
return toString.call(object) === $
}
})({}.toString)
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (fn, scope) {
var i, len
for (i = 0, len = this.length; i < len; ++i) {
if (i in this) {
fn.call(scope, this[i], i, this)
}
}
}
}
if (typeof Function.prototype.bind !== 'function') {
Function.prototype.bind = function () {
var fn = this
var args = arguments
return function () {
return fn.call.apply(fn, args)
}
}
}
if (!SVGElement) {
SVGElement = function () {
// 暂时不支持 svg
}
}
if (!Array.prototype.some) {
Array.prototype.some = function (fun) {
if (this === void 0 || this === null) {
throw new TypeError()
}
var t = Object(this)
var len = t.length >>> 0
if (typeof fun !== 'function') {
throw new TypeError()
}
var thisArg = arguments.length >= 2 ? arguments[1] : void 0
for (var i = 0; i < len; i++) {
if (i in t && fun.call(thisArg, t[i], i, t)) {
return true
}
}
return false
}
}
if (!document.createTextNode) {
document.createTextNode = function (data) {
const text = document.createElement('x-text')
text.innerText = data
return text
}
}