amazeui 2.5.2a → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -12
- data/lib/amazeui/version.rb +1 -1
- data/vendor/assets/javascripts/amazeui.ie8polyfill.js +1899 -1312
- data/vendor/assets/javascripts/amazeui.ie8polyfill.min.js +3 -2
- data/vendor/assets/javascripts/amazeui.js +228 -121
- data/vendor/assets/javascripts/amazeui.min.js +8 -8
- data/vendor/assets/javascripts/amazeui.widgets.helper.js +1 -1
- data/vendor/assets/javascripts/amazeui.widgets.helper.min.js +1 -1
- data/vendor/assets/stylesheets/amazeui.css +60 -59
- data/vendor/assets/stylesheets/amazeui.flat.css +62 -61
- data/vendor/assets/stylesheets/amazeui.flat.min.css +1 -1
- data/vendor/assets/stylesheets/amazeui.min.css +1 -1
- metadata +4 -5
- data/lib/amazeui/version.rb~ +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 606ad2bff9d89e2000e9a100af6e473700afc217
|
4
|
+
data.tar.gz: c96818a5b782c149349e28942cf23d1318317a78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 741734ec4e6efd9e8f3fb38967adf5e72f6adda0469590a0acf64ffc51f26833d97494a3fc300a4fe8ec35605361798bc4f19f8808a3442b92063ac9283da939
|
7
|
+
data.tar.gz: cd01aaf34e0050fdf56f6aa79606ab8017e76cb37e4462d9d57d3533fdfc5f5a710ff78d1aaf44a630e660abeebd08ad5cfb36868b5c15d09e9a2a4acb5c7793
|
data/README.md
CHANGED
@@ -1,24 +1,42 @@
|
|
1
|
-
|
1
|
+
## Introduce
|
2
2
|
|
3
|
-
|
3
|
+
Amazeui gem is a Rails assets wrapper of Amaze Ui.
|
4
4
|
|
5
|
-
|
6
|
-
in Gemfile
|
5
|
+
Files can be included directly in application.js/css/scss after install the gem.
|
7
6
|
|
8
|
-
|
7
|
+
|
8
|
+
```
|
9
9
|
gem 'amazeui'
|
10
10
|
```
|
11
11
|
|
12
|
-
|
12
|
+
##File list
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
###fonts
|
15
|
+
FontAwesome.otf
|
16
|
+
fontawesome-webfont.eot
|
17
|
+
fontawesome-webfont.svg
|
18
|
+
fontawesome-webfont.ttf
|
19
|
+
fontawesome-webfont.woff
|
20
|
+
fontawesome-webfont.woff2
|
17
21
|
|
18
|
-
|
22
|
+
###css
|
19
23
|
|
20
|
-
```
|
21
|
-
|
24
|
+
```
|
25
|
+
amazeui.css
|
26
|
+
amazeui.flat.css
|
27
|
+
amazeui.flat.min.css
|
28
|
+
amazeui.min.css
|
29
|
+
```
|
30
|
+
|
31
|
+
###js
|
32
|
+
```
|
33
|
+
amazeui.ie8polyfill.js
|
34
|
+
amazeui.ie8polyfill.min.js
|
35
|
+
amazeui.js
|
36
|
+
amazeui.min.js
|
37
|
+
amazeui.widegets.helper.js
|
38
|
+
amazeui.widegets.helper.min.js
|
39
|
+
handlebars.min.js
|
22
40
|
```
|
23
41
|
|
24
42
|
## Usage
|
data/lib/amazeui/version.rb
CHANGED
@@ -1,25 +1,4 @@
|
|
1
|
-
/*! Amaze UI v2.
|
2
|
-
// Console-polyfill. MIT license.
|
3
|
-
// https://github.com/paulmillr/console-polyfill
|
4
|
-
// Make it safe to do console.log() always.
|
5
|
-
(function(global) {
|
6
|
-
'use strict';
|
7
|
-
global.console = global.console || {};
|
8
|
-
var con = global.console;
|
9
|
-
var prop, method;
|
10
|
-
var empty = {};
|
11
|
-
var dummy = function() {};
|
12
|
-
var properties = 'memory'.split(',');
|
13
|
-
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
|
14
|
-
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
|
15
|
-
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
|
16
|
-
while (prop = properties.pop()) if (!con[prop]) con[prop] = empty;
|
17
|
-
while (method = methods.pop()) if (!con[method]) con[method] = dummy;
|
18
|
-
})(typeof window === 'undefined' ? this : window);
|
19
|
-
// Using `this` for web workers while maintaining compatibility with browser
|
20
|
-
// targeted script loaders such as Browserify or Webpack where the only way to
|
21
|
-
// get to the global object is via `window`.
|
22
|
-
|
1
|
+
/*! Amaze UI v2.6.1 ~ IE8 Fucker | by Amaze UI Team | (c) 2016 AllMobilize, Inc. | Licensed under MIT | 2016-04-06T09:34:39+0800 */
|
23
2
|
/*!
|
24
3
|
* https://github.com/es-shims/es5-shim
|
25
4
|
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
|
@@ -32,7 +11,7 @@
|
|
32
11
|
;
|
33
12
|
|
34
13
|
// UMD (Universal Module Definition)
|
35
|
-
// see https://github.com/umdjs/umd/blob/master/returnExports.js
|
14
|
+
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
36
15
|
(function (root, factory) {
|
37
16
|
'use strict';
|
38
17
|
|
@@ -48,866 +27,700 @@
|
|
48
27
|
} else {
|
49
28
|
// Browser globals (root is window)
|
50
29
|
root.returnExports = factory();
|
51
|
-
|
30
|
+
}
|
52
31
|
}(this, function () {
|
53
32
|
|
54
|
-
|
55
|
-
|
56
|
-
|
33
|
+
/**
|
34
|
+
* Brings an environment as close to ECMAScript 5 compliance
|
35
|
+
* as is possible with the facilities of erstwhile engines.
|
36
|
+
*
|
37
|
+
* Annotated ES5: http://es5.github.com/ (specific links below)
|
38
|
+
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
|
39
|
+
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
|
40
|
+
*/
|
57
41
|
|
58
|
-
//
|
59
|
-
|
60
|
-
|
61
|
-
var
|
62
|
-
var
|
63
|
-
var
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
42
|
+
// Shortcut to an often accessed properties, in order to avoid multiple
|
43
|
+
// dereference that costs universally. This also holds a reference to known-good
|
44
|
+
// functions.
|
45
|
+
var $Array = Array;
|
46
|
+
var ArrayPrototype = $Array.prototype;
|
47
|
+
var $Object = Object;
|
48
|
+
var ObjectPrototype = $Object.prototype;
|
49
|
+
var $Function = Function;
|
50
|
+
var FunctionPrototype = $Function.prototype;
|
51
|
+
var $String = String;
|
52
|
+
var StringPrototype = $String.prototype;
|
53
|
+
var $Number = Number;
|
54
|
+
var NumberPrototype = $Number.prototype;
|
55
|
+
var array_slice = ArrayPrototype.slice;
|
56
|
+
var array_splice = ArrayPrototype.splice;
|
57
|
+
var array_push = ArrayPrototype.push;
|
58
|
+
var array_unshift = ArrayPrototype.unshift;
|
59
|
+
var array_concat = ArrayPrototype.concat;
|
60
|
+
var array_join = ArrayPrototype.join;
|
61
|
+
var call = FunctionPrototype.call;
|
62
|
+
var apply = FunctionPrototype.apply;
|
63
|
+
var max = Math.max;
|
64
|
+
var min = Math.min;
|
72
65
|
|
73
|
-
//
|
74
|
-
|
75
|
-
if (!Object.getPrototypeOf) {
|
76
|
-
// https://github.com/es-shims/es5-shim/issues#issue/2
|
77
|
-
// http://ejohn.org/blog/objectgetprototypeof/
|
78
|
-
// recommended by fschaefer on github
|
79
|
-
//
|
80
|
-
// sure, and webreflection says ^_^
|
81
|
-
// ... this will nerever possibly return null
|
82
|
-
// ... Opera Mini breaks here with infinite loops
|
83
|
-
Object.getPrototypeOf = function getPrototypeOf(object) {
|
84
|
-
/* eslint-disable no-proto */
|
85
|
-
var proto = object.__proto__;
|
86
|
-
/* eslint-enable no-proto */
|
87
|
-
if (proto || proto === null) {
|
88
|
-
return proto;
|
89
|
-
} else if (object.constructor) {
|
90
|
-
return object.constructor.prototype;
|
91
|
-
} else {
|
92
|
-
return prototypeOfObject;
|
93
|
-
}
|
94
|
-
};
|
95
|
-
}
|
66
|
+
// Having a toString local variable name breaks in Opera so use to_string.
|
67
|
+
var to_string = ObjectPrototype.toString;
|
96
68
|
|
97
|
-
|
98
|
-
|
69
|
+
/* global Symbol */
|
70
|
+
/* eslint-disable one-var-declaration-per-line, no-redeclare */
|
71
|
+
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
72
|
+
var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
|
99
73
|
|
100
|
-
var
|
74
|
+
var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; };
|
75
|
+
var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; };
|
76
|
+
/* eslint-enable one-var-declaration-per-line, no-redeclare */
|
77
|
+
|
78
|
+
/* inlined from http://npmjs.com/define-properties */
|
79
|
+
var supportsDescriptors = $Object.defineProperty && (function () {
|
101
80
|
try {
|
102
|
-
|
103
|
-
|
104
|
-
|
81
|
+
var obj = {};
|
82
|
+
$Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
|
83
|
+
for (var _ in obj) { return false; }
|
84
|
+
return obj.x === obj;
|
85
|
+
} catch (e) { /* this is ES3 */
|
105
86
|
return false;
|
106
87
|
}
|
107
|
-
};
|
88
|
+
}());
|
89
|
+
var defineProperties = (function (has) {
|
90
|
+
// Define configurable, writable, and non-enumerable props
|
91
|
+
// if they don't exist.
|
92
|
+
var defineProperty;
|
93
|
+
if (supportsDescriptors) {
|
94
|
+
defineProperty = function (object, name, method, forceAssign) {
|
95
|
+
if (!forceAssign && (name in object)) { return; }
|
96
|
+
$Object.defineProperty(object, name, {
|
97
|
+
configurable: true,
|
98
|
+
enumerable: false,
|
99
|
+
writable: true,
|
100
|
+
value: method
|
101
|
+
});
|
102
|
+
};
|
103
|
+
} else {
|
104
|
+
defineProperty = function (object, name, method, forceAssign) {
|
105
|
+
if (!forceAssign && (name in object)) { return; }
|
106
|
+
object[name] = method;
|
107
|
+
};
|
108
|
+
}
|
109
|
+
return function defineProperties(object, map, forceAssign) {
|
110
|
+
for (var name in map) {
|
111
|
+
if (has.call(map, name)) {
|
112
|
+
defineProperty(object, name, map[name], forceAssign);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
};
|
116
|
+
}(ObjectPrototype.hasOwnProperty));
|
108
117
|
|
109
|
-
//
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
doesGetOwnPropertyDescriptorWork(document.createElement('div'));
|
114
|
-
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
|
115
|
-
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
|
116
|
-
}
|
117
|
-
}
|
118
|
+
//
|
119
|
+
// Util
|
120
|
+
// ======
|
121
|
+
//
|
118
122
|
|
119
|
-
|
120
|
-
|
123
|
+
/* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */
|
124
|
+
var isPrimitive = function isPrimitive(input) {
|
125
|
+
var type = typeof input;
|
126
|
+
return input === null || (type !== 'object' && type !== 'function');
|
127
|
+
};
|
121
128
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
129
|
+
var isActualNaN = $Number.isNaN || function (x) { return x !== x; };
|
130
|
+
|
131
|
+
var ES = {
|
132
|
+
// ES5 9.4
|
133
|
+
// http://es5.github.com/#x9.4
|
134
|
+
// http://jsperf.com/to-integer
|
135
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
|
136
|
+
ToInteger: function ToInteger(num) {
|
137
|
+
var n = +num;
|
138
|
+
if (isActualNaN(n)) {
|
139
|
+
n = 0;
|
140
|
+
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
141
|
+
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
126
142
|
}
|
143
|
+
return n;
|
144
|
+
},
|
127
145
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
146
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */
|
147
|
+
ToPrimitive: function ToPrimitive(input) {
|
148
|
+
var val, valueOf, toStr;
|
149
|
+
if (isPrimitive(input)) {
|
150
|
+
return input;
|
151
|
+
}
|
152
|
+
valueOf = input.valueOf;
|
153
|
+
if (isCallable(valueOf)) {
|
154
|
+
val = valueOf.call(input);
|
155
|
+
if (isPrimitive(val)) {
|
156
|
+
return val;
|
135
157
|
}
|
136
158
|
}
|
159
|
+
toStr = input.toString;
|
160
|
+
if (isCallable(toStr)) {
|
161
|
+
val = toStr.call(input);
|
162
|
+
if (isPrimitive(val)) {
|
163
|
+
return val;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
throw new TypeError();
|
167
|
+
},
|
137
168
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
169
|
+
// ES5 9.9
|
170
|
+
// http://es5.github.com/#x9.9
|
171
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */
|
172
|
+
ToObject: function (o) {
|
173
|
+
if (o == null) { // this matches both null and undefined
|
174
|
+
throw new TypeError("can't convert " + o + ' to object');
|
143
175
|
}
|
176
|
+
return $Object(o);
|
177
|
+
},
|
144
178
|
|
145
|
-
|
146
|
-
|
147
|
-
|
179
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
|
180
|
+
ToUint32: function ToUint32(x) {
|
181
|
+
return x >>> 0;
|
182
|
+
}
|
183
|
+
};
|
148
184
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
// if object has own non getter property along with a same named
|
154
|
-
// inherited getter. To avoid misbehavior we temporary remove
|
155
|
-
// `__proto__` so that `__lookupGetter__` will return getter only
|
156
|
-
// if it's owned by an object.
|
157
|
-
var prototype = object.__proto__;
|
158
|
-
var notPrototypeOfObject = object !== prototypeOfObject;
|
159
|
-
// avoid recursion problem, breaking in Opera Mini when
|
160
|
-
// Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
|
161
|
-
// or any other Object.prototype accessor
|
162
|
-
if (notPrototypeOfObject) {
|
163
|
-
object.__proto__ = prototypeOfObject;
|
164
|
-
}
|
185
|
+
//
|
186
|
+
// Function
|
187
|
+
// ========
|
188
|
+
//
|
165
189
|
|
166
|
-
|
167
|
-
|
190
|
+
// ES-5 15.3.4.5
|
191
|
+
// http://es5.github.com/#x15.3.4.5
|
168
192
|
|
169
|
-
|
170
|
-
// Once we have getter and setter we can put values back.
|
171
|
-
object.__proto__ = prototype;
|
172
|
-
}
|
193
|
+
var Empty = function Empty() {};
|
173
194
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
// If it was accessor property we're done and return here
|
182
|
-
// in order to avoid adding `value` to the descriptor.
|
183
|
-
return descriptor;
|
184
|
-
}
|
195
|
+
defineProperties(FunctionPrototype, {
|
196
|
+
bind: function bind(that) { // .length is 1
|
197
|
+
// 1. Let Target be the this value.
|
198
|
+
var target = this;
|
199
|
+
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
200
|
+
if (!isCallable(target)) {
|
201
|
+
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
185
202
|
}
|
203
|
+
// 3. Let A be a new (possibly empty) internal list of all of the
|
204
|
+
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
205
|
+
// XXX slicedArgs will stand in for "A" if used
|
206
|
+
var args = array_slice.call(arguments, 1); // for normal call
|
207
|
+
// 4. Let F be a new native ECMAScript object.
|
208
|
+
// 11. Set the [[Prototype]] internal property of F to the standard
|
209
|
+
// built-in Function prototype object as specified in 15.3.3.1.
|
210
|
+
// 12. Set the [[Call]] internal property of F as described in
|
211
|
+
// 15.3.4.5.1.
|
212
|
+
// 13. Set the [[Construct]] internal property of F as described in
|
213
|
+
// 15.3.4.5.2.
|
214
|
+
// 14. Set the [[HasInstance]] internal property of F as described in
|
215
|
+
// 15.3.4.5.3.
|
216
|
+
var bound;
|
217
|
+
var binder = function () {
|
186
218
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
219
|
+
if (this instanceof bound) {
|
220
|
+
// 15.3.4.5.2 [[Construct]]
|
221
|
+
// When the [[Construct]] internal method of a function object,
|
222
|
+
// F that was created using the bind function is called with a
|
223
|
+
// list of arguments ExtraArgs, the following steps are taken:
|
224
|
+
// 1. Let target be the value of F's [[TargetFunction]]
|
225
|
+
// internal property.
|
226
|
+
// 2. If target has no [[Construct]] internal method, a
|
227
|
+
// TypeError exception is thrown.
|
228
|
+
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
229
|
+
// property.
|
230
|
+
// 4. Let args be a new list containing the same values as the
|
231
|
+
// list boundArgs in the same order followed by the same
|
232
|
+
// values as the list ExtraArgs in the same order.
|
233
|
+
// 5. Return the result of calling the [[Construct]] internal
|
234
|
+
// method of target providing args as the arguments.
|
195
235
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
236
|
+
var result = apply.call(
|
237
|
+
target,
|
238
|
+
this,
|
239
|
+
array_concat.call(args, array_slice.call(arguments))
|
240
|
+
);
|
241
|
+
if ($Object(result) === result) {
|
242
|
+
return result;
|
243
|
+
}
|
244
|
+
return this;
|
203
245
|
|
204
|
-
|
205
|
-
//
|
206
|
-
|
246
|
+
} else {
|
247
|
+
// 15.3.4.5.1 [[Call]]
|
248
|
+
// When the [[Call]] internal method of a function object, F,
|
249
|
+
// which was created using the bind function is called with a
|
250
|
+
// this value and a list of arguments ExtraArgs, the following
|
251
|
+
// steps are taken:
|
252
|
+
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
253
|
+
// property.
|
254
|
+
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
255
|
+
// property.
|
256
|
+
// 3. Let target be the value of F's [[TargetFunction]] internal
|
257
|
+
// property.
|
258
|
+
// 4. Let args be a new list containing the same values as the
|
259
|
+
// list boundArgs in the same order followed by the same
|
260
|
+
// values as the list ExtraArgs in the same order.
|
261
|
+
// 5. Return the result of calling the [[Call]] internal method
|
262
|
+
// of target providing boundThis as the this value and
|
263
|
+
// providing args as the arguments.
|
207
264
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
265
|
+
// equiv: target.call(this, ...boundArgs, ...args)
|
266
|
+
return apply.call(
|
267
|
+
target,
|
268
|
+
that,
|
269
|
+
array_concat.call(args, array_slice.call(arguments))
|
270
|
+
);
|
214
271
|
|
215
|
-
|
216
|
-
// No need to use active x approach when document.domain is not set
|
217
|
-
// see https://github.com/es-shims/es5-shim/issues/150
|
218
|
-
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
219
|
-
/* global ActiveXObject */
|
220
|
-
var shouldUseActiveX = function shouldUseActiveX() {
|
221
|
-
// return early if document.domain not set
|
222
|
-
if (!document.domain) {
|
223
|
-
return false;
|
224
|
-
}
|
272
|
+
}
|
225
273
|
|
226
|
-
|
227
|
-
return !!new ActiveXObject('htmlfile');
|
228
|
-
} catch (exception) {
|
229
|
-
return false;
|
230
|
-
}
|
231
|
-
};
|
274
|
+
};
|
232
275
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
var xDoc;
|
276
|
+
// 15. If the [[Class]] internal property of Target is "Function", then
|
277
|
+
// a. Let L be the length property of Target minus the length of A.
|
278
|
+
// b. Set the length own property of F to either 0 or L, whichever is
|
279
|
+
// larger.
|
280
|
+
// 16. Else set the length own property of F to 0.
|
239
281
|
|
240
|
-
|
282
|
+
var boundLength = max(0, target.length - args.length);
|
241
283
|
|
242
|
-
|
243
|
-
|
284
|
+
// 17. Set the attributes of the length own property of F to the values
|
285
|
+
// specified in 15.3.5.1.
|
286
|
+
var boundArgs = [];
|
287
|
+
for (var i = 0; i < boundLength; i++) {
|
288
|
+
array_push.call(boundArgs, '$' + i);
|
289
|
+
}
|
244
290
|
|
245
|
-
|
246
|
-
|
291
|
+
// XXX Build a dynamic function with desired amount of arguments is the only
|
292
|
+
// way to set the length property of a function.
|
293
|
+
// In environments where Content Security Policies enabled (Chrome extensions,
|
294
|
+
// for ex.) all use of eval or Function costructor throws an exception.
|
295
|
+
// However in all of these environments Function.prototype.bind exists
|
296
|
+
// and so this code will never be executed.
|
297
|
+
bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder);
|
247
298
|
|
248
|
-
|
249
|
-
|
299
|
+
if (target.prototype) {
|
300
|
+
Empty.prototype = target.prototype;
|
301
|
+
bound.prototype = new Empty();
|
302
|
+
// Clean up dangling references.
|
303
|
+
Empty.prototype = null;
|
304
|
+
}
|
250
305
|
|
251
|
-
|
252
|
-
|
253
|
-
// see https://github.com/es-shims/es5-shim/issues/150
|
254
|
-
var getEmptyViaIFrame = function getEmptyViaIFrame() {
|
255
|
-
var iframe = document.createElement('iframe');
|
256
|
-
var parent = document.body || document.documentElement;
|
257
|
-
var empty;
|
306
|
+
// TODO
|
307
|
+
// 18. Set the [[Extensible]] internal property of F to true.
|
258
308
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
309
|
+
// TODO
|
310
|
+
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
311
|
+
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
312
|
+
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
313
|
+
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
314
|
+
// false.
|
315
|
+
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
316
|
+
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
317
|
+
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
318
|
+
// and false.
|
264
319
|
|
265
|
-
|
266
|
-
|
267
|
-
|
320
|
+
// TODO
|
321
|
+
// NOTE Function objects created using Function.prototype.bind do not
|
322
|
+
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
323
|
+
// [[Scope]] internal properties.
|
324
|
+
// XXX can't delete prototype in pure-js.
|
268
325
|
|
269
|
-
|
270
|
-
|
326
|
+
// 22. Return F.
|
327
|
+
return bound;
|
328
|
+
}
|
329
|
+
});
|
271
330
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
// Determine which approach to use
|
285
|
-
// see https://github.com/es-shims/es5-shim/issues/150
|
286
|
-
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
|
331
|
+
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
|
332
|
+
// use it in defining shortcuts.
|
333
|
+
var owns = call.bind(ObjectPrototype.hasOwnProperty);
|
334
|
+
var toStr = call.bind(ObjectPrototype.toString);
|
335
|
+
var arraySlice = call.bind(array_slice);
|
336
|
+
var arraySliceApply = apply.bind(array_slice);
|
337
|
+
var strSlice = call.bind(StringPrototype.slice);
|
338
|
+
var strSplit = call.bind(StringPrototype.split);
|
339
|
+
var strIndexOf = call.bind(StringPrototype.indexOf);
|
340
|
+
var pushCall = call.bind(array_push);
|
341
|
+
var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable);
|
342
|
+
var arraySort = call.bind(ArrayPrototype.sort);
|
287
343
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
delete empty.toLocaleString;
|
293
|
-
delete empty.toString;
|
294
|
-
delete empty.valueOf;
|
295
|
-
/* eslint-disable no-proto */
|
296
|
-
empty.__proto__ = null;
|
297
|
-
/* eslint-enable no-proto */
|
344
|
+
//
|
345
|
+
// Array
|
346
|
+
// =====
|
347
|
+
//
|
298
348
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
349
|
+
var isArray = $Array.isArray || function isArray(obj) {
|
350
|
+
return toStr(obj) === '[object Array]';
|
351
|
+
};
|
352
|
+
|
353
|
+
// ES5 15.4.4.12
|
354
|
+
// http://es5.github.com/#x15.4.4.13
|
355
|
+
// Return len+argCount.
|
356
|
+
// [bugfix, ielt8]
|
357
|
+
// IE < 8 bug: [].unshift(0) === undefined but should be "1"
|
358
|
+
var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
|
359
|
+
defineProperties(ArrayPrototype, {
|
360
|
+
unshift: function () {
|
361
|
+
array_unshift.apply(this, arguments);
|
362
|
+
return this.length;
|
307
363
|
}
|
364
|
+
}, hasUnshiftReturnValueBug);
|
308
365
|
|
309
|
-
|
366
|
+
// ES5 15.4.3.2
|
367
|
+
// http://es5.github.com/#x15.4.3.2
|
368
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
|
369
|
+
defineProperties($Array, { isArray: isArray });
|
310
370
|
|
311
|
-
|
312
|
-
|
371
|
+
// The IsCallable() check in the Array functions
|
372
|
+
// has been replaced with a strict check on the
|
373
|
+
// internal class of the object to trap cases where
|
374
|
+
// the provided function was actually a regular
|
375
|
+
// expression literal, which in V8 and
|
376
|
+
// JavaScriptCore is a typeof "function". Only in
|
377
|
+
// V8 are regular expression literals permitted as
|
378
|
+
// reduce parameters, so it is desirable in the
|
379
|
+
// general case for the shim to match the more
|
380
|
+
// strict and common behavior of rejecting regular
|
381
|
+
// expressions.
|
313
382
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
if (typeof prototype !== 'object' && typeof prototype !== 'function') {
|
318
|
-
// In the native implementation `parent` can be `null`
|
319
|
-
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
|
320
|
-
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
|
321
|
-
// like they are in modern browsers. Using `Object.create` on DOM elements
|
322
|
-
// is...err...probably inappropriate, but the native version allows for it.
|
323
|
-
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
|
324
|
-
}
|
325
|
-
Type.prototype = prototype;
|
326
|
-
object = new Type();
|
327
|
-
// IE has no built-in implementation of `Object.getPrototypeOf`
|
328
|
-
// neither `__proto__`, but this manually setting `__proto__` will
|
329
|
-
// guarantee that `Object.getPrototypeOf` will work as expected with
|
330
|
-
// objects created using `Object.create`
|
331
|
-
/* eslint-disable no-proto */
|
332
|
-
object.__proto__ = prototype;
|
333
|
-
/* eslint-enable no-proto */
|
334
|
-
}
|
383
|
+
// ES5 15.4.4.18
|
384
|
+
// http://es5.github.com/#x15.4.4.18
|
385
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
|
335
386
|
|
336
|
-
|
337
|
-
|
338
|
-
|
387
|
+
// Check failure of by-index access of string characters (IE < 9)
|
388
|
+
// and failure of `0 in boxedString` (Rhino)
|
389
|
+
var boxedString = $Object('a');
|
390
|
+
var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
|
339
391
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
392
|
+
var properlyBoxesContext = function properlyBoxed(method) {
|
393
|
+
// Check node 0.6.21 bug where third parameter is not boxed
|
394
|
+
var properlyBoxesNonStrict = true;
|
395
|
+
var properlyBoxesStrict = true;
|
396
|
+
var threwException = false;
|
397
|
+
if (method) {
|
398
|
+
try {
|
399
|
+
method.call('foo', function (_, __, context) {
|
400
|
+
if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
|
401
|
+
});
|
346
402
|
|
347
|
-
|
348
|
-
|
349
|
-
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
|
350
|
-
// IE8 Reference:
|
351
|
-
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
|
352
|
-
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
|
353
|
-
// WebKit Bugs:
|
354
|
-
// https://bugs.webkit.org/show_bug.cgi?id=36423
|
403
|
+
method.call([1], function () {
|
404
|
+
'use strict';
|
355
405
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
return false;
|
406
|
+
properlyBoxesStrict = typeof this === 'string';
|
407
|
+
}, 'x');
|
408
|
+
} catch (e) {
|
409
|
+
threwException = true;
|
410
|
+
}
|
362
411
|
}
|
412
|
+
return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict;
|
363
413
|
};
|
364
414
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
}
|
376
|
-
|
377
|
-
if (!Object.defineProperty || definePropertyFallback) {
|
378
|
-
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
|
379
|
-
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
|
380
|
-
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
|
381
|
-
|
382
|
-
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
383
|
-
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
|
384
|
-
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
|
415
|
+
defineProperties(ArrayPrototype, {
|
416
|
+
forEach: function forEach(callbackfn/*, thisArg*/) {
|
417
|
+
var object = ES.ToObject(this);
|
418
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
419
|
+
var i = -1;
|
420
|
+
var length = ES.ToUint32(self.length);
|
421
|
+
var T;
|
422
|
+
if (arguments.length > 1) {
|
423
|
+
T = arguments[1];
|
385
424
|
}
|
386
|
-
|
387
|
-
|
425
|
+
|
426
|
+
// If no callback function or if callback is not a callable function
|
427
|
+
if (!isCallable(callbackfn)) {
|
428
|
+
throw new TypeError('Array.prototype.forEach callback must be a function');
|
388
429
|
}
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
430
|
+
|
431
|
+
while (++i < length) {
|
432
|
+
if (i in self) {
|
433
|
+
// Invoke the callback function with call, passing arguments:
|
434
|
+
// context, property value, property key, thisArg object
|
435
|
+
if (typeof T === 'undefined') {
|
436
|
+
callbackfn(self[i], i, object);
|
437
|
+
} else {
|
438
|
+
callbackfn.call(T, self[i], i, object);
|
439
|
+
}
|
396
440
|
}
|
397
441
|
}
|
442
|
+
}
|
443
|
+
}, !properlyBoxesContext(ArrayPrototype.forEach));
|
398
444
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
|
412
|
-
);
|
413
|
-
*/
|
414
|
-
|
415
|
-
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
|
416
|
-
// As accessors are supported only on engines implementing
|
417
|
-
// `__proto__` we can safely override `__proto__` while defining
|
418
|
-
// a property to make sure that we don't hit an inherited
|
419
|
-
// accessor.
|
420
|
-
/* eslint-disable no-proto */
|
421
|
-
var prototype = object.__proto__;
|
422
|
-
object.__proto__ = prototypeOfObject;
|
423
|
-
// Deleting a property anyway since getter / setter may be
|
424
|
-
// defined on object itself.
|
425
|
-
delete object[property];
|
426
|
-
object[property] = descriptor.value;
|
427
|
-
// Setting original `__proto__` back now.
|
428
|
-
object.__proto__ = prototype;
|
429
|
-
/* eslint-enable no-proto */
|
430
|
-
} else {
|
431
|
-
object[property] = descriptor.value;
|
432
|
-
}
|
433
|
-
} else {
|
434
|
-
if (!supportsAccessors) {
|
435
|
-
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
436
|
-
}
|
437
|
-
// If we got that far then getters and setters can be defined !!
|
438
|
-
if ('get' in descriptor) {
|
439
|
-
defineGetter(object, property, descriptor.get);
|
440
|
-
}
|
441
|
-
if ('set' in descriptor) {
|
442
|
-
defineSetter(object, property, descriptor.set);
|
443
|
-
}
|
445
|
+
// ES5 15.4.4.19
|
446
|
+
// http://es5.github.com/#x15.4.4.19
|
447
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
|
448
|
+
defineProperties(ArrayPrototype, {
|
449
|
+
map: function map(callbackfn/*, thisArg*/) {
|
450
|
+
var object = ES.ToObject(this);
|
451
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
452
|
+
var length = ES.ToUint32(self.length);
|
453
|
+
var result = $Array(length);
|
454
|
+
var T;
|
455
|
+
if (arguments.length > 1) {
|
456
|
+
T = arguments[1];
|
444
457
|
}
|
445
|
-
return object;
|
446
|
-
};
|
447
|
-
}
|
448
458
|
|
449
|
-
//
|
450
|
-
|
451
|
-
|
452
|
-
Object.defineProperties = function defineProperties(object, properties) {
|
453
|
-
// make a valiant attempt to use the real defineProperties
|
454
|
-
if (definePropertiesFallback) {
|
455
|
-
try {
|
456
|
-
return definePropertiesFallback.call(Object, object, properties);
|
457
|
-
} catch (exception) {
|
458
|
-
// try the shim if the real one doesn't work
|
459
|
-
}
|
459
|
+
// If no callback function or if callback is not a callable function
|
460
|
+
if (!isCallable(callbackfn)) {
|
461
|
+
throw new TypeError('Array.prototype.map callback must be a function');
|
460
462
|
}
|
461
463
|
|
462
|
-
|
463
|
-
if (
|
464
|
-
|
464
|
+
for (var i = 0; i < length; i++) {
|
465
|
+
if (i in self) {
|
466
|
+
if (typeof T === 'undefined') {
|
467
|
+
result[i] = callbackfn(self[i], i, object);
|
468
|
+
} else {
|
469
|
+
result[i] = callbackfn.call(T, self[i], i, object);
|
470
|
+
}
|
465
471
|
}
|
466
|
-
}
|
467
|
-
return
|
468
|
-
}
|
469
|
-
}
|
472
|
+
}
|
473
|
+
return result;
|
474
|
+
}
|
475
|
+
}, !properlyBoxesContext(ArrayPrototype.map));
|
470
476
|
|
471
|
-
// ES5 15.
|
472
|
-
// http://es5.github.com/#x15.
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
+
// ES5 15.4.4.20
|
478
|
+
// http://es5.github.com/#x15.4.4.20
|
479
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
|
480
|
+
defineProperties(ArrayPrototype, {
|
481
|
+
filter: function filter(callbackfn/*, thisArg*/) {
|
482
|
+
var object = ES.ToObject(this);
|
483
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
484
|
+
var length = ES.ToUint32(self.length);
|
485
|
+
var result = [];
|
486
|
+
var value;
|
487
|
+
var T;
|
488
|
+
if (arguments.length > 1) {
|
489
|
+
T = arguments[1];
|
477
490
|
}
|
478
|
-
// this is misleading and breaks feature-detection, but
|
479
|
-
// allows "securable" code to "gracefully" degrade to working
|
480
|
-
// but insecure code.
|
481
|
-
return object;
|
482
|
-
};
|
483
|
-
}
|
484
491
|
|
485
|
-
//
|
486
|
-
|
487
|
-
|
488
|
-
Object.freeze = function freeze(object) {
|
489
|
-
if (Object(object) !== object) {
|
490
|
-
throw new TypeError('Object.freeze can only be called on Objects.');
|
492
|
+
// If no callback function or if callback is not a callable function
|
493
|
+
if (!isCallable(callbackfn)) {
|
494
|
+
throw new TypeError('Array.prototype.filter callback must be a function');
|
491
495
|
}
|
492
|
-
// this is misleading and breaks feature-detection, but
|
493
|
-
// allows "securable" code to "gracefully" degrade to working
|
494
|
-
// but insecure code.
|
495
|
-
return object;
|
496
|
-
};
|
497
|
-
}
|
498
496
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
if (typeof object === 'function') {
|
506
|
-
return object;
|
507
|
-
} else {
|
508
|
-
return freezeObject(object);
|
497
|
+
for (var i = 0; i < length; i++) {
|
498
|
+
if (i in self) {
|
499
|
+
value = self[i];
|
500
|
+
if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) {
|
501
|
+
pushCall(result, value);
|
502
|
+
}
|
509
503
|
}
|
510
|
-
}
|
511
|
-
|
512
|
-
}
|
504
|
+
}
|
505
|
+
return result;
|
506
|
+
}
|
507
|
+
}, !properlyBoxesContext(ArrayPrototype.filter));
|
513
508
|
|
514
|
-
// ES5 15.
|
515
|
-
// http://es5.github.com/#x15.
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
509
|
+
// ES5 15.4.4.16
|
510
|
+
// http://es5.github.com/#x15.4.4.16
|
511
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
|
512
|
+
defineProperties(ArrayPrototype, {
|
513
|
+
every: function every(callbackfn/*, thisArg*/) {
|
514
|
+
var object = ES.ToObject(this);
|
515
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
516
|
+
var length = ES.ToUint32(self.length);
|
517
|
+
var T;
|
518
|
+
if (arguments.length > 1) {
|
519
|
+
T = arguments[1];
|
520
520
|
}
|
521
|
-
// this is misleading and breaks feature-detection, but
|
522
|
-
// allows "securable" code to "gracefully" degrade to working
|
523
|
-
// but insecure code.
|
524
|
-
return object;
|
525
|
-
};
|
526
|
-
}
|
527
521
|
|
528
|
-
//
|
529
|
-
|
530
|
-
|
531
|
-
Object.isSealed = function isSealed(object) {
|
532
|
-
if (Object(object) !== object) {
|
533
|
-
throw new TypeError('Object.isSealed can only be called on Objects.');
|
522
|
+
// If no callback function or if callback is not a callable function
|
523
|
+
if (!isCallable(callbackfn)) {
|
524
|
+
throw new TypeError('Array.prototype.every callback must be a function');
|
534
525
|
}
|
535
|
-
return false;
|
536
|
-
};
|
537
|
-
}
|
538
526
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
if (Object(object) !== object) {
|
544
|
-
throw new TypeError('Object.isFrozen can only be called on Objects.');
|
527
|
+
for (var i = 0; i < length; i++) {
|
528
|
+
if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
|
529
|
+
return false;
|
530
|
+
}
|
545
531
|
}
|
546
|
-
return
|
547
|
-
}
|
548
|
-
}
|
532
|
+
return true;
|
533
|
+
}
|
534
|
+
}, !properlyBoxesContext(ArrayPrototype.every));
|
549
535
|
|
550
|
-
// ES5 15.
|
551
|
-
// http://es5.github.com/#x15.
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
536
|
+
// ES5 15.4.4.17
|
537
|
+
// http://es5.github.com/#x15.4.4.17
|
538
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
|
539
|
+
defineProperties(ArrayPrototype, {
|
540
|
+
some: function some(callbackfn/*, thisArg */) {
|
541
|
+
var object = ES.ToObject(this);
|
542
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
543
|
+
var length = ES.ToUint32(self.length);
|
544
|
+
var T;
|
545
|
+
if (arguments.length > 1) {
|
546
|
+
T = arguments[1];
|
557
547
|
}
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
548
|
+
|
549
|
+
// If no callback function or if callback is not a callable function
|
550
|
+
if (!isCallable(callbackfn)) {
|
551
|
+
throw new TypeError('Array.prototype.some callback must be a function');
|
562
552
|
}
|
563
|
-
|
564
|
-
var
|
565
|
-
|
566
|
-
|
567
|
-
|
553
|
+
|
554
|
+
for (var i = 0; i < length; i++) {
|
555
|
+
if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
|
556
|
+
return true;
|
557
|
+
}
|
558
|
+
}
|
559
|
+
return false;
|
560
|
+
}
|
561
|
+
}, !properlyBoxesContext(ArrayPrototype.some));
|
562
|
+
|
563
|
+
// ES5 15.4.4.21
|
564
|
+
// http://es5.github.com/#x15.4.4.21
|
565
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
|
566
|
+
var reduceCoercesToObject = false;
|
567
|
+
if (ArrayPrototype.reduce) {
|
568
|
+
reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
568
569
|
}
|
570
|
+
defineProperties(ArrayPrototype, {
|
571
|
+
reduce: function reduce(callbackfn/*, initialValue*/) {
|
572
|
+
var object = ES.ToObject(this);
|
573
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
574
|
+
var length = ES.ToUint32(self.length);
|
569
575
|
|
570
|
-
|
576
|
+
// If no callback function or if callback is not a callable function
|
577
|
+
if (!isCallable(callbackfn)) {
|
578
|
+
throw new TypeError('Array.prototype.reduce callback must be a function');
|
579
|
+
}
|
571
580
|
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
*/
|
581
|
+
// no value to return if no initial value and an empty array
|
582
|
+
if (length === 0 && arguments.length === 1) {
|
583
|
+
throw new TypeError('reduce of empty array with no initial value');
|
584
|
+
}
|
577
585
|
|
578
|
-
|
586
|
+
var i = 0;
|
587
|
+
var result;
|
588
|
+
if (arguments.length >= 2) {
|
589
|
+
result = arguments[1];
|
590
|
+
} else {
|
591
|
+
do {
|
592
|
+
if (i in self) {
|
593
|
+
result = self[i++];
|
594
|
+
break;
|
595
|
+
}
|
579
596
|
|
580
|
-
//
|
581
|
-
|
597
|
+
// if array contains no values, no initial value to return
|
598
|
+
if (++i >= length) {
|
599
|
+
throw new TypeError('reduce of empty array with no initial value');
|
600
|
+
}
|
601
|
+
} while (true);
|
602
|
+
}
|
582
603
|
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
604
|
+
for (; i < length; i++) {
|
605
|
+
if (i in self) {
|
606
|
+
result = callbackfn(result, self[i], i, object);
|
607
|
+
}
|
608
|
+
}
|
587
609
|
|
588
|
-
|
589
|
-
if (typeof define === 'function' && define.amd) {
|
590
|
-
// AMD. Register as an anonymous module.
|
591
|
-
define(factory);
|
592
|
-
} else if (typeof exports === 'object') {
|
593
|
-
// Node. Does not work with strict CommonJS, but
|
594
|
-
// only CommonJS-like enviroments that support module.exports,
|
595
|
-
// like Node.
|
596
|
-
module.exports = factory();
|
597
|
-
} else {
|
598
|
-
// Browser globals (root is window)
|
599
|
-
root.returnExports = factory();
|
610
|
+
return result;
|
600
611
|
}
|
601
|
-
}
|
602
|
-
|
603
|
-
/**
|
604
|
-
* Brings an environment as close to ECMAScript 5 compliance
|
605
|
-
* as is possible with the facilities of erstwhile engines.
|
606
|
-
*
|
607
|
-
* Annotated ES5: http://es5.github.com/ (specific links below)
|
608
|
-
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
|
609
|
-
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
|
610
|
-
*/
|
612
|
+
}, !reduceCoercesToObject);
|
611
613
|
|
612
|
-
//
|
613
|
-
//
|
614
|
-
|
615
|
-
var
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
var
|
622
|
-
var
|
623
|
-
var
|
624
|
-
var call = FunctionPrototype.call;
|
614
|
+
// ES5 15.4.4.22
|
615
|
+
// http://es5.github.com/#x15.4.4.22
|
616
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
|
617
|
+
var reduceRightCoercesToObject = false;
|
618
|
+
if (ArrayPrototype.reduceRight) {
|
619
|
+
reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
620
|
+
}
|
621
|
+
defineProperties(ArrayPrototype, {
|
622
|
+
reduceRight: function reduceRight(callbackfn/*, initial*/) {
|
623
|
+
var object = ES.ToObject(this);
|
624
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
625
|
+
var length = ES.ToUint32(self.length);
|
625
626
|
|
626
|
-
//
|
627
|
-
|
627
|
+
// If no callback function or if callback is not a callable function
|
628
|
+
if (!isCallable(callbackfn)) {
|
629
|
+
throw new TypeError('Array.prototype.reduceRight callback must be a function');
|
630
|
+
}
|
628
631
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
+
// no value to return if no initial value, empty array
|
633
|
+
if (length === 0 && arguments.length === 1) {
|
634
|
+
throw new TypeError('reduceRight of empty array with no initial value');
|
635
|
+
}
|
632
636
|
|
633
|
-
var
|
634
|
-
var
|
635
|
-
|
636
|
-
|
637
|
+
var result;
|
638
|
+
var i = length - 1;
|
639
|
+
if (arguments.length >= 2) {
|
640
|
+
result = arguments[1];
|
641
|
+
} else {
|
642
|
+
do {
|
643
|
+
if (i in self) {
|
644
|
+
result = self[i--];
|
645
|
+
break;
|
646
|
+
}
|
637
647
|
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
typeof value === 'object' &&
|
645
|
-
typeof value.length === 'number' &&
|
646
|
-
value.length >= 0 &&
|
647
|
-
isCallable(value.callee);
|
648
|
-
}
|
649
|
-
return isArgs;
|
650
|
-
};
|
648
|
+
// if array contains no values, no initial value to return
|
649
|
+
if (--i < 0) {
|
650
|
+
throw new TypeError('reduceRight of empty array with no initial value');
|
651
|
+
}
|
652
|
+
} while (true);
|
653
|
+
}
|
651
654
|
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
try {
|
656
|
-
var obj = {};
|
657
|
-
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
|
658
|
-
for (var _ in obj) { return false; }
|
659
|
-
return obj.x === obj;
|
660
|
-
} catch (e) { /* this is ES3 */
|
661
|
-
return false;
|
662
|
-
}
|
663
|
-
}());
|
655
|
+
if (i < 0) {
|
656
|
+
return result;
|
657
|
+
}
|
664
658
|
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
if (!forceAssign && (name in object)) { return; }
|
671
|
-
Object.defineProperty(object, name, {
|
672
|
-
configurable: true,
|
673
|
-
enumerable: false,
|
674
|
-
writable: true,
|
675
|
-
value: method
|
676
|
-
});
|
677
|
-
};
|
678
|
-
} else {
|
679
|
-
defineProperty = function (object, name, method, forceAssign) {
|
680
|
-
if (!forceAssign && (name in object)) { return; }
|
681
|
-
object[name] = method;
|
682
|
-
};
|
683
|
-
}
|
684
|
-
return function defineProperties(object, map, forceAssign) {
|
685
|
-
for (var name in map) {
|
686
|
-
if (has.call(map, name)) {
|
687
|
-
defineProperty(object, name, map[name], forceAssign);
|
688
|
-
}
|
689
|
-
}
|
690
|
-
};
|
691
|
-
}(ObjectPrototype.hasOwnProperty));
|
659
|
+
do {
|
660
|
+
if (i in self) {
|
661
|
+
result = callbackfn(result, self[i], i, object);
|
662
|
+
}
|
663
|
+
} while (i--);
|
692
664
|
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
//
|
665
|
+
return result;
|
666
|
+
}
|
667
|
+
}, !reduceRightCoercesToObject);
|
697
668
|
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
669
|
+
// ES5 15.4.4.14
|
670
|
+
// http://es5.github.com/#x15.4.4.14
|
671
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
672
|
+
var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
|
673
|
+
defineProperties(ArrayPrototype, {
|
674
|
+
indexOf: function indexOf(searchElement/*, fromIndex */) {
|
675
|
+
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
|
676
|
+
var length = ES.ToUint32(self.length);
|
703
677
|
|
704
|
-
|
705
|
-
|
706
|
-
// http://es5.github.com/#x9.4
|
707
|
-
// http://jsperf.com/to-integer
|
708
|
-
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
|
709
|
-
ToInteger: function ToInteger(num) {
|
710
|
-
var n = +num;
|
711
|
-
if (n !== n) { // isNaN
|
712
|
-
n = 0;
|
713
|
-
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
714
|
-
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
678
|
+
if (length === 0) {
|
679
|
+
return -1;
|
715
680
|
}
|
716
|
-
return n;
|
717
|
-
},
|
718
681
|
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
if (isPrimitive(input)) {
|
723
|
-
return input;
|
682
|
+
var i = 0;
|
683
|
+
if (arguments.length > 1) {
|
684
|
+
i = ES.ToInteger(arguments[1]);
|
724
685
|
}
|
725
|
-
valueOf = input.valueOf;
|
726
|
-
if (isCallable(valueOf)) {
|
727
|
-
val = valueOf.call(input);
|
728
|
-
if (isPrimitive(val)) {
|
729
|
-
return val;
|
730
|
-
}
|
731
|
-
}
|
732
|
-
toStr = input.toString;
|
733
|
-
if (isCallable(toStr)) {
|
734
|
-
val = toStr.call(input);
|
735
|
-
if (isPrimitive(val)) {
|
736
|
-
return val;
|
737
|
-
}
|
738
|
-
}
|
739
|
-
throw new TypeError();
|
740
|
-
},
|
741
686
|
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
throw new TypeError("can't convert " + o + ' to object');
|
687
|
+
// handle negative indices
|
688
|
+
i = i >= 0 ? i : max(0, length + i);
|
689
|
+
for (; i < length; i++) {
|
690
|
+
if (i in self && self[i] === searchElement) {
|
691
|
+
return i;
|
692
|
+
}
|
749
693
|
}
|
750
|
-
return
|
751
|
-
},
|
752
|
-
|
753
|
-
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
|
754
|
-
ToUint32: function ToUint32(x) {
|
755
|
-
return x >>> 0;
|
694
|
+
return -1;
|
756
695
|
}
|
757
|
-
};
|
758
|
-
|
759
|
-
//
|
760
|
-
// Function
|
761
|
-
// ========
|
762
|
-
//
|
763
|
-
|
764
|
-
// ES-5 15.3.4.5
|
765
|
-
// http://es5.github.com/#x15.3.4.5
|
696
|
+
}, hasFirefox2IndexOfBug);
|
766
697
|
|
767
|
-
|
698
|
+
// ES5 15.4.4.15
|
699
|
+
// http://es5.github.com/#x15.4.4.15
|
700
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
701
|
+
var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
|
702
|
+
defineProperties(ArrayPrototype, {
|
703
|
+
lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) {
|
704
|
+
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
|
705
|
+
var length = ES.ToUint32(self.length);
|
768
706
|
|
769
|
-
|
770
|
-
|
771
|
-
// 1. Let Target be the this value.
|
772
|
-
var target = this;
|
773
|
-
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
774
|
-
if (!isCallable(target)) {
|
775
|
-
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
707
|
+
if (length === 0) {
|
708
|
+
return -1;
|
776
709
|
}
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
var args = array_slice.call(arguments, 1); // for normal call
|
781
|
-
// 4. Let F be a new native ECMAScript object.
|
782
|
-
// 11. Set the [[Prototype]] internal property of F to the standard
|
783
|
-
// built-in Function prototype object as specified in 15.3.3.1.
|
784
|
-
// 12. Set the [[Call]] internal property of F as described in
|
785
|
-
// 15.3.4.5.1.
|
786
|
-
// 13. Set the [[Construct]] internal property of F as described in
|
787
|
-
// 15.3.4.5.2.
|
788
|
-
// 14. Set the [[HasInstance]] internal property of F as described in
|
789
|
-
// 15.3.4.5.3.
|
790
|
-
var bound;
|
791
|
-
var binder = function () {
|
792
|
-
|
793
|
-
if (this instanceof bound) {
|
794
|
-
// 15.3.4.5.2 [[Construct]]
|
795
|
-
// When the [[Construct]] internal method of a function object,
|
796
|
-
// F that was created using the bind function is called with a
|
797
|
-
// list of arguments ExtraArgs, the following steps are taken:
|
798
|
-
// 1. Let target be the value of F's [[TargetFunction]]
|
799
|
-
// internal property.
|
800
|
-
// 2. If target has no [[Construct]] internal method, a
|
801
|
-
// TypeError exception is thrown.
|
802
|
-
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
803
|
-
// property.
|
804
|
-
// 4. Let args be a new list containing the same values as the
|
805
|
-
// list boundArgs in the same order followed by the same
|
806
|
-
// values as the list ExtraArgs in the same order.
|
807
|
-
// 5. Return the result of calling the [[Construct]] internal
|
808
|
-
// method of target providing args as the arguments.
|
809
|
-
|
810
|
-
var result = target.apply(
|
811
|
-
this,
|
812
|
-
array_concat.call(args, array_slice.call(arguments))
|
813
|
-
);
|
814
|
-
if (Object(result) === result) {
|
815
|
-
return result;
|
816
|
-
}
|
817
|
-
return this;
|
818
|
-
|
819
|
-
} else {
|
820
|
-
// 15.3.4.5.1 [[Call]]
|
821
|
-
// When the [[Call]] internal method of a function object, F,
|
822
|
-
// which was created using the bind function is called with a
|
823
|
-
// this value and a list of arguments ExtraArgs, the following
|
824
|
-
// steps are taken:
|
825
|
-
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
826
|
-
// property.
|
827
|
-
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
828
|
-
// property.
|
829
|
-
// 3. Let target be the value of F's [[TargetFunction]] internal
|
830
|
-
// property.
|
831
|
-
// 4. Let args be a new list containing the same values as the
|
832
|
-
// list boundArgs in the same order followed by the same
|
833
|
-
// values as the list ExtraArgs in the same order.
|
834
|
-
// 5. Return the result of calling the [[Call]] internal method
|
835
|
-
// of target providing boundThis as the this value and
|
836
|
-
// providing args as the arguments.
|
837
|
-
|
838
|
-
// equiv: target.call(this, ...boundArgs, ...args)
|
839
|
-
return target.apply(
|
840
|
-
that,
|
841
|
-
array_concat.call(args, array_slice.call(arguments))
|
842
|
-
);
|
843
|
-
|
844
|
-
}
|
845
|
-
|
846
|
-
};
|
847
|
-
|
848
|
-
// 15. If the [[Class]] internal property of Target is "Function", then
|
849
|
-
// a. Let L be the length property of Target minus the length of A.
|
850
|
-
// b. Set the length own property of F to either 0 or L, whichever is
|
851
|
-
// larger.
|
852
|
-
// 16. Else set the length own property of F to 0.
|
853
|
-
|
854
|
-
var boundLength = Math.max(0, target.length - args.length);
|
855
|
-
|
856
|
-
// 17. Set the attributes of the length own property of F to the values
|
857
|
-
// specified in 15.3.5.1.
|
858
|
-
var boundArgs = [];
|
859
|
-
for (var i = 0; i < boundLength; i++) {
|
860
|
-
boundArgs.push('$' + i);
|
710
|
+
var i = length - 1;
|
711
|
+
if (arguments.length > 1) {
|
712
|
+
i = min(i, ES.ToInteger(arguments[1]));
|
861
713
|
}
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
// and so this code will never be executed.
|
869
|
-
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
|
870
|
-
|
871
|
-
if (target.prototype) {
|
872
|
-
Empty.prototype = target.prototype;
|
873
|
-
bound.prototype = new Empty();
|
874
|
-
// Clean up dangling references.
|
875
|
-
Empty.prototype = null;
|
714
|
+
// handle negative indices
|
715
|
+
i = i >= 0 ? i : length - Math.abs(i);
|
716
|
+
for (; i >= 0; i--) {
|
717
|
+
if (i in self && searchElement === self[i]) {
|
718
|
+
return i;
|
719
|
+
}
|
876
720
|
}
|
877
|
-
|
878
|
-
// TODO
|
879
|
-
// 18. Set the [[Extensible]] internal property of F to true.
|
880
|
-
|
881
|
-
// TODO
|
882
|
-
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
883
|
-
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
884
|
-
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
885
|
-
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
886
|
-
// false.
|
887
|
-
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
888
|
-
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
889
|
-
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
890
|
-
// and false.
|
891
|
-
|
892
|
-
// TODO
|
893
|
-
// NOTE Function objects created using Function.prototype.bind do not
|
894
|
-
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
895
|
-
// [[Scope]] internal properties.
|
896
|
-
// XXX can't delete prototype in pure-js.
|
897
|
-
|
898
|
-
// 22. Return F.
|
899
|
-
return bound;
|
721
|
+
return -1;
|
900
722
|
}
|
901
|
-
});
|
902
|
-
|
903
|
-
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
|
904
|
-
// us it in defining shortcuts.
|
905
|
-
var owns = call.bind(ObjectPrototype.hasOwnProperty);
|
906
|
-
|
907
|
-
//
|
908
|
-
// Array
|
909
|
-
// =====
|
910
|
-
//
|
723
|
+
}, hasFirefox2LastIndexOfBug);
|
911
724
|
|
912
725
|
// ES5 15.4.4.12
|
913
726
|
// http://es5.github.com/#x15.4.4.12
|
@@ -936,11 +749,11 @@ defineProperties(ArrayPrototype, {
|
|
936
749
|
splice: function splice(start, deleteCount) {
|
937
750
|
if (arguments.length === 0) { return []; }
|
938
751
|
var args = arguments;
|
939
|
-
this.length =
|
752
|
+
this.length = max(ES.ToInteger(this.length), 0);
|
940
753
|
if (arguments.length > 0 && typeof deleteCount !== 'number') {
|
941
|
-
args =
|
754
|
+
args = arraySlice(arguments);
|
942
755
|
if (args.length < 2) {
|
943
|
-
args
|
756
|
+
pushCall(args, this.length - start);
|
944
757
|
} else {
|
945
758
|
args[1] = ES.ToInteger(deleteCount);
|
946
759
|
}
|
@@ -948,457 +761,520 @@ defineProperties(ArrayPrototype, {
|
|
948
761
|
return array_splice.apply(this, args);
|
949
762
|
}
|
950
763
|
}, !spliceWorksWithEmptyObject);
|
951
|
-
|
952
|
-
//
|
953
|
-
//
|
954
|
-
|
955
|
-
//
|
956
|
-
|
957
|
-
|
764
|
+
var spliceWorksWithLargeSparseArrays = (function () {
|
765
|
+
// Per https://github.com/es-shims/es5-shim/issues/295
|
766
|
+
// Safari 7/8 breaks with sparse arrays of size 1e5 or greater
|
767
|
+
var arr = new $Array(1e5);
|
768
|
+
// note: the index MUST be 8 or larger or the test will false pass
|
769
|
+
arr[8] = 'x';
|
770
|
+
arr.splice(1, 1);
|
771
|
+
// note: this test must be defined *after* the indexOf shim
|
772
|
+
// per https://github.com/es-shims/es5-shim/issues/313
|
773
|
+
return arr.indexOf('x') === 7;
|
774
|
+
}());
|
775
|
+
var spliceWorksWithSmallSparseArrays = (function () {
|
776
|
+
// Per https://github.com/es-shims/es5-shim/issues/295
|
777
|
+
// Opera 12.15 breaks on this, no idea why.
|
778
|
+
var n = 256;
|
779
|
+
var arr = [];
|
780
|
+
arr[n] = 'a';
|
781
|
+
arr.splice(n + 1, 0, 'b');
|
782
|
+
return arr[n] === 'a';
|
783
|
+
}());
|
958
784
|
defineProperties(ArrayPrototype, {
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
785
|
+
splice: function splice(start, deleteCount) {
|
786
|
+
var O = ES.ToObject(this);
|
787
|
+
var A = [];
|
788
|
+
var len = ES.ToUint32(O.length);
|
789
|
+
var relativeStart = ES.ToInteger(start);
|
790
|
+
var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len);
|
791
|
+
var actualDeleteCount = min(max(ES.ToInteger(deleteCount), 0), len - actualStart);
|
792
|
+
|
793
|
+
var k = 0;
|
794
|
+
var from;
|
795
|
+
while (k < actualDeleteCount) {
|
796
|
+
from = $String(actualStart + k);
|
797
|
+
if (owns(O, from)) {
|
798
|
+
A[k] = O[from];
|
799
|
+
}
|
800
|
+
k += 1;
|
801
|
+
}
|
802
|
+
|
803
|
+
var items = arraySlice(arguments, 2);
|
804
|
+
var itemCount = items.length;
|
805
|
+
var to;
|
806
|
+
if (itemCount < actualDeleteCount) {
|
807
|
+
k = actualStart;
|
808
|
+
var maxK = len - actualDeleteCount;
|
809
|
+
while (k < maxK) {
|
810
|
+
from = $String(k + actualDeleteCount);
|
811
|
+
to = $String(k + itemCount);
|
812
|
+
if (owns(O, from)) {
|
813
|
+
O[to] = O[from];
|
814
|
+
} else {
|
815
|
+
delete O[to];
|
816
|
+
}
|
817
|
+
k += 1;
|
818
|
+
}
|
819
|
+
k = len;
|
820
|
+
var minK = len - actualDeleteCount + itemCount;
|
821
|
+
while (k > minK) {
|
822
|
+
delete O[k - 1];
|
823
|
+
k -= 1;
|
824
|
+
}
|
825
|
+
} else if (itemCount > actualDeleteCount) {
|
826
|
+
k = len - actualDeleteCount;
|
827
|
+
while (k > actualStart) {
|
828
|
+
from = $String(k + actualDeleteCount - 1);
|
829
|
+
to = $String(k + itemCount - 1);
|
830
|
+
if (owns(O, from)) {
|
831
|
+
O[to] = O[from];
|
832
|
+
} else {
|
833
|
+
delete O[to];
|
834
|
+
}
|
835
|
+
k -= 1;
|
836
|
+
}
|
837
|
+
}
|
838
|
+
k = actualStart;
|
839
|
+
for (var i = 0; i < items.length; ++i) {
|
840
|
+
O[k] = items[i];
|
841
|
+
k += 1;
|
842
|
+
}
|
843
|
+
O.length = len - actualDeleteCount + itemCount;
|
985
844
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
|
845
|
+
return A;
|
846
|
+
}
|
847
|
+
}, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays);
|
990
848
|
|
991
|
-
var
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
849
|
+
var originalJoin = ArrayPrototype.join;
|
850
|
+
var hasStringJoinBug;
|
851
|
+
try {
|
852
|
+
hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3';
|
853
|
+
} catch (e) {
|
854
|
+
hasStringJoinBug = true;
|
855
|
+
}
|
856
|
+
if (hasStringJoinBug) {
|
857
|
+
defineProperties(ArrayPrototype, {
|
858
|
+
join: function join(separator) {
|
859
|
+
var sep = typeof separator === 'undefined' ? ',' : separator;
|
860
|
+
return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep);
|
861
|
+
}
|
862
|
+
}, hasStringJoinBug);
|
863
|
+
}
|
999
864
|
|
1000
|
-
|
1001
|
-
|
865
|
+
var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2';
|
866
|
+
if (hasJoinUndefinedBug) {
|
867
|
+
defineProperties(ArrayPrototype, {
|
868
|
+
join: function join(separator) {
|
869
|
+
var sep = typeof separator === 'undefined' ? ',' : separator;
|
870
|
+
return originalJoin.call(this, sep);
|
871
|
+
}
|
872
|
+
}, hasJoinUndefinedBug);
|
873
|
+
}
|
1002
874
|
|
1003
|
-
|
1004
|
-
|
875
|
+
var pushShim = function push(item) {
|
876
|
+
var O = ES.ToObject(this);
|
877
|
+
var n = ES.ToUint32(O.length);
|
878
|
+
var i = 0;
|
879
|
+
while (i < arguments.length) {
|
880
|
+
O[n + i] = arguments[i];
|
881
|
+
i += 1;
|
1005
882
|
}
|
1006
|
-
|
883
|
+
O.length = n + i;
|
884
|
+
return n + i;
|
1007
885
|
};
|
1008
886
|
|
887
|
+
var pushIsNotGeneric = (function () {
|
888
|
+
var obj = {};
|
889
|
+
var result = Array.prototype.push.call(obj, undefined);
|
890
|
+
return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0);
|
891
|
+
}());
|
1009
892
|
defineProperties(ArrayPrototype, {
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
var i = -1;
|
1014
|
-
var length = self.length >>> 0;
|
1015
|
-
var T;
|
1016
|
-
if (arguments.length > 1) {
|
1017
|
-
T = arguments[1];
|
893
|
+
push: function push(item) {
|
894
|
+
if (isArray(this)) {
|
895
|
+
return array_push.apply(this, arguments);
|
1018
896
|
}
|
897
|
+
return pushShim.apply(this, arguments);
|
898
|
+
}
|
899
|
+
}, pushIsNotGeneric);
|
1019
900
|
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
901
|
+
// This fixes a very weird bug in Opera 10.6 when pushing `undefined
|
902
|
+
var pushUndefinedIsWeird = (function () {
|
903
|
+
var arr = [];
|
904
|
+
var result = arr.push(undefined);
|
905
|
+
return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0);
|
906
|
+
}());
|
907
|
+
defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird);
|
1024
908
|
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
callbackfn(self[i], i, object);
|
1033
|
-
}
|
1034
|
-
}
|
1035
|
-
}
|
909
|
+
// ES5 15.2.3.14
|
910
|
+
// http://es5.github.io/#x15.4.4.10
|
911
|
+
// Fix boxed string bug
|
912
|
+
defineProperties(ArrayPrototype, {
|
913
|
+
slice: function (start, end) {
|
914
|
+
var arr = isString(this) ? strSplit(this, '') : this;
|
915
|
+
return arraySliceApply(arr, arguments);
|
1036
916
|
}
|
1037
|
-
},
|
917
|
+
}, splitString);
|
1038
918
|
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
919
|
+
var sortIgnoresNonFunctions = (function () {
|
920
|
+
try {
|
921
|
+
[1, 2].sort(null);
|
922
|
+
[1, 2].sort({});
|
923
|
+
return true;
|
924
|
+
} catch (e) { /**/ }
|
925
|
+
return false;
|
926
|
+
}());
|
927
|
+
var sortThrowsOnRegex = (function () {
|
928
|
+
// this is a problem in Firefox 4, in which `typeof /a/ === 'function'`
|
929
|
+
try {
|
930
|
+
[1, 2].sort(/a/);
|
931
|
+
return false;
|
932
|
+
} catch (e) { /**/ }
|
933
|
+
return true;
|
934
|
+
}());
|
935
|
+
var sortIgnoresUndefined = (function () {
|
936
|
+
// applies in IE 8, for one.
|
937
|
+
try {
|
938
|
+
[1, 2].sort(undefined);
|
939
|
+
return true;
|
940
|
+
} catch (e) { /**/ }
|
941
|
+
return false;
|
942
|
+
}());
|
1042
943
|
defineProperties(ArrayPrototype, {
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
var length = self.length >>> 0;
|
1047
|
-
var result = Array(length);
|
1048
|
-
var T;
|
1049
|
-
if (arguments.length > 1) {
|
1050
|
-
T = arguments[1];
|
1051
|
-
}
|
1052
|
-
|
1053
|
-
// If no callback function or if callback is not a callable function
|
1054
|
-
if (!isCallable(callbackfn)) {
|
1055
|
-
throw new TypeError('Array.prototype.map callback must be a function');
|
944
|
+
sort: function sort(compareFn) {
|
945
|
+
if (typeof compareFn === 'undefined') {
|
946
|
+
return arraySort(this);
|
1056
947
|
}
|
1057
|
-
|
1058
|
-
|
1059
|
-
if (i in self) {
|
1060
|
-
if (typeof T !== 'undefined') {
|
1061
|
-
result[i] = callbackfn.call(T, self[i], i, object);
|
1062
|
-
} else {
|
1063
|
-
result[i] = callbackfn(self[i], i, object);
|
1064
|
-
}
|
1065
|
-
}
|
948
|
+
if (!isCallable(compareFn)) {
|
949
|
+
throw new TypeError('Array.prototype.sort callback must be a function');
|
1066
950
|
}
|
1067
|
-
return
|
951
|
+
return arraySort(this, compareFn);
|
1068
952
|
}
|
1069
|
-
}, !
|
953
|
+
}, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex);
|
1070
954
|
|
1071
|
-
//
|
1072
|
-
//
|
1073
|
-
//
|
1074
|
-
|
1075
|
-
filter: function filter(callbackfn /*, thisArg*/) {
|
1076
|
-
var object = ES.ToObject(this);
|
1077
|
-
var self = splitString && isString(this) ? this.split('') : object;
|
1078
|
-
var length = self.length >>> 0;
|
1079
|
-
var result = [];
|
1080
|
-
var value;
|
1081
|
-
var T;
|
1082
|
-
if (arguments.length > 1) {
|
1083
|
-
T = arguments[1];
|
1084
|
-
}
|
955
|
+
//
|
956
|
+
// Object
|
957
|
+
// ======
|
958
|
+
//
|
1085
959
|
|
1086
|
-
|
1087
|
-
|
1088
|
-
throw new TypeError('Array.prototype.filter callback must be a function');
|
1089
|
-
}
|
960
|
+
// ES5 15.2.3.14
|
961
|
+
// http://es5.github.com/#x15.2.3.14
|
1090
962
|
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
963
|
+
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
|
964
|
+
var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString');
|
965
|
+
var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype');
|
966
|
+
var hasStringEnumBug = !owns('x', '0');
|
967
|
+
var equalsConstructorPrototype = function (o) {
|
968
|
+
var ctor = o.constructor;
|
969
|
+
return ctor && ctor.prototype === o;
|
970
|
+
};
|
971
|
+
var blacklistedKeys = {
|
972
|
+
$window: true,
|
973
|
+
$console: true,
|
974
|
+
$parent: true,
|
975
|
+
$self: true,
|
976
|
+
$frame: true,
|
977
|
+
$frames: true,
|
978
|
+
$frameElement: true,
|
979
|
+
$webkitIndexedDB: true,
|
980
|
+
$webkitStorageInfo: true,
|
981
|
+
$external: true
|
982
|
+
};
|
983
|
+
var hasAutomationEqualityBug = (function () {
|
984
|
+
/* globals window */
|
985
|
+
if (typeof window === 'undefined') { return false; }
|
986
|
+
for (var k in window) {
|
987
|
+
try {
|
988
|
+
if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
989
|
+
equalsConstructorPrototype(window[k]);
|
1097
990
|
}
|
991
|
+
} catch (e) {
|
992
|
+
return true;
|
1098
993
|
}
|
1099
|
-
return result;
|
1100
994
|
}
|
1101
|
-
|
995
|
+
return false;
|
996
|
+
}());
|
997
|
+
var equalsConstructorPrototypeIfNotBuggy = function (object) {
|
998
|
+
if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(object); }
|
999
|
+
try {
|
1000
|
+
return equalsConstructorPrototype(object);
|
1001
|
+
} catch (e) {
|
1002
|
+
return false;
|
1003
|
+
}
|
1004
|
+
};
|
1005
|
+
var dontEnums = [
|
1006
|
+
'toString',
|
1007
|
+
'toLocaleString',
|
1008
|
+
'valueOf',
|
1009
|
+
'hasOwnProperty',
|
1010
|
+
'isPrototypeOf',
|
1011
|
+
'propertyIsEnumerable',
|
1012
|
+
'constructor'
|
1013
|
+
];
|
1014
|
+
var dontEnumsLength = dontEnums.length;
|
1015
|
+
|
1016
|
+
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
|
1017
|
+
// can be replaced with require('is-arguments') if we ever use a build process instead
|
1018
|
+
var isStandardArguments = function isArguments(value) {
|
1019
|
+
return toStr(value) === '[object Arguments]';
|
1020
|
+
};
|
1021
|
+
var isLegacyArguments = function isArguments(value) {
|
1022
|
+
return value !== null &&
|
1023
|
+
typeof value === 'object' &&
|
1024
|
+
typeof value.length === 'number' &&
|
1025
|
+
value.length >= 0 &&
|
1026
|
+
!isArray(value) &&
|
1027
|
+
isCallable(value.callee);
|
1028
|
+
};
|
1029
|
+
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
|
1102
1030
|
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
var
|
1109
|
-
var self = splitString && isString(this) ? this.split('') : object;
|
1110
|
-
var length = self.length >>> 0;
|
1111
|
-
var T;
|
1112
|
-
if (arguments.length > 1) {
|
1113
|
-
T = arguments[1];
|
1114
|
-
}
|
1031
|
+
defineProperties($Object, {
|
1032
|
+
keys: function keys(object) {
|
1033
|
+
var isFn = isCallable(object);
|
1034
|
+
var isArgs = isArguments(object);
|
1035
|
+
var isObject = object !== null && typeof object === 'object';
|
1036
|
+
var isStr = isObject && isString(object);
|
1115
1037
|
|
1116
|
-
|
1117
|
-
|
1118
|
-
throw new TypeError('Array.prototype.every callback must be a function');
|
1038
|
+
if (!isObject && !isFn && !isArgs) {
|
1039
|
+
throw new TypeError('Object.keys called on a non-object');
|
1119
1040
|
}
|
1120
1041
|
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1042
|
+
var theKeys = [];
|
1043
|
+
var skipProto = hasProtoEnumBug && isFn;
|
1044
|
+
if ((isStr && hasStringEnumBug) || isArgs) {
|
1045
|
+
for (var i = 0; i < object.length; ++i) {
|
1046
|
+
pushCall(theKeys, $String(i));
|
1124
1047
|
}
|
1125
1048
|
}
|
1126
|
-
return true;
|
1127
|
-
}
|
1128
|
-
}, !properlyBoxesContext(ArrayPrototype.every));
|
1129
1049
|
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
var self = splitString && isString(this) ? this.split('') : object;
|
1137
|
-
var length = self.length >>> 0;
|
1138
|
-
var T;
|
1139
|
-
if (arguments.length > 1) {
|
1140
|
-
T = arguments[1];
|
1050
|
+
if (!isArgs) {
|
1051
|
+
for (var name in object) {
|
1052
|
+
if (!(skipProto && name === 'prototype') && owns(object, name)) {
|
1053
|
+
pushCall(theKeys, $String(name));
|
1054
|
+
}
|
1055
|
+
}
|
1141
1056
|
}
|
1142
1057
|
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1058
|
+
if (hasDontEnumBug) {
|
1059
|
+
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
1060
|
+
for (var j = 0; j < dontEnumsLength; j++) {
|
1061
|
+
var dontEnum = dontEnums[j];
|
1062
|
+
if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
|
1063
|
+
pushCall(theKeys, dontEnum);
|
1064
|
+
}
|
1065
|
+
}
|
1146
1066
|
}
|
1067
|
+
return theKeys;
|
1068
|
+
}
|
1069
|
+
});
|
1147
1070
|
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1071
|
+
var keysWorksWithArguments = $Object.keys && (function () {
|
1072
|
+
// Safari 5.0 bug
|
1073
|
+
return $Object.keys(arguments).length === 2;
|
1074
|
+
}(1, 2));
|
1075
|
+
var keysHasArgumentsLengthBug = $Object.keys && (function () {
|
1076
|
+
var argKeys = $Object.keys(arguments);
|
1077
|
+
return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1;
|
1078
|
+
}(1));
|
1079
|
+
var originalKeys = $Object.keys;
|
1080
|
+
defineProperties($Object, {
|
1081
|
+
keys: function keys(object) {
|
1082
|
+
if (isArguments(object)) {
|
1083
|
+
return originalKeys(arraySlice(object));
|
1084
|
+
} else {
|
1085
|
+
return originalKeys(object);
|
1152
1086
|
}
|
1153
|
-
return false;
|
1154
1087
|
}
|
1155
|
-
}, !
|
1088
|
+
}, !keysWorksWithArguments || keysHasArgumentsLengthBug);
|
1156
1089
|
|
1157
|
-
//
|
1158
|
-
//
|
1159
|
-
//
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1090
|
+
//
|
1091
|
+
// Date
|
1092
|
+
// ====
|
1093
|
+
//
|
1094
|
+
|
1095
|
+
var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0;
|
1096
|
+
var aNegativeTestDate = new Date(-1509842289600292);
|
1097
|
+
var aPositiveTestDate = new Date(1449662400000);
|
1098
|
+
var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT';
|
1099
|
+
var hasToDateStringFormatBug;
|
1100
|
+
var hasToStringFormatBug;
|
1101
|
+
var timeZoneOffset = aNegativeTestDate.getTimezoneOffset();
|
1102
|
+
if (timeZoneOffset < -720) {
|
1103
|
+
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875';
|
1104
|
+
hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
|
1105
|
+
} else {
|
1106
|
+
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875';
|
1107
|
+
hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
|
1163
1108
|
}
|
1164
|
-
defineProperties(ArrayPrototype, {
|
1165
|
-
reduce: function reduce(callbackfn /*, initialValue*/) {
|
1166
|
-
var object = ES.ToObject(this);
|
1167
|
-
var self = splitString && isString(this) ? this.split('') : object;
|
1168
|
-
var length = self.length >>> 0;
|
1169
1109
|
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1110
|
+
var originalGetFullYear = call.bind(Date.prototype.getFullYear);
|
1111
|
+
var originalGetMonth = call.bind(Date.prototype.getMonth);
|
1112
|
+
var originalGetDate = call.bind(Date.prototype.getDate);
|
1113
|
+
var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear);
|
1114
|
+
var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth);
|
1115
|
+
var originalGetUTCDate = call.bind(Date.prototype.getUTCDate);
|
1116
|
+
var originalGetUTCDay = call.bind(Date.prototype.getUTCDay);
|
1117
|
+
var originalGetUTCHours = call.bind(Date.prototype.getUTCHours);
|
1118
|
+
var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes);
|
1119
|
+
var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds);
|
1120
|
+
var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds);
|
1121
|
+
var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
1122
|
+
var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
1123
|
+
var daysInMonth = function daysInMonth(month, year) {
|
1124
|
+
return originalGetDate(new Date(year, month, 0));
|
1125
|
+
};
|
1174
1126
|
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1127
|
+
defineProperties(Date.prototype, {
|
1128
|
+
getFullYear: function getFullYear() {
|
1129
|
+
if (!this || !(this instanceof Date)) {
|
1130
|
+
throw new TypeError('this is not a Date object.');
|
1178
1131
|
}
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
if (arguments.length >= 2) {
|
1183
|
-
result = arguments[1];
|
1184
|
-
} else {
|
1185
|
-
do {
|
1186
|
-
if (i in self) {
|
1187
|
-
result = self[i++];
|
1188
|
-
break;
|
1189
|
-
}
|
1190
|
-
|
1191
|
-
// if array contains no values, no initial value to return
|
1192
|
-
if (++i >= length) {
|
1193
|
-
throw new TypeError('reduce of empty array with no initial value');
|
1194
|
-
}
|
1195
|
-
} while (true);
|
1132
|
+
var year = originalGetFullYear(this);
|
1133
|
+
if (year < 0 && originalGetMonth(this) > 11) {
|
1134
|
+
return year + 1;
|
1196
1135
|
}
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1136
|
+
return year;
|
1137
|
+
},
|
1138
|
+
getMonth: function getMonth() {
|
1139
|
+
if (!this || !(this instanceof Date)) {
|
1140
|
+
throw new TypeError('this is not a Date object.');
|
1141
|
+
}
|
1142
|
+
var year = originalGetFullYear(this);
|
1143
|
+
var month = originalGetMonth(this);
|
1144
|
+
if (year < 0 && month > 11) {
|
1145
|
+
return 0;
|
1146
|
+
}
|
1147
|
+
return month;
|
1148
|
+
},
|
1149
|
+
getDate: function getDate() {
|
1150
|
+
if (!this || !(this instanceof Date)) {
|
1151
|
+
throw new TypeError('this is not a Date object.');
|
1152
|
+
}
|
1153
|
+
var year = originalGetFullYear(this);
|
1154
|
+
var month = originalGetMonth(this);
|
1155
|
+
var date = originalGetDate(this);
|
1156
|
+
if (year < 0 && month > 11) {
|
1157
|
+
if (month === 12) {
|
1158
|
+
return date;
|
1201
1159
|
}
|
1160
|
+
var days = daysInMonth(0, year + 1);
|
1161
|
+
return (days - date) + 1;
|
1202
1162
|
}
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
// ES5 15.4.4.22
|
1209
|
-
// http://es5.github.com/#x15.4.4.22
|
1210
|
-
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
|
1211
|
-
var reduceRightCoercesToObject = false;
|
1212
|
-
if (ArrayPrototype.reduceRight) {
|
1213
|
-
reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
1214
|
-
}
|
1215
|
-
defineProperties(ArrayPrototype, {
|
1216
|
-
reduceRight: function reduceRight(callbackfn/*, initial*/) {
|
1217
|
-
var object = ES.ToObject(this);
|
1218
|
-
var self = splitString && isString(this) ? this.split('') : object;
|
1219
|
-
var length = self.length >>> 0;
|
1220
|
-
|
1221
|
-
// If no callback function or if callback is not a callable function
|
1222
|
-
if (!isCallable(callbackfn)) {
|
1223
|
-
throw new TypeError('Array.prototype.reduceRight callback must be a function');
|
1163
|
+
return date;
|
1164
|
+
},
|
1165
|
+
getUTCFullYear: function getUTCFullYear() {
|
1166
|
+
if (!this || !(this instanceof Date)) {
|
1167
|
+
throw new TypeError('this is not a Date object.');
|
1224
1168
|
}
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
throw new TypeError('reduceRight of empty array with no initial value');
|
1169
|
+
var year = originalGetUTCFullYear(this);
|
1170
|
+
if (year < 0 && originalGetUTCMonth(this) > 11) {
|
1171
|
+
return year + 1;
|
1229
1172
|
}
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
if (
|
1234
|
-
|
1235
|
-
} else {
|
1236
|
-
do {
|
1237
|
-
if (i in self) {
|
1238
|
-
result = self[i--];
|
1239
|
-
break;
|
1240
|
-
}
|
1241
|
-
|
1242
|
-
// if array contains no values, no initial value to return
|
1243
|
-
if (--i < 0) {
|
1244
|
-
throw new TypeError('reduceRight of empty array with no initial value');
|
1245
|
-
}
|
1246
|
-
} while (true);
|
1173
|
+
return year;
|
1174
|
+
},
|
1175
|
+
getUTCMonth: function getUTCMonth() {
|
1176
|
+
if (!this || !(this instanceof Date)) {
|
1177
|
+
throw new TypeError('this is not a Date object.');
|
1247
1178
|
}
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1179
|
+
var year = originalGetUTCFullYear(this);
|
1180
|
+
var month = originalGetUTCMonth(this);
|
1181
|
+
if (year < 0 && month > 11) {
|
1182
|
+
return 0;
|
1251
1183
|
}
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1184
|
+
return month;
|
1185
|
+
},
|
1186
|
+
getUTCDate: function getUTCDate() {
|
1187
|
+
if (!this || !(this instanceof Date)) {
|
1188
|
+
throw new TypeError('this is not a Date object.');
|
1189
|
+
}
|
1190
|
+
var year = originalGetUTCFullYear(this);
|
1191
|
+
var month = originalGetUTCMonth(this);
|
1192
|
+
var date = originalGetUTCDate(this);
|
1193
|
+
if (year < 0 && month > 11) {
|
1194
|
+
if (month === 12) {
|
1195
|
+
return date;
|
1256
1196
|
}
|
1257
|
-
|
1197
|
+
var days = daysInMonth(0, year + 1);
|
1198
|
+
return (days - date) + 1;
|
1199
|
+
}
|
1200
|
+
return date;
|
1201
|
+
}
|
1202
|
+
}, hasNegativeMonthYearBug);
|
1258
1203
|
|
1259
|
-
|
1204
|
+
defineProperties(Date.prototype, {
|
1205
|
+
toUTCString: function toUTCString() {
|
1206
|
+
if (!this || !(this instanceof Date)) {
|
1207
|
+
throw new TypeError('this is not a Date object.');
|
1208
|
+
}
|
1209
|
+
var day = originalGetUTCDay(this);
|
1210
|
+
var date = originalGetUTCDate(this);
|
1211
|
+
var month = originalGetUTCMonth(this);
|
1212
|
+
var year = originalGetUTCFullYear(this);
|
1213
|
+
var hour = originalGetUTCHours(this);
|
1214
|
+
var minute = originalGetUTCMinutes(this);
|
1215
|
+
var second = originalGetUTCSeconds(this);
|
1216
|
+
return dayName[day] + ', ' +
|
1217
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1218
|
+
monthName[month] + ' ' +
|
1219
|
+
year + ' ' +
|
1220
|
+
(hour < 10 ? '0' + hour : hour) + ':' +
|
1221
|
+
(minute < 10 ? '0' + minute : minute) + ':' +
|
1222
|
+
(second < 10 ? '0' + second : second) + ' GMT';
|
1260
1223
|
}
|
1261
|
-
},
|
1224
|
+
}, hasNegativeMonthYearBug || hasToUTCStringFormatBug);
|
1262
1225
|
|
1263
|
-
//
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
var
|
1270
|
-
var
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
if (arguments.length > 1) {
|
1278
|
-
i = ES.ToInteger(arguments[1]);
|
1279
|
-
}
|
1280
|
-
|
1281
|
-
// handle negative indices
|
1282
|
-
i = i >= 0 ? i : Math.max(0, length + i);
|
1283
|
-
for (; i < length; i++) {
|
1284
|
-
if (i in self && self[i] === searchElement) {
|
1285
|
-
return i;
|
1286
|
-
}
|
1287
|
-
}
|
1288
|
-
return -1;
|
1289
|
-
}
|
1290
|
-
}, hasFirefox2IndexOfBug);
|
1291
|
-
|
1292
|
-
// ES5 15.4.4.15
|
1293
|
-
// http://es5.github.com/#x15.4.4.15
|
1294
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
1295
|
-
var hasFirefox2LastIndexOfBug = Array.prototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
|
1296
|
-
defineProperties(ArrayPrototype, {
|
1297
|
-
lastIndexOf: function lastIndexOf(searchElement /*, fromIndex */) {
|
1298
|
-
var self = splitString && isString(this) ? this.split('') : ES.ToObject(this);
|
1299
|
-
var length = self.length >>> 0;
|
1300
|
-
|
1301
|
-
if (length === 0) {
|
1302
|
-
return -1;
|
1303
|
-
}
|
1304
|
-
var i = length - 1;
|
1305
|
-
if (arguments.length > 1) {
|
1306
|
-
i = Math.min(i, ES.ToInteger(arguments[1]));
|
1307
|
-
}
|
1308
|
-
// handle negative indices
|
1309
|
-
i = i >= 0 ? i : length - Math.abs(i);
|
1310
|
-
for (; i >= 0; i--) {
|
1311
|
-
if (i in self && searchElement === self[i]) {
|
1312
|
-
return i;
|
1313
|
-
}
|
1314
|
-
}
|
1315
|
-
return -1;
|
1316
|
-
}
|
1317
|
-
}, hasFirefox2LastIndexOfBug);
|
1318
|
-
|
1319
|
-
//
|
1320
|
-
// Object
|
1321
|
-
// ======
|
1322
|
-
//
|
1323
|
-
|
1324
|
-
// ES5 15.2.3.14
|
1325
|
-
// http://es5.github.com/#x15.2.3.14
|
1326
|
-
|
1327
|
-
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
|
1328
|
-
var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString'),
|
1329
|
-
hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype'),
|
1330
|
-
hasStringEnumBug = !owns('x', '0'),
|
1331
|
-
dontEnums = [
|
1332
|
-
'toString',
|
1333
|
-
'toLocaleString',
|
1334
|
-
'valueOf',
|
1335
|
-
'hasOwnProperty',
|
1336
|
-
'isPrototypeOf',
|
1337
|
-
'propertyIsEnumerable',
|
1338
|
-
'constructor'
|
1339
|
-
],
|
1340
|
-
dontEnumsLength = dontEnums.length;
|
1341
|
-
|
1342
|
-
defineProperties(Object, {
|
1343
|
-
keys: function keys(object) {
|
1344
|
-
var isFn = isCallable(object),
|
1345
|
-
isArgs = isArguments(object),
|
1346
|
-
isObject = object !== null && typeof object === 'object',
|
1347
|
-
isStr = isObject && isString(object);
|
1348
|
-
|
1349
|
-
if (!isObject && !isFn && !isArgs) {
|
1350
|
-
throw new TypeError('Object.keys called on a non-object');
|
1351
|
-
}
|
1352
|
-
|
1353
|
-
var theKeys = [];
|
1354
|
-
var skipProto = hasProtoEnumBug && isFn;
|
1355
|
-
if ((isStr && hasStringEnumBug) || isArgs) {
|
1356
|
-
for (var i = 0; i < object.length; ++i) {
|
1357
|
-
theKeys.push(String(i));
|
1358
|
-
}
|
1359
|
-
}
|
1360
|
-
|
1361
|
-
if (!isArgs) {
|
1362
|
-
for (var name in object) {
|
1363
|
-
if (!(skipProto && name === 'prototype') && owns(object, name)) {
|
1364
|
-
theKeys.push(String(name));
|
1365
|
-
}
|
1366
|
-
}
|
1367
|
-
}
|
1368
|
-
|
1369
|
-
if (hasDontEnumBug) {
|
1370
|
-
var ctor = object.constructor,
|
1371
|
-
skipConstructor = ctor && ctor.prototype === object;
|
1372
|
-
for (var j = 0; j < dontEnumsLength; j++) {
|
1373
|
-
var dontEnum = dontEnums[j];
|
1374
|
-
if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
|
1375
|
-
theKeys.push(dontEnum);
|
1376
|
-
}
|
1377
|
-
}
|
1378
|
-
}
|
1379
|
-
return theKeys;
|
1226
|
+
// Opera 12 has `,`
|
1227
|
+
defineProperties(Date.prototype, {
|
1228
|
+
toDateString: function toDateString() {
|
1229
|
+
if (!this || !(this instanceof Date)) {
|
1230
|
+
throw new TypeError('this is not a Date object.');
|
1231
|
+
}
|
1232
|
+
var day = this.getDay();
|
1233
|
+
var date = this.getDate();
|
1234
|
+
var month = this.getMonth();
|
1235
|
+
var year = this.getFullYear();
|
1236
|
+
return dayName[day] + ' ' +
|
1237
|
+
monthName[month] + ' ' +
|
1238
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1239
|
+
year;
|
1380
1240
|
}
|
1381
|
-
});
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1241
|
+
}, hasNegativeMonthYearBug || hasToDateStringFormatBug);
|
1242
|
+
|
1243
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
1244
|
+
if (hasNegativeMonthYearBug || hasToStringFormatBug) {
|
1245
|
+
Date.prototype.toString = function toString() {
|
1246
|
+
if (!this || !(this instanceof Date)) {
|
1247
|
+
throw new TypeError('this is not a Date object.');
|
1248
|
+
}
|
1249
|
+
var day = this.getDay();
|
1250
|
+
var date = this.getDate();
|
1251
|
+
var month = this.getMonth();
|
1252
|
+
var year = this.getFullYear();
|
1253
|
+
var hour = this.getHours();
|
1254
|
+
var minute = this.getMinutes();
|
1255
|
+
var second = this.getSeconds();
|
1256
|
+
var timezoneOffset = this.getTimezoneOffset();
|
1257
|
+
var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60);
|
1258
|
+
var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60);
|
1259
|
+
return dayName[day] + ' ' +
|
1260
|
+
monthName[month] + ' ' +
|
1261
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1262
|
+
year + ' ' +
|
1263
|
+
(hour < 10 ? '0' + hour : hour) + ':' +
|
1264
|
+
(minute < 10 ? '0' + minute : minute) + ':' +
|
1265
|
+
(second < 10 ? '0' + second : second) + ' GMT' +
|
1266
|
+
(timezoneOffset > 0 ? '-' : '+') +
|
1267
|
+
(hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) +
|
1268
|
+
(minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
|
1269
|
+
};
|
1270
|
+
if (supportsDescriptors) {
|
1271
|
+
$Object.defineProperty(Date.prototype, 'toString', {
|
1272
|
+
configurable: true,
|
1273
|
+
enumerable: false,
|
1274
|
+
writable: true
|
1275
|
+
});
|
1395
1276
|
}
|
1396
|
-
}
|
1397
|
-
|
1398
|
-
//
|
1399
|
-
// Date
|
1400
|
-
// ====
|
1401
|
-
//
|
1277
|
+
}
|
1402
1278
|
|
1403
1279
|
// ES5 15.9.5.43
|
1404
1280
|
// http://es5.github.com/#x15.9.5.43
|
@@ -1410,45 +1286,43 @@ defineProperties(Object, {
|
|
1410
1286
|
var negativeDate = -62198755200000;
|
1411
1287
|
var negativeYearString = '-000001';
|
1412
1288
|
var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
|
1289
|
+
var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z';
|
1290
|
+
|
1291
|
+
var getTime = call.bind(Date.prototype.getTime);
|
1413
1292
|
|
1414
1293
|
defineProperties(Date.prototype, {
|
1415
1294
|
toISOString: function toISOString() {
|
1416
|
-
|
1417
|
-
|
1295
|
+
if (!isFinite(this) || !isFinite(getTime(this))) {
|
1296
|
+
// Adope Photoshop requires the second check.
|
1418
1297
|
throw new RangeError('Date.prototype.toISOString called on non-finite value.');
|
1419
1298
|
}
|
1420
1299
|
|
1421
|
-
year = this
|
1300
|
+
var year = originalGetUTCFullYear(this);
|
1422
1301
|
|
1423
|
-
month = this
|
1302
|
+
var month = originalGetUTCMonth(this);
|
1424
1303
|
// see https://github.com/es-shims/es5-shim/issues/111
|
1425
1304
|
year += Math.floor(month / 12);
|
1426
1305
|
month = (month % 12 + 12) % 12;
|
1427
1306
|
|
1428
1307
|
// the date time string format is specified in 15.9.1.15.
|
1429
|
-
result = [month + 1, this
|
1308
|
+
var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)];
|
1430
1309
|
year = (
|
1431
1310
|
(year < 0 ? '-' : (year > 9999 ? '+' : '')) +
|
1432
|
-
('00000' + Math.abs(year)
|
1311
|
+
strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
|
1433
1312
|
);
|
1434
1313
|
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
// pad months, days, hours, minutes, and seconds to have two
|
1439
|
-
// digits.
|
1440
|
-
if (value < 10) {
|
1441
|
-
result[length] = '0' + value;
|
1442
|
-
}
|
1314
|
+
for (var i = 0; i < result.length; ++i) {
|
1315
|
+
// pad months, days, hours, minutes, and seconds to have two digits.
|
1316
|
+
result[i] = strSlice('00' + result[i], -2);
|
1443
1317
|
}
|
1444
1318
|
// pad milliseconds to have three digits.
|
1445
1319
|
return (
|
1446
|
-
year + '-' + result
|
1447
|
-
'T' + result
|
1448
|
-
('000' + this
|
1320
|
+
year + '-' + arraySlice(result, 0, 2).join('-') +
|
1321
|
+
'T' + arraySlice(result, 2).join(':') + '.' +
|
1322
|
+
strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
|
1449
1323
|
);
|
1450
1324
|
}
|
1451
|
-
}, hasNegativeDateBug);
|
1325
|
+
}, hasNegativeDateBug || hasSafari51DateBug);
|
1452
1326
|
|
1453
1327
|
// ES5 15.9.5.44
|
1454
1328
|
// http://es5.github.com/#x15.9.5.44
|
@@ -1474,7 +1348,7 @@ if (!dateToJSONIsSupported) {
|
|
1474
1348
|
// 1. Let O be the result of calling ToObject, giving it the this
|
1475
1349
|
// value as its argument.
|
1476
1350
|
// 2. Let tv be ES.ToPrimitive(O, hint Number).
|
1477
|
-
var O = Object(this);
|
1351
|
+
var O = $Object(this);
|
1478
1352
|
var tv = ES.ToPrimitive(O);
|
1479
1353
|
// 3. If tv is a Number and is not finite, return null.
|
1480
1354
|
if (typeof tv === 'number' && !isFinite(tv)) {
|
@@ -1509,36 +1383,51 @@ if (!dateToJSONIsSupported) {
|
|
1509
1383
|
var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
|
1510
1384
|
var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z'));
|
1511
1385
|
var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
|
1512
|
-
if (
|
1386
|
+
if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
|
1513
1387
|
// XXX global assignment won't work in embeddings that use
|
1514
1388
|
// an alternate object for the context.
|
1515
1389
|
/* global Date: true */
|
1516
1390
|
/* eslint-disable no-undef */
|
1391
|
+
var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
|
1392
|
+
var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
|
1393
|
+
/* eslint-disable no-implicit-globals */
|
1517
1394
|
Date = (function (NativeDate) {
|
1395
|
+
/* eslint-enable no-implicit-globals */
|
1518
1396
|
/* eslint-enable no-undef */
|
1519
1397
|
// Date.length === 7
|
1520
1398
|
var DateShim = function Date(Y, M, D, h, m, s, ms) {
|
1521
1399
|
var length = arguments.length;
|
1522
1400
|
var date;
|
1523
1401
|
if (this instanceof NativeDate) {
|
1524
|
-
|
1402
|
+
var seconds = s;
|
1403
|
+
var millis = ms;
|
1404
|
+
if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
|
1405
|
+
// work around a Safari 8/9 bug where it treats the seconds as signed
|
1406
|
+
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
|
1407
|
+
var sToShift = Math.floor(msToShift / 1e3);
|
1408
|
+
seconds += sToShift;
|
1409
|
+
millis -= sToShift * 1e3;
|
1410
|
+
}
|
1411
|
+
date = length === 1 && $String(Y) === Y ? // isString(Y)
|
1525
1412
|
// We explicitly pass it through parse:
|
1526
1413
|
new NativeDate(DateShim.parse(Y)) :
|
1527
1414
|
// We have to manually make calls depending on argument
|
1528
1415
|
// length here
|
1529
|
-
length >= 7 ? new NativeDate(Y, M, D, h, m,
|
1530
|
-
length >= 6 ? new NativeDate(Y, M, D, h, m,
|
1416
|
+
length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
|
1417
|
+
length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
|
1531
1418
|
length >= 5 ? new NativeDate(Y, M, D, h, m) :
|
1532
1419
|
length >= 4 ? new NativeDate(Y, M, D, h) :
|
1533
1420
|
length >= 3 ? new NativeDate(Y, M, D) :
|
1534
1421
|
length >= 2 ? new NativeDate(Y, M) :
|
1535
|
-
length >= 1 ? new NativeDate(Y) :
|
1422
|
+
length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) :
|
1536
1423
|
new NativeDate();
|
1537
1424
|
} else {
|
1538
1425
|
date = NativeDate.apply(this, arguments);
|
1539
1426
|
}
|
1540
|
-
|
1541
|
-
|
1427
|
+
if (!isPrimitive(date)) {
|
1428
|
+
// Prevent mixups with unfixed Date object
|
1429
|
+
defineProperties(date, { constructor: DateShim }, true);
|
1430
|
+
}
|
1542
1431
|
return date;
|
1543
1432
|
};
|
1544
1433
|
|
@@ -1579,7 +1468,16 @@ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExt
|
|
1579
1468
|
};
|
1580
1469
|
|
1581
1470
|
var toUTC = function toUTC(t) {
|
1582
|
-
|
1471
|
+
var s = 0;
|
1472
|
+
var ms = t;
|
1473
|
+
if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) {
|
1474
|
+
// work around a Safari 8/9 bug where it treats the seconds as signed
|
1475
|
+
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
|
1476
|
+
var sToShift = Math.floor(msToShift / 1e3);
|
1477
|
+
s += sToShift;
|
1478
|
+
ms -= sToShift * 1e3;
|
1479
|
+
}
|
1480
|
+
return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms));
|
1583
1481
|
};
|
1584
1482
|
|
1585
1483
|
// Copy any custom methods a 3rd party library may have added
|
@@ -1606,34 +1504,29 @@ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExt
|
|
1606
1504
|
// parse months, days, hours, minutes, seconds, and milliseconds
|
1607
1505
|
// provide default values if necessary
|
1608
1506
|
// parse the UTC offset component
|
1609
|
-
var year = Number(match[1]),
|
1610
|
-
month = Number(match[2] || 1) - 1,
|
1611
|
-
day = Number(match[3] || 1) - 1,
|
1612
|
-
hour = Number(match[4] || 0),
|
1613
|
-
minute = Number(match[5] || 0),
|
1614
|
-
second = Number(match[6] || 0),
|
1615
|
-
millisecond = Math.floor(Number(match[7] || 0) * 1000),
|
1507
|
+
var year = $Number(match[1]),
|
1508
|
+
month = $Number(match[2] || 1) - 1,
|
1509
|
+
day = $Number(match[3] || 1) - 1,
|
1510
|
+
hour = $Number(match[4] || 0),
|
1511
|
+
minute = $Number(match[5] || 0),
|
1512
|
+
second = $Number(match[6] || 0),
|
1513
|
+
millisecond = Math.floor($Number(match[7] || 0) * 1000),
|
1616
1514
|
// When time zone is missed, local offset should be used
|
1617
1515
|
// (ES 5.1 bug)
|
1618
1516
|
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
|
1619
1517
|
isLocalTime = Boolean(match[4] && !match[8]),
|
1620
1518
|
signOffset = match[9] === '-' ? 1 : -1,
|
1621
|
-
hourOffset = Number(match[10] || 0),
|
1622
|
-
minuteOffset = Number(match[11] || 0),
|
1519
|
+
hourOffset = $Number(match[10] || 0),
|
1520
|
+
minuteOffset = $Number(match[11] || 0),
|
1623
1521
|
result;
|
1522
|
+
var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0;
|
1624
1523
|
if (
|
1625
|
-
hour < (
|
1626
|
-
minute > 0 || second > 0 || millisecond > 0 ?
|
1627
|
-
24 : 25
|
1628
|
-
) &&
|
1524
|
+
hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) &&
|
1629
1525
|
minute < 60 && second < 60 && millisecond < 1000 &&
|
1630
1526
|
month > -1 && month < 12 && hourOffset < 24 &&
|
1631
1527
|
minuteOffset < 60 && // detect invalid offsets
|
1632
1528
|
day > -1 &&
|
1633
|
-
day < (
|
1634
|
-
dayFromMonth(year, month + 1) -
|
1635
|
-
dayFromMonth(year, month)
|
1636
|
-
)
|
1529
|
+
day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
|
1637
1530
|
) {
|
1638
1531
|
result = (
|
1639
1532
|
(dayFromMonth(year, month) + day) * 24 +
|
@@ -1698,7 +1591,8 @@ var toFixedHelpers = {
|
|
1698
1591
|
}
|
1699
1592
|
},
|
1700
1593
|
divide: function divide(n) {
|
1701
|
-
var i = toFixedHelpers.size
|
1594
|
+
var i = toFixedHelpers.size;
|
1595
|
+
var c = 0;
|
1702
1596
|
while (--i >= 0) {
|
1703
1597
|
c += toFixedHelpers.data[i];
|
1704
1598
|
toFixedHelpers.data[i] = Math.floor(c / n);
|
@@ -1710,11 +1604,11 @@ var toFixedHelpers = {
|
|
1710
1604
|
var s = '';
|
1711
1605
|
while (--i >= 0) {
|
1712
1606
|
if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
|
1713
|
-
var t = String(toFixedHelpers.data[i]);
|
1607
|
+
var t = $String(toFixedHelpers.data[i]);
|
1714
1608
|
if (s === '') {
|
1715
1609
|
s = t;
|
1716
1610
|
} else {
|
1717
|
-
s += '0000000'
|
1611
|
+
s += strSlice('0000000', 0, 7 - t.length) + t;
|
1718
1612
|
}
|
1719
1613
|
}
|
1720
1614
|
}
|
@@ -1738,92 +1632,104 @@ var toFixedHelpers = {
|
|
1738
1632
|
}
|
1739
1633
|
};
|
1740
1634
|
|
1741
|
-
|
1742
|
-
|
1743
|
-
var f, x, s, m, e, z, j, k;
|
1744
|
-
|
1745
|
-
// Test for NaN and round fractionDigits down
|
1746
|
-
f = Number(fractionDigits);
|
1747
|
-
f = f !== f ? 0 : Math.floor(f);
|
1748
|
-
|
1749
|
-
if (f < 0 || f > 20) {
|
1750
|
-
throw new RangeError('Number.toFixed called with invalid number of decimals');
|
1751
|
-
}
|
1752
|
-
|
1753
|
-
x = Number(this);
|
1635
|
+
var toFixedShim = function toFixed(fractionDigits) {
|
1636
|
+
var f, x, s, m, e, z, j, k;
|
1754
1637
|
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
}
|
1759
|
-
|
1760
|
-
// If it is too big or small, return the string value of the number
|
1761
|
-
if (x <= -1e21 || x >= 1e21) {
|
1762
|
-
return String(x);
|
1763
|
-
}
|
1638
|
+
// Test for NaN and round fractionDigits down
|
1639
|
+
f = $Number(fractionDigits);
|
1640
|
+
f = isActualNaN(f) ? 0 : Math.floor(f);
|
1764
1641
|
|
1765
|
-
|
1642
|
+
if (f < 0 || f > 20) {
|
1643
|
+
throw new RangeError('Number.toFixed called with invalid number of decimals');
|
1644
|
+
}
|
1766
1645
|
|
1767
|
-
|
1768
|
-
s = '-';
|
1769
|
-
x = -x;
|
1770
|
-
}
|
1646
|
+
x = $Number(this);
|
1771
1647
|
|
1772
|
-
|
1648
|
+
if (isActualNaN(x)) {
|
1649
|
+
return 'NaN';
|
1650
|
+
}
|
1773
1651
|
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
|
1779
|
-
z *= 0x10000000000000; // Math.pow(2, 52);
|
1780
|
-
e = 52 - e;
|
1652
|
+
// If it is too big or small, return the string value of the number
|
1653
|
+
if (x <= -1e21 || x >= 1e21) {
|
1654
|
+
return $String(x);
|
1655
|
+
}
|
1781
1656
|
|
1782
|
-
|
1783
|
-
// x = z / 2 ^ e
|
1784
|
-
if (e > 0) {
|
1785
|
-
toFixedHelpers.multiply(0, z);
|
1786
|
-
j = f;
|
1657
|
+
s = '';
|
1787
1658
|
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1659
|
+
if (x < 0) {
|
1660
|
+
s = '-';
|
1661
|
+
x = -x;
|
1662
|
+
}
|
1792
1663
|
|
1793
|
-
|
1794
|
-
|
1664
|
+
m = '0';
|
1665
|
+
|
1666
|
+
if (x > 1e-21) {
|
1667
|
+
// 1e-21 < x < 1e21
|
1668
|
+
// -70 < log2(x) < 70
|
1669
|
+
e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
|
1670
|
+
z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
|
1671
|
+
z *= 0x10000000000000; // Math.pow(2, 52);
|
1672
|
+
e = 52 - e;
|
1673
|
+
|
1674
|
+
// -18 < e < 122
|
1675
|
+
// x = z / 2 ^ e
|
1676
|
+
if (e > 0) {
|
1677
|
+
toFixedHelpers.multiply(0, z);
|
1678
|
+
j = f;
|
1679
|
+
|
1680
|
+
while (j >= 7) {
|
1681
|
+
toFixedHelpers.multiply(1e7, 0);
|
1682
|
+
j -= 7;
|
1683
|
+
}
|
1795
1684
|
|
1796
|
-
|
1797
|
-
|
1798
|
-
j -= 23;
|
1799
|
-
}
|
1685
|
+
toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
|
1686
|
+
j = e - 1;
|
1800
1687
|
|
1801
|
-
|
1802
|
-
toFixedHelpers.
|
1803
|
-
|
1804
|
-
m = toFixedHelpers.numToString();
|
1805
|
-
} else {
|
1806
|
-
toFixedHelpers.multiply(0, z);
|
1807
|
-
toFixedHelpers.multiply(1 << (-e), 0);
|
1808
|
-
m = toFixedHelpers.numToString() + '0.00000000000000000000'.slice(2, 2 + f);
|
1688
|
+
while (j >= 23) {
|
1689
|
+
toFixedHelpers.divide(1 << 23);
|
1690
|
+
j -= 23;
|
1809
1691
|
}
|
1692
|
+
|
1693
|
+
toFixedHelpers.divide(1 << j);
|
1694
|
+
toFixedHelpers.multiply(1, 1);
|
1695
|
+
toFixedHelpers.divide(2);
|
1696
|
+
m = toFixedHelpers.numToString();
|
1697
|
+
} else {
|
1698
|
+
toFixedHelpers.multiply(0, z);
|
1699
|
+
toFixedHelpers.multiply(1 << (-e), 0);
|
1700
|
+
m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f);
|
1810
1701
|
}
|
1702
|
+
}
|
1811
1703
|
|
1812
|
-
|
1813
|
-
|
1704
|
+
if (f > 0) {
|
1705
|
+
k = m.length;
|
1814
1706
|
|
1815
|
-
|
1816
|
-
|
1817
|
-
} else {
|
1818
|
-
m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
|
1819
|
-
}
|
1707
|
+
if (k <= f) {
|
1708
|
+
m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m;
|
1820
1709
|
} else {
|
1821
|
-
m = s + m;
|
1710
|
+
m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f);
|
1822
1711
|
}
|
1712
|
+
} else {
|
1713
|
+
m = s + m;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
return m;
|
1717
|
+
};
|
1718
|
+
defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs);
|
1823
1719
|
|
1824
|
-
|
1720
|
+
var hasToPrecisionUndefinedBug = (function () {
|
1721
|
+
try {
|
1722
|
+
return 1.0.toPrecision(undefined) === '1';
|
1723
|
+
} catch (e) {
|
1724
|
+
return true;
|
1825
1725
|
}
|
1826
|
-
}
|
1726
|
+
}());
|
1727
|
+
var originalToPrecision = NumberPrototype.toPrecision;
|
1728
|
+
defineProperties(NumberPrototype, {
|
1729
|
+
toPrecision: function toPrecision(precision) {
|
1730
|
+
return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision);
|
1731
|
+
}
|
1732
|
+
}, hasToPrecisionUndefinedBug);
|
1827
1733
|
|
1828
1734
|
//
|
1829
1735
|
// String
|
@@ -1845,7 +1751,6 @@ defineProperties(NumberPrototype, {
|
|
1845
1751
|
// ''.split(/.?/) should be [], not [""]
|
1846
1752
|
// '.'.split(/()()/) should be ["."], not ["", "", "."]
|
1847
1753
|
|
1848
|
-
var string_split = StringPrototype.split;
|
1849
1754
|
if (
|
1850
1755
|
'ab'.split(/(?:ab)*/).length !== 2 ||
|
1851
1756
|
'.'.split(/(.?)(.?)/).length !== 4 ||
|
@@ -1856,48 +1761,46 @@ if (
|
|
1856
1761
|
) {
|
1857
1762
|
(function () {
|
1858
1763
|
var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
|
1764
|
+
var maxSafe32BitInt = Math.pow(2, 32) - 1;
|
1859
1765
|
|
1860
1766
|
StringPrototype.split = function (separator, limit) {
|
1861
|
-
var string = this;
|
1767
|
+
var string = String(this);
|
1862
1768
|
if (typeof separator === 'undefined' && limit === 0) {
|
1863
1769
|
return [];
|
1864
1770
|
}
|
1865
1771
|
|
1866
1772
|
// If `separator` is not a regex, use native split
|
1867
1773
|
if (!isRegex(separator)) {
|
1868
|
-
return
|
1774
|
+
return strSplit(this, separator, limit);
|
1869
1775
|
}
|
1870
1776
|
|
1871
1777
|
var output = [];
|
1872
1778
|
var flags = (separator.ignoreCase ? 'i' : '') +
|
1873
1779
|
(separator.multiline ? 'm' : '') +
|
1874
|
-
(separator.
|
1875
|
-
(separator.sticky ? 'y' : ''), // Firefox 3+
|
1780
|
+
(separator.unicode ? 'u' : '') + // in ES6
|
1781
|
+
(separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
|
1876
1782
|
lastLastIndex = 0,
|
1877
1783
|
// Make `global` and avoid `lastIndex` issues by working with a copy
|
1878
1784
|
separator2, match, lastIndex, lastLength;
|
1879
1785
|
var separatorCopy = new RegExp(separator.source, flags + 'g');
|
1880
|
-
string += ''; // Type-convert
|
1881
1786
|
if (!compliantExecNpcg) {
|
1882
1787
|
// Doesn't need flags gy, but they don't hurt
|
1883
1788
|
separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
|
1884
1789
|
}
|
1885
1790
|
/* Values for `limit`, per the spec:
|
1886
|
-
* If undefined: 4294967295 //
|
1791
|
+
* If undefined: 4294967295 // maxSafe32BitInt
|
1887
1792
|
* If 0, Infinity, or NaN: 0
|
1888
1793
|
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
|
1889
1794
|
* If negative number: 4294967296 - Math.floor(Math.abs(limit))
|
1890
1795
|
* If other: Type-convert, then use the above rules
|
1891
1796
|
*/
|
1892
|
-
var splitLimit = typeof limit === 'undefined' ?
|
1893
|
-
-1 >>> 0 : // Math.pow(2, 32) - 1
|
1894
|
-
ES.ToUint32(limit);
|
1797
|
+
var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit);
|
1895
1798
|
match = separatorCopy.exec(string);
|
1896
1799
|
while (match) {
|
1897
1800
|
// `separatorCopy.lastIndex` is not reliable cross-browser
|
1898
1801
|
lastIndex = match.index + match[0].length;
|
1899
1802
|
if (lastIndex > lastLastIndex) {
|
1900
|
-
output
|
1803
|
+
pushCall(output, strSlice(string, lastLastIndex, match.index));
|
1901
1804
|
// Fix browsers whose `exec` methods don't consistently return `undefined` for
|
1902
1805
|
// nonparticipating capturing groups
|
1903
1806
|
if (!compliantExecNpcg && match.length > 1) {
|
@@ -1912,7 +1815,7 @@ if (
|
|
1912
1815
|
/* eslint-enable no-loop-func */
|
1913
1816
|
}
|
1914
1817
|
if (match.length > 1 && match.index < string.length) {
|
1915
|
-
array_push.apply(output, match
|
1818
|
+
array_push.apply(output, arraySlice(match, 1));
|
1916
1819
|
}
|
1917
1820
|
lastLength = match[0].length;
|
1918
1821
|
lastLastIndex = lastIndex;
|
@@ -1927,12 +1830,12 @@ if (
|
|
1927
1830
|
}
|
1928
1831
|
if (lastLastIndex === string.length) {
|
1929
1832
|
if (lastLength || !separatorCopy.test('')) {
|
1930
|
-
output
|
1833
|
+
pushCall(output, '');
|
1931
1834
|
}
|
1932
1835
|
} else {
|
1933
|
-
output
|
1836
|
+
pushCall(output, strSlice(string, lastLastIndex));
|
1934
1837
|
}
|
1935
|
-
return output.length > splitLimit ? output
|
1838
|
+
return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output;
|
1936
1839
|
};
|
1937
1840
|
}());
|
1938
1841
|
|
@@ -1945,7 +1848,7 @@ if (
|
|
1945
1848
|
} else if ('0'.split(void 0, 0).length) {
|
1946
1849
|
StringPrototype.split = function split(separator, limit) {
|
1947
1850
|
if (typeof separator === 'undefined' && limit === 0) { return []; }
|
1948
|
-
return
|
1851
|
+
return strSplit(this, separator, limit);
|
1949
1852
|
};
|
1950
1853
|
}
|
1951
1854
|
|
@@ -1953,7 +1856,7 @@ var str_replace = StringPrototype.replace;
|
|
1953
1856
|
var replaceReportsGroupsCorrectly = (function () {
|
1954
1857
|
var groups = [];
|
1955
1858
|
'x'.replace(/x(.)?/g, function (match, group) {
|
1956
|
-
groups
|
1859
|
+
pushCall(groups, group);
|
1957
1860
|
});
|
1958
1861
|
return groups.length === 1 && typeof groups[0] === 'undefined';
|
1959
1862
|
}());
|
@@ -1971,7 +1874,7 @@ if (!replaceReportsGroupsCorrectly) {
|
|
1971
1874
|
searchValue.lastIndex = 0;
|
1972
1875
|
var args = searchValue.exec(match) || [];
|
1973
1876
|
searchValue.lastIndex = originalLastIndex;
|
1974
|
-
args
|
1877
|
+
pushCall(args, arguments[length - 2], arguments[length - 1]);
|
1975
1878
|
return replaceValue.apply(this, args);
|
1976
1879
|
};
|
1977
1880
|
return str_replace.call(this, searchValue, wrappedReplaceValue);
|
@@ -1990,7 +1893,7 @@ defineProperties(StringPrototype, {
|
|
1990
1893
|
substr: function substr(start, length) {
|
1991
1894
|
var normalizedStart = start;
|
1992
1895
|
if (start < 0) {
|
1993
|
-
normalizedStart =
|
1896
|
+
normalizedStart = max(this.length + start, 0);
|
1994
1897
|
}
|
1995
1898
|
return string_substr.call(this, normalizedStart, length);
|
1996
1899
|
}
|
@@ -2013,25 +1916,709 @@ defineProperties(StringPrototype, {
|
|
2013
1916
|
if (typeof this === 'undefined' || this === null) {
|
2014
1917
|
throw new TypeError("can't convert " + this + ' to object');
|
2015
1918
|
}
|
2016
|
-
return String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
|
1919
|
+
return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
|
2017
1920
|
}
|
2018
1921
|
}, hasTrimWhitespaceBug);
|
1922
|
+
var trim = call.bind(String.prototype.trim);
|
1923
|
+
|
1924
|
+
var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1;
|
1925
|
+
defineProperties(StringPrototype, {
|
1926
|
+
lastIndexOf: function lastIndexOf(searchString) {
|
1927
|
+
if (typeof this === 'undefined' || this === null) {
|
1928
|
+
throw new TypeError("can't convert " + this + ' to object');
|
1929
|
+
}
|
1930
|
+
var S = $String(this);
|
1931
|
+
var searchStr = $String(searchString);
|
1932
|
+
var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN;
|
1933
|
+
var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos);
|
1934
|
+
var start = min(max(pos, 0), S.length);
|
1935
|
+
var searchLen = searchStr.length;
|
1936
|
+
var k = start + searchLen;
|
1937
|
+
while (k > 0) {
|
1938
|
+
k = max(0, k - searchLen);
|
1939
|
+
var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr);
|
1940
|
+
if (index !== -1) {
|
1941
|
+
return k + index;
|
1942
|
+
}
|
1943
|
+
}
|
1944
|
+
return -1;
|
1945
|
+
}
|
1946
|
+
}, hasLastIndexBug);
|
1947
|
+
|
1948
|
+
var originalLastIndexOf = StringPrototype.lastIndexOf;
|
1949
|
+
defineProperties(StringPrototype, {
|
1950
|
+
lastIndexOf: function lastIndexOf(searchString) {
|
1951
|
+
return originalLastIndexOf.apply(this, arguments);
|
1952
|
+
}
|
1953
|
+
}, StringPrototype.lastIndexOf.length !== 1);
|
2019
1954
|
|
2020
1955
|
// ES-5 15.1.2.2
|
1956
|
+
/* eslint-disable radix */
|
2021
1957
|
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
|
1958
|
+
/* eslint-enable radix */
|
2022
1959
|
/* global parseInt: true */
|
2023
1960
|
parseInt = (function (origParseInt) {
|
2024
|
-
var hexRegex = /^0[xX]/;
|
1961
|
+
var hexRegex = /^[\-+]?0[xX]/;
|
2025
1962
|
return function parseInt(str, radix) {
|
2026
|
-
var string =
|
2027
|
-
var defaultedRadix = Number(radix) || (hexRegex.test(string) ? 16 : 10);
|
1963
|
+
var string = trim(str);
|
1964
|
+
var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10);
|
2028
1965
|
return origParseInt(string, defaultedRadix);
|
2029
1966
|
};
|
2030
1967
|
}(parseInt));
|
2031
1968
|
}
|
2032
1969
|
|
1970
|
+
// https://es5.github.io/#x15.1.2.3
|
1971
|
+
if (1 / parseFloat('-0') !== -Infinity) {
|
1972
|
+
/* global parseFloat: true */
|
1973
|
+
parseFloat = (function (origParseFloat) {
|
1974
|
+
return function parseFloat(string) {
|
1975
|
+
var inputString = trim(string);
|
1976
|
+
var result = origParseFloat(inputString);
|
1977
|
+
return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result;
|
1978
|
+
};
|
1979
|
+
}(parseFloat));
|
1980
|
+
}
|
1981
|
+
|
1982
|
+
if (String(new RangeError('test')) !== 'RangeError: test') {
|
1983
|
+
var errorToStringShim = function toString() {
|
1984
|
+
if (typeof this === 'undefined' || this === null) {
|
1985
|
+
throw new TypeError("can't convert " + this + ' to object');
|
1986
|
+
}
|
1987
|
+
var name = this.name;
|
1988
|
+
if (typeof name === 'undefined') {
|
1989
|
+
name = 'Error';
|
1990
|
+
} else if (typeof name !== 'string') {
|
1991
|
+
name = $String(name);
|
1992
|
+
}
|
1993
|
+
var msg = this.message;
|
1994
|
+
if (typeof msg === 'undefined') {
|
1995
|
+
msg = '';
|
1996
|
+
} else if (typeof msg !== 'string') {
|
1997
|
+
msg = $String(msg);
|
1998
|
+
}
|
1999
|
+
if (!name) {
|
2000
|
+
return msg;
|
2001
|
+
}
|
2002
|
+
if (!msg) {
|
2003
|
+
return name;
|
2004
|
+
}
|
2005
|
+
return name + ': ' + msg;
|
2006
|
+
};
|
2007
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
2008
|
+
Error.prototype.toString = errorToStringShim;
|
2009
|
+
}
|
2010
|
+
|
2011
|
+
if (supportsDescriptors) {
|
2012
|
+
var ensureNonEnumerable = function (obj, prop) {
|
2013
|
+
if (isEnum(obj, prop)) {
|
2014
|
+
var desc = Object.getOwnPropertyDescriptor(obj, prop);
|
2015
|
+
desc.enumerable = false;
|
2016
|
+
Object.defineProperty(obj, prop, desc);
|
2017
|
+
}
|
2018
|
+
};
|
2019
|
+
ensureNonEnumerable(Error.prototype, 'message');
|
2020
|
+
if (Error.prototype.message !== '') {
|
2021
|
+
Error.prototype.message = '';
|
2022
|
+
}
|
2023
|
+
ensureNonEnumerable(Error.prototype, 'name');
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
if (String(/a/mig) !== '/a/gim') {
|
2027
|
+
var regexToString = function toString() {
|
2028
|
+
var str = '/' + this.source + '/';
|
2029
|
+
if (this.global) {
|
2030
|
+
str += 'g';
|
2031
|
+
}
|
2032
|
+
if (this.ignoreCase) {
|
2033
|
+
str += 'i';
|
2034
|
+
}
|
2035
|
+
if (this.multiline) {
|
2036
|
+
str += 'm';
|
2037
|
+
}
|
2038
|
+
return str;
|
2039
|
+
};
|
2040
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
2041
|
+
RegExp.prototype.toString = regexToString;
|
2042
|
+
}
|
2043
|
+
|
2033
2044
|
}));
|
2034
2045
|
|
2046
|
+
/*!
|
2047
|
+
* https://github.com/es-shims/es5-shim
|
2048
|
+
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
|
2049
|
+
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
|
2050
|
+
*/
|
2051
|
+
|
2052
|
+
// vim: ts=4 sts=4 sw=4 expandtab
|
2053
|
+
|
2054
|
+
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
|
2055
|
+
;
|
2056
|
+
|
2057
|
+
// UMD (Universal Module Definition)
|
2058
|
+
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
2059
|
+
(function (root, factory) {
|
2060
|
+
'use strict';
|
2061
|
+
|
2062
|
+
/* global define, exports, module */
|
2063
|
+
if (typeof define === 'function' && define.amd) {
|
2064
|
+
// AMD. Register as an anonymous module.
|
2065
|
+
define(factory);
|
2066
|
+
} else if (typeof exports === 'object') {
|
2067
|
+
// Node. Does not work with strict CommonJS, but
|
2068
|
+
// only CommonJS-like enviroments that support module.exports,
|
2069
|
+
// like Node.
|
2070
|
+
module.exports = factory();
|
2071
|
+
} else {
|
2072
|
+
// Browser globals (root is window)
|
2073
|
+
root.returnExports = factory();
|
2074
|
+
}
|
2075
|
+
}(this, function () {
|
2076
|
+
|
2077
|
+
var call = Function.call;
|
2078
|
+
var prototypeOfObject = Object.prototype;
|
2079
|
+
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
2080
|
+
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
|
2081
|
+
var toStr = call.bind(prototypeOfObject.toString);
|
2082
|
+
|
2083
|
+
// If JS engine supports accessors creating shortcuts.
|
2084
|
+
var defineGetter;
|
2085
|
+
var defineSetter;
|
2086
|
+
var lookupGetter;
|
2087
|
+
var lookupSetter;
|
2088
|
+
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
|
2089
|
+
if (supportsAccessors) {
|
2090
|
+
/* eslint-disable no-underscore-dangle */
|
2091
|
+
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
|
2092
|
+
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
|
2093
|
+
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
|
2094
|
+
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
|
2095
|
+
/* eslint-enable no-underscore-dangle */
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
// ES5 15.2.3.2
|
2099
|
+
// http://es5.github.com/#x15.2.3.2
|
2100
|
+
if (!Object.getPrototypeOf) {
|
2101
|
+
// https://github.com/es-shims/es5-shim/issues#issue/2
|
2102
|
+
// http://ejohn.org/blog/objectgetprototypeof/
|
2103
|
+
// recommended by fschaefer on github
|
2104
|
+
//
|
2105
|
+
// sure, and webreflection says ^_^
|
2106
|
+
// ... this will nerever possibly return null
|
2107
|
+
// ... Opera Mini breaks here with infinite loops
|
2108
|
+
Object.getPrototypeOf = function getPrototypeOf(object) {
|
2109
|
+
/* eslint-disable no-proto */
|
2110
|
+
var proto = object.__proto__;
|
2111
|
+
/* eslint-enable no-proto */
|
2112
|
+
if (proto || proto === null) {
|
2113
|
+
return proto;
|
2114
|
+
} else if (toStr(object.constructor) === '[object Function]') {
|
2115
|
+
return object.constructor.prototype;
|
2116
|
+
} else if (object instanceof Object) {
|
2117
|
+
return prototypeOfObject;
|
2118
|
+
} else {
|
2119
|
+
// Correctly return null for Objects created with `Object.create(null)`
|
2120
|
+
// (shammed or native) or `{ __proto__: null}`. Also returns null for
|
2121
|
+
// cross-realm objects on browsers that lack `__proto__` support (like
|
2122
|
+
// IE <11), but that's the best we can do.
|
2123
|
+
return null;
|
2124
|
+
}
|
2125
|
+
};
|
2126
|
+
}
|
2127
|
+
|
2128
|
+
// ES5 15.2.3.3
|
2129
|
+
// http://es5.github.com/#x15.2.3.3
|
2130
|
+
|
2131
|
+
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
|
2132
|
+
try {
|
2133
|
+
object.sentinel = 0;
|
2134
|
+
return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
|
2135
|
+
} catch (exception) {
|
2136
|
+
return false;
|
2137
|
+
}
|
2138
|
+
};
|
2139
|
+
|
2140
|
+
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
|
2141
|
+
if (Object.defineProperty) {
|
2142
|
+
var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
|
2143
|
+
var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
|
2144
|
+
doesGetOwnPropertyDescriptorWork(document.createElement('div'));
|
2145
|
+
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
|
2146
|
+
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
|
2147
|
+
}
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
|
2151
|
+
var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
|
2152
|
+
|
2153
|
+
/* eslint-disable no-proto */
|
2154
|
+
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
|
2155
|
+
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
|
2156
|
+
throw new TypeError(ERR_NON_OBJECT + object);
|
2157
|
+
}
|
2158
|
+
|
2159
|
+
// make a valiant attempt to use the real getOwnPropertyDescriptor
|
2160
|
+
// for I8's DOM elements.
|
2161
|
+
if (getOwnPropertyDescriptorFallback) {
|
2162
|
+
try {
|
2163
|
+
return getOwnPropertyDescriptorFallback.call(Object, object, property);
|
2164
|
+
} catch (exception) {
|
2165
|
+
// try the shim if the real one doesn't work
|
2166
|
+
}
|
2167
|
+
}
|
2168
|
+
|
2169
|
+
var descriptor;
|
2170
|
+
|
2171
|
+
// If object does not owns property return undefined immediately.
|
2172
|
+
if (!owns(object, property)) {
|
2173
|
+
return descriptor;
|
2174
|
+
}
|
2175
|
+
|
2176
|
+
// If object has a property then it's for sure `configurable`, and
|
2177
|
+
// probably `enumerable`. Detect enumerability though.
|
2178
|
+
descriptor = {
|
2179
|
+
enumerable: isEnumerable(object, property),
|
2180
|
+
configurable: true
|
2181
|
+
};
|
2182
|
+
|
2183
|
+
// If JS engine supports accessor properties then property may be a
|
2184
|
+
// getter or setter.
|
2185
|
+
if (supportsAccessors) {
|
2186
|
+
// Unfortunately `__lookupGetter__` will return a getter even
|
2187
|
+
// if object has own non getter property along with a same named
|
2188
|
+
// inherited getter. To avoid misbehavior we temporary remove
|
2189
|
+
// `__proto__` so that `__lookupGetter__` will return getter only
|
2190
|
+
// if it's owned by an object.
|
2191
|
+
var prototype = object.__proto__;
|
2192
|
+
var notPrototypeOfObject = object !== prototypeOfObject;
|
2193
|
+
// avoid recursion problem, breaking in Opera Mini when
|
2194
|
+
// Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
|
2195
|
+
// or any other Object.prototype accessor
|
2196
|
+
if (notPrototypeOfObject) {
|
2197
|
+
object.__proto__ = prototypeOfObject;
|
2198
|
+
}
|
2199
|
+
|
2200
|
+
var getter = lookupGetter(object, property);
|
2201
|
+
var setter = lookupSetter(object, property);
|
2202
|
+
|
2203
|
+
if (notPrototypeOfObject) {
|
2204
|
+
// Once we have getter and setter we can put values back.
|
2205
|
+
object.__proto__ = prototype;
|
2206
|
+
}
|
2207
|
+
|
2208
|
+
if (getter || setter) {
|
2209
|
+
if (getter) {
|
2210
|
+
descriptor.get = getter;
|
2211
|
+
}
|
2212
|
+
if (setter) {
|
2213
|
+
descriptor.set = setter;
|
2214
|
+
}
|
2215
|
+
// If it was accessor property we're done and return here
|
2216
|
+
// in order to avoid adding `value` to the descriptor.
|
2217
|
+
return descriptor;
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
|
2221
|
+
// If we got this far we know that object has an own property that is
|
2222
|
+
// not an accessor so we set it as a value and return descriptor.
|
2223
|
+
descriptor.value = object[property];
|
2224
|
+
descriptor.writable = true;
|
2225
|
+
return descriptor;
|
2226
|
+
};
|
2227
|
+
/* eslint-enable no-proto */
|
2228
|
+
}
|
2229
|
+
|
2230
|
+
// ES5 15.2.3.4
|
2231
|
+
// http://es5.github.com/#x15.2.3.4
|
2232
|
+
if (!Object.getOwnPropertyNames) {
|
2233
|
+
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
|
2234
|
+
return Object.keys(object);
|
2235
|
+
};
|
2236
|
+
}
|
2237
|
+
|
2238
|
+
// ES5 15.2.3.5
|
2239
|
+
// http://es5.github.com/#x15.2.3.5
|
2240
|
+
if (!Object.create) {
|
2241
|
+
|
2242
|
+
// Contributed by Brandon Benvie, October, 2012
|
2243
|
+
var createEmpty;
|
2244
|
+
var supportsProto = !({ __proto__: null } instanceof Object);
|
2245
|
+
// the following produces false positives
|
2246
|
+
// in Opera Mini => not a reliable check
|
2247
|
+
// Object.prototype.__proto__ === null
|
2248
|
+
|
2249
|
+
// Check for document.domain and active x support
|
2250
|
+
// No need to use active x approach when document.domain is not set
|
2251
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2252
|
+
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
2253
|
+
/* global ActiveXObject */
|
2254
|
+
var shouldUseActiveX = function shouldUseActiveX() {
|
2255
|
+
// return early if document.domain not set
|
2256
|
+
if (!document.domain) {
|
2257
|
+
return false;
|
2258
|
+
}
|
2259
|
+
|
2260
|
+
try {
|
2261
|
+
return !!new ActiveXObject('htmlfile');
|
2262
|
+
} catch (exception) {
|
2263
|
+
return false;
|
2264
|
+
}
|
2265
|
+
};
|
2266
|
+
|
2267
|
+
// This supports IE8 when document.domain is used
|
2268
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2269
|
+
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
2270
|
+
var getEmptyViaActiveX = function getEmptyViaActiveX() {
|
2271
|
+
var empty;
|
2272
|
+
var xDoc;
|
2273
|
+
|
2274
|
+
xDoc = new ActiveXObject('htmlfile');
|
2275
|
+
|
2276
|
+
xDoc.write('<script><\/script>');
|
2277
|
+
xDoc.close();
|
2278
|
+
|
2279
|
+
empty = xDoc.parentWindow.Object.prototype;
|
2280
|
+
xDoc = null;
|
2281
|
+
|
2282
|
+
return empty;
|
2283
|
+
};
|
2284
|
+
|
2285
|
+
// The original implementation using an iframe
|
2286
|
+
// before the activex approach was added
|
2287
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2288
|
+
var getEmptyViaIFrame = function getEmptyViaIFrame() {
|
2289
|
+
var iframe = document.createElement('iframe');
|
2290
|
+
var parent = document.body || document.documentElement;
|
2291
|
+
var empty;
|
2292
|
+
|
2293
|
+
iframe.style.display = 'none';
|
2294
|
+
parent.appendChild(iframe);
|
2295
|
+
/* eslint-disable no-script-url */
|
2296
|
+
iframe.src = 'javascript:';
|
2297
|
+
/* eslint-enable no-script-url */
|
2298
|
+
|
2299
|
+
empty = iframe.contentWindow.Object.prototype;
|
2300
|
+
parent.removeChild(iframe);
|
2301
|
+
iframe = null;
|
2302
|
+
|
2303
|
+
return empty;
|
2304
|
+
};
|
2305
|
+
|
2306
|
+
/* global document */
|
2307
|
+
if (supportsProto || typeof document === 'undefined') {
|
2308
|
+
createEmpty = function () {
|
2309
|
+
return { __proto__: null };
|
2310
|
+
};
|
2311
|
+
} else {
|
2312
|
+
// In old IE __proto__ can't be used to manually set `null`, nor does
|
2313
|
+
// any other method exist to make an object that inherits from nothing,
|
2314
|
+
// aside from Object.prototype itself. Instead, create a new global
|
2315
|
+
// object and *steal* its Object.prototype and strip it bare. This is
|
2316
|
+
// used as the prototype to create nullary objects.
|
2317
|
+
createEmpty = function () {
|
2318
|
+
// Determine which approach to use
|
2319
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2320
|
+
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
|
2321
|
+
|
2322
|
+
delete empty.constructor;
|
2323
|
+
delete empty.hasOwnProperty;
|
2324
|
+
delete empty.propertyIsEnumerable;
|
2325
|
+
delete empty.isPrototypeOf;
|
2326
|
+
delete empty.toLocaleString;
|
2327
|
+
delete empty.toString;
|
2328
|
+
delete empty.valueOf;
|
2329
|
+
|
2330
|
+
var Empty = function Empty() {};
|
2331
|
+
Empty.prototype = empty;
|
2332
|
+
// short-circuit future calls
|
2333
|
+
createEmpty = function () {
|
2334
|
+
return new Empty();
|
2335
|
+
};
|
2336
|
+
return new Empty();
|
2337
|
+
};
|
2338
|
+
}
|
2339
|
+
|
2340
|
+
Object.create = function create(prototype, properties) {
|
2341
|
+
|
2342
|
+
var object;
|
2343
|
+
var Type = function Type() {}; // An empty constructor.
|
2344
|
+
|
2345
|
+
if (prototype === null) {
|
2346
|
+
object = createEmpty();
|
2347
|
+
} else {
|
2348
|
+
if (typeof prototype !== 'object' && typeof prototype !== 'function') {
|
2349
|
+
// In the native implementation `parent` can be `null`
|
2350
|
+
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
|
2351
|
+
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
|
2352
|
+
// like they are in modern browsers. Using `Object.create` on DOM elements
|
2353
|
+
// is...err...probably inappropriate, but the native version allows for it.
|
2354
|
+
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
|
2355
|
+
}
|
2356
|
+
Type.prototype = prototype;
|
2357
|
+
object = new Type();
|
2358
|
+
// IE has no built-in implementation of `Object.getPrototypeOf`
|
2359
|
+
// neither `__proto__`, but this manually setting `__proto__` will
|
2360
|
+
// guarantee that `Object.getPrototypeOf` will work as expected with
|
2361
|
+
// objects created using `Object.create`
|
2362
|
+
/* eslint-disable no-proto */
|
2363
|
+
object.__proto__ = prototype;
|
2364
|
+
/* eslint-enable no-proto */
|
2365
|
+
}
|
2366
|
+
|
2367
|
+
if (properties !== void 0) {
|
2368
|
+
Object.defineProperties(object, properties);
|
2369
|
+
}
|
2370
|
+
|
2371
|
+
return object;
|
2372
|
+
};
|
2373
|
+
}
|
2374
|
+
|
2375
|
+
// ES5 15.2.3.6
|
2376
|
+
// http://es5.github.com/#x15.2.3.6
|
2377
|
+
|
2378
|
+
// Patch for WebKit and IE8 standard mode
|
2379
|
+
// Designed by hax <hax.github.com>
|
2380
|
+
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
|
2381
|
+
// IE8 Reference:
|
2382
|
+
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
|
2383
|
+
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
|
2384
|
+
// WebKit Bugs:
|
2385
|
+
// https://bugs.webkit.org/show_bug.cgi?id=36423
|
2386
|
+
|
2387
|
+
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
|
2388
|
+
try {
|
2389
|
+
Object.defineProperty(object, 'sentinel', {});
|
2390
|
+
return 'sentinel' in object;
|
2391
|
+
} catch (exception) {
|
2392
|
+
return false;
|
2393
|
+
}
|
2394
|
+
};
|
2395
|
+
|
2396
|
+
// check whether defineProperty works if it's given. Otherwise,
|
2397
|
+
// shim partially.
|
2398
|
+
if (Object.defineProperty) {
|
2399
|
+
var definePropertyWorksOnObject = doesDefinePropertyWork({});
|
2400
|
+
var definePropertyWorksOnDom = typeof document === 'undefined' ||
|
2401
|
+
doesDefinePropertyWork(document.createElement('div'));
|
2402
|
+
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
|
2403
|
+
var definePropertyFallback = Object.defineProperty,
|
2404
|
+
definePropertiesFallback = Object.defineProperties;
|
2405
|
+
}
|
2406
|
+
}
|
2407
|
+
|
2408
|
+
if (!Object.defineProperty || definePropertyFallback) {
|
2409
|
+
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
|
2410
|
+
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
|
2411
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
|
2412
|
+
|
2413
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
2414
|
+
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
|
2415
|
+
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
|
2416
|
+
}
|
2417
|
+
if ((typeof descriptor !== 'object' && typeof descriptor !== 'function') || descriptor === null) {
|
2418
|
+
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
|
2419
|
+
}
|
2420
|
+
// make a valiant attempt to use the real defineProperty
|
2421
|
+
// for I8's DOM elements.
|
2422
|
+
if (definePropertyFallback) {
|
2423
|
+
try {
|
2424
|
+
return definePropertyFallback.call(Object, object, property, descriptor);
|
2425
|
+
} catch (exception) {
|
2426
|
+
// try the shim if the real one doesn't work
|
2427
|
+
}
|
2428
|
+
}
|
2429
|
+
|
2430
|
+
// If it's a data property.
|
2431
|
+
if ('value' in descriptor) {
|
2432
|
+
// fail silently if 'writable', 'enumerable', or 'configurable'
|
2433
|
+
// are requested but not supported
|
2434
|
+
/*
|
2435
|
+
// alternate approach:
|
2436
|
+
if ( // can't implement these features; allow false but not true
|
2437
|
+
('writable' in descriptor && !descriptor.writable) ||
|
2438
|
+
('enumerable' in descriptor && !descriptor.enumerable) ||
|
2439
|
+
('configurable' in descriptor && !descriptor.configurable)
|
2440
|
+
))
|
2441
|
+
throw new RangeError(
|
2442
|
+
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
|
2443
|
+
);
|
2444
|
+
*/
|
2445
|
+
|
2446
|
+
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
|
2447
|
+
// As accessors are supported only on engines implementing
|
2448
|
+
// `__proto__` we can safely override `__proto__` while defining
|
2449
|
+
// a property to make sure that we don't hit an inherited
|
2450
|
+
// accessor.
|
2451
|
+
/* eslint-disable no-proto */
|
2452
|
+
var prototype = object.__proto__;
|
2453
|
+
object.__proto__ = prototypeOfObject;
|
2454
|
+
// Deleting a property anyway since getter / setter may be
|
2455
|
+
// defined on object itself.
|
2456
|
+
delete object[property];
|
2457
|
+
object[property] = descriptor.value;
|
2458
|
+
// Setting original `__proto__` back now.
|
2459
|
+
object.__proto__ = prototype;
|
2460
|
+
/* eslint-enable no-proto */
|
2461
|
+
} else {
|
2462
|
+
object[property] = descriptor.value;
|
2463
|
+
}
|
2464
|
+
} else {
|
2465
|
+
if (!supportsAccessors && (('get' in descriptor) || ('set' in descriptor))) {
|
2466
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
2467
|
+
}
|
2468
|
+
// If we got that far then getters and setters can be defined !!
|
2469
|
+
if ('get' in descriptor) {
|
2470
|
+
defineGetter(object, property, descriptor.get);
|
2471
|
+
}
|
2472
|
+
if ('set' in descriptor) {
|
2473
|
+
defineSetter(object, property, descriptor.set);
|
2474
|
+
}
|
2475
|
+
}
|
2476
|
+
return object;
|
2477
|
+
};
|
2478
|
+
}
|
2479
|
+
|
2480
|
+
// ES5 15.2.3.7
|
2481
|
+
// http://es5.github.com/#x15.2.3.7
|
2482
|
+
if (!Object.defineProperties || definePropertiesFallback) {
|
2483
|
+
Object.defineProperties = function defineProperties(object, properties) {
|
2484
|
+
// make a valiant attempt to use the real defineProperties
|
2485
|
+
if (definePropertiesFallback) {
|
2486
|
+
try {
|
2487
|
+
return definePropertiesFallback.call(Object, object, properties);
|
2488
|
+
} catch (exception) {
|
2489
|
+
// try the shim if the real one doesn't work
|
2490
|
+
}
|
2491
|
+
}
|
2492
|
+
|
2493
|
+
Object.keys(properties).forEach(function (property) {
|
2494
|
+
if (property !== '__proto__') {
|
2495
|
+
Object.defineProperty(object, property, properties[property]);
|
2496
|
+
}
|
2497
|
+
});
|
2498
|
+
return object;
|
2499
|
+
};
|
2500
|
+
}
|
2501
|
+
|
2502
|
+
// ES5 15.2.3.8
|
2503
|
+
// http://es5.github.com/#x15.2.3.8
|
2504
|
+
if (!Object.seal) {
|
2505
|
+
Object.seal = function seal(object) {
|
2506
|
+
if (Object(object) !== object) {
|
2507
|
+
throw new TypeError('Object.seal can only be called on Objects.');
|
2508
|
+
}
|
2509
|
+
// this is misleading and breaks feature-detection, but
|
2510
|
+
// allows "securable" code to "gracefully" degrade to working
|
2511
|
+
// but insecure code.
|
2512
|
+
return object;
|
2513
|
+
};
|
2514
|
+
}
|
2515
|
+
|
2516
|
+
// ES5 15.2.3.9
|
2517
|
+
// http://es5.github.com/#x15.2.3.9
|
2518
|
+
if (!Object.freeze) {
|
2519
|
+
Object.freeze = function freeze(object) {
|
2520
|
+
if (Object(object) !== object) {
|
2521
|
+
throw new TypeError('Object.freeze can only be called on Objects.');
|
2522
|
+
}
|
2523
|
+
// this is misleading and breaks feature-detection, but
|
2524
|
+
// allows "securable" code to "gracefully" degrade to working
|
2525
|
+
// but insecure code.
|
2526
|
+
return object;
|
2527
|
+
};
|
2528
|
+
}
|
2529
|
+
|
2530
|
+
// detect a Rhino bug and patch it
|
2531
|
+
try {
|
2532
|
+
Object.freeze(function () {});
|
2533
|
+
} catch (exception) {
|
2534
|
+
Object.freeze = (function (freezeObject) {
|
2535
|
+
return function freeze(object) {
|
2536
|
+
if (typeof object === 'function') {
|
2537
|
+
return object;
|
2538
|
+
} else {
|
2539
|
+
return freezeObject(object);
|
2540
|
+
}
|
2541
|
+
};
|
2542
|
+
}(Object.freeze));
|
2543
|
+
}
|
2544
|
+
|
2545
|
+
// ES5 15.2.3.10
|
2546
|
+
// http://es5.github.com/#x15.2.3.10
|
2547
|
+
if (!Object.preventExtensions) {
|
2548
|
+
Object.preventExtensions = function preventExtensions(object) {
|
2549
|
+
if (Object(object) !== object) {
|
2550
|
+
throw new TypeError('Object.preventExtensions can only be called on Objects.');
|
2551
|
+
}
|
2552
|
+
// this is misleading and breaks feature-detection, but
|
2553
|
+
// allows "securable" code to "gracefully" degrade to working
|
2554
|
+
// but insecure code.
|
2555
|
+
return object;
|
2556
|
+
};
|
2557
|
+
}
|
2558
|
+
|
2559
|
+
// ES5 15.2.3.11
|
2560
|
+
// http://es5.github.com/#x15.2.3.11
|
2561
|
+
if (!Object.isSealed) {
|
2562
|
+
Object.isSealed = function isSealed(object) {
|
2563
|
+
if (Object(object) !== object) {
|
2564
|
+
throw new TypeError('Object.isSealed can only be called on Objects.');
|
2565
|
+
}
|
2566
|
+
return false;
|
2567
|
+
};
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
// ES5 15.2.3.12
|
2571
|
+
// http://es5.github.com/#x15.2.3.12
|
2572
|
+
if (!Object.isFrozen) {
|
2573
|
+
Object.isFrozen = function isFrozen(object) {
|
2574
|
+
if (Object(object) !== object) {
|
2575
|
+
throw new TypeError('Object.isFrozen can only be called on Objects.');
|
2576
|
+
}
|
2577
|
+
return false;
|
2578
|
+
};
|
2579
|
+
}
|
2580
|
+
|
2581
|
+
// ES5 15.2.3.13
|
2582
|
+
// http://es5.github.com/#x15.2.3.13
|
2583
|
+
if (!Object.isExtensible) {
|
2584
|
+
Object.isExtensible = function isExtensible(object) {
|
2585
|
+
// 1. If Type(O) is not Object throw a TypeError exception.
|
2586
|
+
if (Object(object) !== object) {
|
2587
|
+
throw new TypeError('Object.isExtensible can only be called on Objects.');
|
2588
|
+
}
|
2589
|
+
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
|
2590
|
+
var name = '';
|
2591
|
+
while (owns(object, name)) {
|
2592
|
+
name += '?';
|
2593
|
+
}
|
2594
|
+
object[name] = true;
|
2595
|
+
var returnValue = owns(object, name);
|
2596
|
+
delete object[name];
|
2597
|
+
return returnValue;
|
2598
|
+
};
|
2599
|
+
}
|
2600
|
+
|
2601
|
+
}));
|
2602
|
+
|
2603
|
+
// Console-polyfill. MIT license.
|
2604
|
+
// https://github.com/paulmillr/console-polyfill
|
2605
|
+
// Make it safe to do console.log() always.
|
2606
|
+
(function(global) {
|
2607
|
+
'use strict';
|
2608
|
+
global.console = global.console || {};
|
2609
|
+
var con = global.console;
|
2610
|
+
var prop, method;
|
2611
|
+
var empty = {};
|
2612
|
+
var dummy = function() {};
|
2613
|
+
var properties = 'memory'.split(',');
|
2614
|
+
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
|
2615
|
+
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
|
2616
|
+
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
|
2617
|
+
while (prop = properties.pop()) if (!con[prop]) con[prop] = empty;
|
2618
|
+
while (method = methods.pop()) if (typeof con[method] !== 'function') con[method] = dummy;
|
2619
|
+
// Using `this` for web workers & supports Browserify / Webpack.
|
2620
|
+
})(typeof window === 'undefined' ? this : window);
|
2621
|
+
|
2035
2622
|
!window.addEventListener && (function (WindowPrototype, DocumentPrototype, ElementPrototype, addEventListener, removeEventListener, dispatchEvent, registry) {
|
2036
2623
|
WindowPrototype[addEventListener] = DocumentPrototype[addEventListener] = ElementPrototype[addEventListener] = function (type, listener) {
|
2037
2624
|
var target = this;
|