Make React website work in IE8
Fixes #406. Empty conditional comment is for http://www.phpied.com/conditional-comments-block-downloads/.
Ben Alpert committed
Dec 30, 2013 at 15:12 UTC
92b440b1d7adee824727a74e3f951e8b0762c738
3 files changed
+1811
docs/_js/es5-sham.js
new
+446
@@ -0,0 +1,446 @@
1
+// Copyright 2009-2012 by contributors, MIT License
2
+// vim: ts=4 sts=4 sw=4 expandtab
3
+
4
+//Add semicolon to prevent IIFE from being passed as argument to concated code.
5
+;
6
+// Module systems magic dance
7
+(function (definition) {
8
+ // RequireJS
9
+ if (typeof define == "function") {
10
+ define(definition);
11
+ // YUI3
12
+ } else if (typeof YUI == "function") {
13
+ YUI.add("es5-sham", definition);
14
+ // CommonJS and <script>
15
+ } else {
16
+ definition();
17
+ }
18
+})(function () {
19
+
20
+
21
+var call = Function.prototype.call;
22
+var prototypeOfObject = Object.prototype;
23
+var owns = call.bind(prototypeOfObject.hasOwnProperty);
24
+
25
+// If JS engine supports accessors creating shortcuts.
26
+var defineGetter;
27
+var defineSetter;
28
+var lookupGetter;
29
+var lookupSetter;
30
+var supportsAccessors;
31
+if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
32
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
33
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
34
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
35
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
36
+}
37
+
38
+// ES5 15.2.3.2
39
+// http://es5.github.com/#x15.2.3.2
40
+if (!Object.getPrototypeOf) {
41
+ // https://github.com/es-shims/es5-shim/issues#issue/2
42
+ // http://ejohn.org/blog/objectgetprototypeof/
43
+ // recommended by fschaefer on github
44
+ Object.getPrototypeOf = function getPrototypeOf(object) {
45
+ return object.__proto__ || (
46
+ object.constructor
47
+ ? object.constructor.prototype
48
+ : prototypeOfObject
49
+ );
50
+ };
51
+}
52
+
53
+//ES5 15.2.3.3
54
+//http://es5.github.com/#x15.2.3.3
55
+
56
+function doesGetOwnPropertyDescriptorWork(object) {
57
+ try {
58
+ object.sentinel = 0;
59
+ return Object.getOwnPropertyDescriptor(
60
+ object,
61
+ "sentinel"
62
+ ).value === 0;
63
+ } catch (exception) {
64
+ // returns falsy
65
+ }
66
+}
67
+
68
+//check whether getOwnPropertyDescriptor works if it's given. Otherwise,
69
+//shim partially.
70
+if (Object.defineProperty) {
71
+ var getOwnPropertyDescriptorWorksOnObject =
72
+ doesGetOwnPropertyDescriptorWork({});
73
+ var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
74
+ doesGetOwnPropertyDescriptorWork(document.createElement("div"));
75
+ if (!getOwnPropertyDescriptorWorksOnDom ||
76
+ !getOwnPropertyDescriptorWorksOnObject
77
+ ) {
78
+ var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
79
+ }
80
+}
81
+
82
+if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
83
+ var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
84
+
85
+ Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
86
+ if ((typeof object != "object" && typeof object != "function") || object === null) {
87
+ throw new TypeError(ERR_NON_OBJECT + object);
88
+ }
89
+
90
+ // make a valiant attempt to use the real getOwnPropertyDescriptor
91
+ // for I8's DOM elements.
92
+ if (getOwnPropertyDescriptorFallback) {
93
+ try {
94
+ return getOwnPropertyDescriptorFallback.call(Object, object, property);
95
+ } catch (exception) {
96
+ // try the shim if the real one doesn't work
97
+ }
98
+ }
99
+
100
+ // If object does not owns property return undefined immediately.
101
+ if (!owns(object, property)) {
102
+ return;
103
+ }
104
+
105
+ // If object has a property then it's for sure both `enumerable` and
106
+ // `configurable`.
107
+ var descriptor = { enumerable: true, configurable: true };
108
+
109
+ // If JS engine supports accessor properties then property may be a
110
+ // getter or setter.
111
+ if (supportsAccessors) {
112
+ // Unfortunately `__lookupGetter__` will return a getter even
113
+ // if object has own non getter property along with a same named
114
+ // inherited getter. To avoid misbehavior we temporary remove
115
+ // `__proto__` so that `__lookupGetter__` will return getter only
116
+ // if it's owned by an object.
117
+ var prototype = object.__proto__;
118
+ object.__proto__ = prototypeOfObject;
119
+
120
+ var getter = lookupGetter(object, property);
121
+ var setter = lookupSetter(object, property);
122
+
123
+ // Once we have getter and setter we can put values back.
124
+ object.__proto__ = prototype;
125
+
126
+ if (getter || setter) {
127
+ if (getter) {
128
+ descriptor.get = getter;
129
+ }
130
+ if (setter) {
131
+ descriptor.set = setter;
132
+ }
133
+ // If it was accessor property we're done and return here
134
+ // in order to avoid adding `value` to the descriptor.
135
+ return descriptor;
136
+ }
137
+ }
138
+
139
+ // If we got this far we know that object has an own property that is
140
+ // not an accessor so we set it as a value and return descriptor.
141
+ descriptor.value = object[property];
142
+ descriptor.writable = true;
143
+ return descriptor;
144
+ };
145
+}
146
+
147
+// ES5 15.2.3.4
148
+// http://es5.github.com/#x15.2.3.4
149
+if (!Object.getOwnPropertyNames) {
150
+ Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
151
+ return Object.keys(object);
152
+ };
153
+}
154
+
155
+// ES5 15.2.3.5
156
+// http://es5.github.com/#x15.2.3.5
157
+if (!Object.create) {
158
+
159
+ // Contributed by Brandon Benvie, October, 2012
160
+ var createEmpty;
161
+ var supportsProto = Object.prototype.__proto__ === null;
162
+ if (supportsProto || typeof document == 'undefined') {
163
+ createEmpty = function () {
164
+ return { "__proto__": null };
165
+ };
166
+ } else {
167
+ // In old IE __proto__ can't be used to manually set `null`, nor does
168
+ // any other method exist to make an object that inherits from nothing,
169
+ // aside from Object.prototype itself. Instead, create a new global
170
+ // object and *steal* its Object.prototype and strip it bare. This is
171
+ // used as the prototype to create nullary objects.
172
+ createEmpty = function () {
173
+ var iframe = document.createElement('iframe');
174
+ var parent = document.body || document.documentElement;
175
+ iframe.style.display = 'none';
176
+ parent.appendChild(iframe);
177
+ iframe.src = 'javascript:';
178
+ var empty = iframe.contentWindow.Object.prototype;
179
+ parent.removeChild(iframe);
180
+ iframe = null;
181
+ delete empty.constructor;
182
+ delete empty.hasOwnProperty;
183
+ delete empty.propertyIsEnumerable;
184
+ delete empty.isPrototypeOf;
185
+ delete empty.toLocaleString;
186
+ delete empty.toString;
187
+ delete empty.valueOf;
188
+ empty.__proto__ = null;
189
+
190
+ function Empty() {}
191
+ Empty.prototype = empty;
192
+ // short-circuit future calls
193
+ createEmpty = function () {
194
+ return new Empty();
195
+ };
196
+ return new Empty();
197
+ };
198
+ }
199
+
200
+ Object.create = function create(prototype, properties) {
201
+
202
+ var object;
203
+ function Type() {} // An empty constructor.
204
+
205
+ if (prototype === null) {
206
+ object = createEmpty();
207
+ } else {
208
+ if (typeof prototype !== "object" && typeof prototype !== "function") {
209
+ // In the native implementation `parent` can be `null`
210
+ // OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
211
+ // Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
212
+ // like they are in modern browsers. Using `Object.create` on DOM elements
213
+ // is...err...probably inappropriate, but the native version allows for it.
214
+ throw new TypeError("Object prototype may only be an Object or null"); // same msg as Chrome
215
+ }
216
+ Type.prototype = prototype;
217
+ object = new Type();
218
+ // IE has no built-in implementation of `Object.getPrototypeOf`
219
+ // neither `__proto__`, but this manually setting `__proto__` will
220
+ // guarantee that `Object.getPrototypeOf` will work as expected with
221
+ // objects created using `Object.create`
222
+ object.__proto__ = prototype;
223
+ }
224
+
225
+ if (properties !== void 0) {
226
+ Object.defineProperties(object, properties);
227
+ }
228
+
229
+ return object;
230
+ };
231
+}
232
+
233
+// ES5 15.2.3.6
234
+// http://es5.github.com/#x15.2.3.6
235
+
236
+// Patch for WebKit and IE8 standard mode
237
+// Designed by hax <hax.github.com>
238
+// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
239
+// IE8 Reference:
240
+// http://msdn.microsoft.com/en-us/library/dd282900.aspx
241
+// http://msdn.microsoft.com/en-us/library/dd229916.aspx
242
+// WebKit Bugs:
243
+// https://bugs.webkit.org/show_bug.cgi?id=36423
244
+
245
+function doesDefinePropertyWork(object) {
246
+ try {
247
+ Object.defineProperty(object, "sentinel", {});
248
+ return "sentinel" in object;
249
+ } catch (exception) {
250
+ // returns falsy
251
+ }
252
+}
253
+
254
+// check whether defineProperty works if it's given. Otherwise,
255
+// shim partially.
256
+if (Object.defineProperty) {
257
+ var definePropertyWorksOnObject = doesDefinePropertyWork({});
258
+ var definePropertyWorksOnDom = typeof document == "undefined" ||
259
+ doesDefinePropertyWork(document.createElement("div"));
260
+ if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
261
+ var definePropertyFallback = Object.defineProperty,
262
+ definePropertiesFallback = Object.defineProperties;
263
+ }
264
+}
265
+
266
+if (!Object.defineProperty || definePropertyFallback) {
267
+ var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
268
+ var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
269
+ var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
270
+ "on this javascript engine";
271
+
272
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
273
+ if ((typeof object != "object" && typeof object != "function") || object === null) {
274
+ throw new TypeError(ERR_NON_OBJECT_TARGET + object);
275
+ }
276
+ if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) {
277
+ throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
278
+ }
279
+ // make a valiant attempt to use the real defineProperty
280
+ // for I8's DOM elements.
281
+ if (definePropertyFallback) {
282
+ try {
283
+ return definePropertyFallback.call(Object, object, property, descriptor);
284
+ } catch (exception) {
285
+ // try the shim if the real one doesn't work
286
+ }
287
+ }
288
+
289
+ // If it's a data property.
290
+ if (owns(descriptor, "value")) {
291
+ // fail silently if "writable", "enumerable", or "configurable"
292
+ // are requested but not supported
293
+ /*
294
+ // alternate approach:
295
+ if ( // can't implement these features; allow false but not true
296
+ !(owns(descriptor, "writable") ? descriptor.writable : true) ||
297
+ !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
298
+ !(owns(descriptor, "configurable") ? descriptor.configurable : true)
299
+ )
300
+ throw new RangeError(
301
+ "This implementation of Object.defineProperty does not " +
302
+ "support configurable, enumerable, or writable."
303
+ );
304
+ */
305
+
306
+ if (supportsAccessors && (lookupGetter(object, property) ||
307
+ lookupSetter(object, property)))
308
+ {
309
+ // As accessors are supported only on engines implementing
310
+ // `__proto__` we can safely override `__proto__` while defining
311
+ // a property to make sure that we don't hit an inherited
312
+ // accessor.
313
+ var prototype = object.__proto__;
314
+ object.__proto__ = prototypeOfObject;
315
+ // Deleting a property anyway since getter / setter may be
316
+ // defined on object itself.
317
+ delete object[property];
318
+ object[property] = descriptor.value;
319
+ // Setting original `__proto__` back now.
320
+ object.__proto__ = prototype;
321
+ } else {
322
+ object[property] = descriptor.value;
323
+ }
324
+ } else {
325
+ if (!supportsAccessors) {
326
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
327
+ }
328
+ // If we got that far then getters and setters can be defined !!
329
+ if (owns(descriptor, "get")) {
330
+ defineGetter(object, property, descriptor.get);
331
+ }
332
+ if (owns(descriptor, "set")) {
333
+ defineSetter(object, property, descriptor.set);
334
+ }
335
+ }
336
+ return object;
337
+ };
338
+}
339
+
340
+// ES5 15.2.3.7
341
+// http://es5.github.com/#x15.2.3.7
342
+if (!Object.defineProperties || definePropertiesFallback) {
343
+ Object.defineProperties = function defineProperties(object, properties) {
344
+ // make a valiant attempt to use the real defineProperties
345
+ if (definePropertiesFallback) {
346
+ try {
347
+ return definePropertiesFallback.call(Object, object, properties);
348
+ } catch (exception) {
349
+ // try the shim if the real one doesn't work
350
+ }
351
+ }
352
+
353
+ for (var property in properties) {
354
+ if (owns(properties, property) && property != "__proto__") {
355
+ Object.defineProperty(object, property, properties[property]);
356
+ }
357
+ }
358
+ return object;
359
+ };
360
+}
361
+
362
+// ES5 15.2.3.8
363
+// http://es5.github.com/#x15.2.3.8
364
+if (!Object.seal) {
365
+ Object.seal = function seal(object) {
366
+ // this is misleading and breaks feature-detection, but
367
+ // allows "securable" code to "gracefully" degrade to working
368
+ // but insecure code.
369
+ return object;
370
+ };
371
+}
372
+
373
+// ES5 15.2.3.9
374
+// http://es5.github.com/#x15.2.3.9
375
+if (!Object.freeze) {
376
+ Object.freeze = function freeze(object) {
377
+ // this is misleading and breaks feature-detection, but
378
+ // allows "securable" code to "gracefully" degrade to working
379
+ // but insecure code.
380
+ return object;
381
+ };
382
+}
383
+
384
+// detect a Rhino bug and patch it
385
+try {
386
+ Object.freeze(function () {});
387
+} catch (exception) {
388
+ Object.freeze = (function freeze(freezeObject) {
389
+ return function freeze(object) {
390
+ if (typeof object == "function") {
391
+ return object;
392
+ } else {
393
+ return freezeObject(object);
394
+ }
395
+ };
396
+ })(Object.freeze);
397
+}
398
+
399
+// ES5 15.2.3.10
400
+// http://es5.github.com/#x15.2.3.10
401
+if (!Object.preventExtensions) {
402
+ Object.preventExtensions = function preventExtensions(object) {
403
+ // this is misleading and breaks feature-detection, but
404
+ // allows "securable" code to "gracefully" degrade to working
405
+ // but insecure code.
406
+ return object;
407
+ };
408
+}
409
+
410
+// ES5 15.2.3.11
411
+// http://es5.github.com/#x15.2.3.11
412
+if (!Object.isSealed) {
413
+ Object.isSealed = function isSealed(object) {
414
+ return false;
415
+ };
416
+}
417
+
418
+// ES5 15.2.3.12
419
+// http://es5.github.com/#x15.2.3.12
420
+if (!Object.isFrozen) {
421
+ Object.isFrozen = function isFrozen(object) {
422
+ return false;
423
+ };
424
+}
425
+
426
+// ES5 15.2.3.13
427
+// http://es5.github.com/#x15.2.3.13
428
+if (!Object.isExtensible) {
429
+ Object.isExtensible = function isExtensible(object) {
430
+ // 1. If Type(O) is not Object throw a TypeError exception.
431
+ if (Object(object) !== object) {
432
+ throw new TypeError(); // TODO message
433
+ }
434
+ // 2. Return the Boolean value of the [[Extensible]] internal property of O.
435
+ var name = '';
436
+ while (owns(object, name)) {
437
+ name += '?';
438
+ }
439
+ object[name] = true;
440
+ var returnValue = owns(object, name);
441
+ delete object[name];
442
+ return returnValue;
443
+ };
444
+}
445
+
446
+});
docs/_js/es5-shim.js
new
+1360
@@ -0,0 +1,1360 @@
1
+// Copyright 2009-2012 by contributors, MIT License
2
+// vim: ts=4 sts=4 sw=4 expandtab
3
+
4
+//Add semicolon to prevent IIFE from being passed as argument to concated code.
5
+;
6
+// Module systems magic dance
7
+(function (definition) {
8
+ // RequireJS
9
+ if (typeof define == "function") {
10
+ define(definition);
11
+ // YUI3
12
+ } else if (typeof YUI == "function") {
13
+ YUI.add("es5", definition);
14
+ // CommonJS and <script>
15
+ } else {
16
+ definition();
17
+ }
18
+})(function () {
19
+
20
+/**
21
+ * Brings an environment as close to ECMAScript 5 compliance
22
+ * as is possible with the facilities of erstwhile engines.
23
+ *
24
+ * Annotated ES5: http://es5.github.com/ (specific links below)
25
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
26
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
27
+ */
28
+
29
+// ES-5 15.1.2.2
30
+if (parseInt('08') !== 8) {
31
+ parseInt = (function (origParseInt) {
32
+ var hexRegex = /^0[xX]/;
33
+ return function parseIntES5(str, radix) {
34
+ str = String(str).trim();
35
+ if (!+radix) {
36
+ radix = hexRegex.test(str) ? 16 : 10;
37
+ }
38
+ return origParseInt(str, radix);
39
+ };
40
+ }(parseInt));
41
+}
42
+
43
+//
44
+// Function
45
+// ========
46
+//
47
+
48
+// ES-5 15.3.4.5
49
+// http://es5.github.com/#x15.3.4.5
50
+
51
+function Empty() {}
52
+
53
+if (!Function.prototype.bind) {
54
+ Function.prototype.bind = function bind(that) { // .length is 1
55
+ // 1. Let Target be the this value.
56
+ var target = this;
57
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
58
+ if (typeof target != "function") {
59
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
60
+ }
61
+ // 3. Let A be a new (possibly empty) internal list of all of the
62
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
63
+ // XXX slicedArgs will stand in for "A" if used
64
+ var args = _Array_slice_.call(arguments, 1); // for normal call
65
+ // 4. Let F be a new native ECMAScript object.
66
+ // 11. Set the [[Prototype]] internal property of F to the standard
67
+ // built-in Function prototype object as specified in 15.3.3.1.
68
+ // 12. Set the [[Call]] internal property of F as described in
69
+ // 15.3.4.5.1.
70
+ // 13. Set the [[Construct]] internal property of F as described in
71
+ // 15.3.4.5.2.
72
+ // 14. Set the [[HasInstance]] internal property of F as described in
73
+ // 15.3.4.5.3.
74
+ var binder = function () {
75
+
76
+ if (this instanceof bound) {
77
+ // 15.3.4.5.2 [[Construct]]
78
+ // When the [[Construct]] internal method of a function object,
79
+ // F that was created using the bind function is called with a
80
+ // list of arguments ExtraArgs, the following steps are taken:
81
+ // 1. Let target be the value of F's [[TargetFunction]]
82
+ // internal property.
83
+ // 2. If target has no [[Construct]] internal method, a
84
+ // TypeError exception is thrown.
85
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
86
+ // property.
87
+ // 4. Let args be a new list containing the same values as the
88
+ // list boundArgs in the same order followed by the same
89
+ // values as the list ExtraArgs in the same order.
90
+ // 5. Return the result of calling the [[Construct]] internal
91
+ // method of target providing args as the arguments.
92
+
93
+ var result = target.apply(
94
+ this,
95
+ args.concat(_Array_slice_.call(arguments))
96
+ );
97
+ if (Object(result) === result) {
98
+ return result;
99
+ }
100
+ return this;
101
+
102
+ } else {
103
+ // 15.3.4.5.1 [[Call]]
104
+ // When the [[Call]] internal method of a function object, F,
105
+ // which was created using the bind function is called with a
106
+ // this value and a list of arguments ExtraArgs, the following
107
+ // steps are taken:
108
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
109
+ // property.
110
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
111
+ // property.
112
+ // 3. Let target be the value of F's [[TargetFunction]] internal
113
+ // property.
114
+ // 4. Let args be a new list containing the same values as the
115
+ // list boundArgs in the same order followed by the same
116
+ // values as the list ExtraArgs in the same order.
117
+ // 5. Return the result of calling the [[Call]] internal method
118
+ // of target providing boundThis as the this value and
119
+ // providing args as the arguments.
120
+
121
+ // equiv: target.call(this, ...boundArgs, ...args)
122
+ return target.apply(
123
+ that,
124
+ args.concat(_Array_slice_.call(arguments))
125
+ );
126
+
127
+ }
128
+
129
+ };
130
+
131
+ // 15. If the [[Class]] internal property of Target is "Function", then
132
+ // a. Let L be the length property of Target minus the length of A.
133
+ // b. Set the length own property of F to either 0 or L, whichever is
134
+ // larger.
135
+ // 16. Else set the length own property of F to 0.
136
+
137
+ var boundLength = Math.max(0, target.length - args.length);
138
+
139
+ // 17. Set the attributes of the length own property of F to the values
140
+ // specified in 15.3.5.1.
141
+ var boundArgs = [];
142
+ for (var i = 0; i < boundLength; i++) {
143
+ boundArgs.push("$" + i);
144
+ }
145
+
146
+ // XXX Build a dynamic function with desired amount of arguments is the only
147
+ // way to set the length property of a function.
148
+ // In environments where Content Security Policies enabled (Chrome extensions,
149
+ // for ex.) all use of eval or Function costructor throws an exception.
150
+ // However in all of these environments Function.prototype.bind exists
151
+ // and so this code will never be executed.
152
+ var bound = Function("binder", "return function(" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
153
+
154
+ if (target.prototype) {
155
+ Empty.prototype = target.prototype;
156
+ bound.prototype = new Empty();
157
+ // Clean up dangling references.
158
+ Empty.prototype = null;
159
+ }
160
+
161
+ // TODO
162
+ // 18. Set the [[Extensible]] internal property of F to true.
163
+
164
+ // TODO
165
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
166
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
167
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
168
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
169
+ // false.
170
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
171
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
172
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
173
+ // and false.
174
+
175
+ // TODO
176
+ // NOTE Function objects created using Function.prototype.bind do not
177
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
178
+ // [[Scope]] internal properties.
179
+ // XXX can't delete prototype in pure-js.
180
+
181
+ // 22. Return F.
182
+ return bound;
183
+ };
184
+}
185
+
186
+// Shortcut to an often accessed properties, in order to avoid multiple
187
+// dereference that costs universally.
188
+// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
189
+// us it in defining shortcuts.
190
+var call = Function.prototype.call;
191
+var prototypeOfArray = Array.prototype;
192
+var prototypeOfObject = Object.prototype;
193
+var _Array_slice_ = prototypeOfArray.slice;
194
+// Having a toString local variable name breaks in Opera so use _toString.
195
+var _toString = call.bind(prototypeOfObject.toString);
196
+var owns = call.bind(prototypeOfObject.hasOwnProperty);
197
+
198
+// If JS engine supports accessors creating shortcuts.
199
+var defineGetter;
200
+var defineSetter;
201
+var lookupGetter;
202
+var lookupSetter;
203
+var supportsAccessors;
204
+if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
205
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
206
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
207
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
208
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
209
+}
210
+
211
+//
212
+// Array
213
+// =====
214
+//
215
+
216
+// ES5 15.4.4.12
217
+// http://es5.github.com/#x15.4.4.12
218
+// Default value for second param
219
+// [bugfix, ielt9, old browsers]
220
+// IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
221
+if ([1,2].splice(0).length != 2) {
222
+ var array_splice = Array.prototype.splice;
223
+ var array_push = Array.prototype.push;
224
+ var array_unshift = Array.prototype.unshift;
225
+
226
+ if (function() { // test IE < 9 to splice bug - see issue #138
227
+ function makeArray(l) {
228
+ var a = [];
229
+ while (l--) {
230
+ a.unshift(l)
231
+ }
232
+ return a
233
+ }
234
+
235
+ var array = []
236
+ , lengthBefore
237
+ ;
238
+
239
+ array.splice.bind(array, 0, 0).apply(null, makeArray(20));
240
+ array.splice.bind(array, 0, 0).apply(null, makeArray(26));
241
+
242
+ lengthBefore = array.length; //20
243
+ array.splice(5, 0, "XXX"); // add one element
244
+
245
+ if (lengthBefore + 1 == array.length) {
246
+ return true;// has right splice implementation without bugs
247
+ }
248
+ // else {
249
+ // IE8 bug
250
+ // }
251
+ }()) {//IE 6/7
252
+ Array.prototype.splice = function(start, deleteCount) {
253
+ if (!arguments.length) {
254
+ return [];
255
+ } else {
256
+ return array_splice.apply(this, [
257
+ start === void 0 ? 0 : start,
258
+ deleteCount === void 0 ? (this.length - start) : deleteCount
259
+ ].concat(_Array_slice_.call(arguments, 2)))
260
+ }
261
+ };
262
+ }
263
+ else {//IE8
264
+ Array.prototype.splice = function(start, deleteCount) {
265
+ var result
266
+ , args = _Array_slice_.call(arguments, 2)
267
+ , addElementsCount = args.length
268
+ ;
269
+
270
+ if (!arguments.length) {
271
+ return [];
272
+ }
273
+
274
+ if (start === void 0) { // default
275
+ start = 0;
276
+ }
277
+ if (deleteCount === void 0) { // default
278
+ deleteCount = this.length - start;
279
+ }
280
+
281
+ if (addElementsCount > 0) {
282
+ if (deleteCount <= 0) {
283
+ if (start == this.length) { // tiny optimisation #1
284
+ array_push.apply(this, args);
285
+ return [];
286
+ }
287
+
288
+ if (start == 0) { // tiny optimisation #2
289
+ array_unshift.apply(this, args);
290
+ return [];
291
+ }
292
+ }
293
+
294
+ // Array.prototype.splice implementation
295
+ result = _Array_slice_.call(this, start, start + deleteCount);// delete part
296
+ args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
297
+ args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
298
+
299
+ // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
300
+ args.unshift(0, this.length);
301
+
302
+ array_splice.apply(this, args);
303
+
304
+ return result;
305
+ }
306
+
307
+ return array_splice.call(this, start, deleteCount);
308
+ }
309
+
310
+ }
311
+}
312
+
313
+// ES5 15.4.4.12
314
+// http://es5.github.com/#x15.4.4.13
315
+// Return len+argCount.
316
+// [bugfix, ielt8]
317
+// IE < 8 bug: [].unshift(0) == undefined but should be "1"
318
+if ([].unshift(0) != 1) {
319
+ var array_unshift = Array.prototype.unshift;
320
+ Array.prototype.unshift = function() {
321
+ array_unshift.apply(this, arguments);
322
+ return this.length;
323
+ };
324
+}
325
+
326
+// ES5 15.4.3.2
327
+// http://es5.github.com/#x15.4.3.2
328
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
329
+if (!Array.isArray) {
330
+ Array.isArray = function isArray(obj) {
331
+ return _toString(obj) == "[object Array]";
332
+ };
333
+}
334
+
335
+// The IsCallable() check in the Array functions
336
+// has been replaced with a strict check on the
337
+// internal class of the object to trap cases where
338
+// the provided function was actually a regular
339
+// expression literal, which in V8 and
340
+// JavaScriptCore is a typeof "function". Only in
341
+// V8 are regular expression literals permitted as
342
+// reduce parameters, so it is desirable in the
343
+// general case for the shim to match the more
344
+// strict and common behavior of rejecting regular
345
+// expressions.
346
+
347
+// ES5 15.4.4.18
348
+// http://es5.github.com/#x15.4.4.18
349
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
350
+
351
+// Check failure of by-index access of string characters (IE < 9)
352
+// and failure of `0 in boxedString` (Rhino)
353
+var boxedString = Object("a"),
354
+ splitString = boxedString[0] != "a" || !(0 in boxedString);
355
+// Check node 0.6.21 bug where third parameter is not boxed
356
+var boxedForEach = true;
357
+if (Array.prototype.forEach) {
358
+ Array.prototype.forEach.call("foo", function(item, i, obj) {
359
+ if (typeof obj !== 'object') boxedForEach = false;
360
+ });
361
+}
362
+
363
+if (!Array.prototype.forEach || !boxedForEach) {
364
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
365
+ var object = toObject(this),
366
+ self = splitString && _toString(this) == "[object String]" ?
367
+ this.split("") :
368
+ object,
369
+ thisp = arguments[1],
370
+ i = -1,
371
+ length = self.length >>> 0;
372
+
373
+ // If no callback function or if callback is not a callable function
374
+ if (_toString(fun) != "[object Function]") {
375
+ throw new TypeError(); // TODO message
376
+ }
377
+
378
+ while (++i < length) {
379
+ if (i in self) {
380
+ // Invoke the callback function with call, passing arguments:
381
+ // context, property value, property key, thisArg object
382
+ // context
383
+ fun.call(thisp, self[i], i, object);
384
+ }
385
+ }
386
+ };
387
+}
388
+
389
+// ES5 15.4.4.19
390
+// http://es5.github.com/#x15.4.4.19
391
+// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
392
+if (!Array.prototype.map) {
393
+ Array.prototype.map = function map(fun /*, thisp*/) {
394
+ var object = toObject(this),
395
+ self = splitString && _toString(this) == "[object String]" ?
396
+ this.split("") :
397
+ object,
398
+ length = self.length >>> 0,
399
+ result = Array(length),
400
+ thisp = arguments[1];
401
+
402
+ // If no callback function or if callback is not a callable function
403
+ if (_toString(fun) != "[object Function]") {
404
+ throw new TypeError(fun + " is not a function");
405
+ }
406
+
407
+ for (var i = 0; i < length; i++) {
408
+ if (i in self)
409
+ result[i] = fun.call(thisp, self[i], i, object);
410
+ }
411
+ return result;
412
+ };
413
+}
414
+
415
+// ES5 15.4.4.20
416
+// http://es5.github.com/#x15.4.4.20
417
+// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
418
+if (!Array.prototype.filter) {
419
+ Array.prototype.filter = function filter(fun /*, thisp */) {
420
+ var object = toObject(this),
421
+ self = splitString && _toString(this) == "[object String]" ?
422
+ this.split("") :
423
+ object,
424
+ length = self.length >>> 0,
425
+ result = [],
426
+ value,
427
+ thisp = arguments[1];
428
+
429
+ // If no callback function or if callback is not a callable function
430
+ if (_toString(fun) != "[object Function]") {
431
+ throw new TypeError(fun + " is not a function");
432
+ }
433
+
434
+ for (var i = 0; i < length; i++) {
435
+ if (i in self) {
436
+ value = self[i];
437
+ if (fun.call(thisp, value, i, object)) {
438
+ result.push(value);
439
+ }
440
+ }
441
+ }
442
+ return result;
443
+ };
444
+}
445
+
446
+// ES5 15.4.4.16
447
+// http://es5.github.com/#x15.4.4.16
448
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
449
+if (!Array.prototype.every) {
450
+ Array.prototype.every = function every(fun /*, thisp */) {
451
+ var object = toObject(this),
452
+ self = splitString && _toString(this) == "[object String]" ?
453
+ this.split("") :
454
+ object,
455
+ length = self.length >>> 0,
456
+ thisp = arguments[1];
457
+
458
+ // If no callback function or if callback is not a callable function
459
+ if (_toString(fun) != "[object Function]") {
460
+ throw new TypeError(fun + " is not a function");
461
+ }
462
+
463
+ for (var i = 0; i < length; i++) {
464
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
465
+ return false;
466
+ }
467
+ }
468
+ return true;
469
+ };
470
+}
471
+
472
+// ES5 15.4.4.17
473
+// http://es5.github.com/#x15.4.4.17
474
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
475
+if (!Array.prototype.some) {
476
+ Array.prototype.some = function some(fun /*, thisp */) {
477
+ var object = toObject(this),
478
+ self = splitString && _toString(this) == "[object String]" ?
479
+ this.split("") :
480
+ object,
481
+ length = self.length >>> 0,
482
+ thisp = arguments[1];
483
+
484
+ // If no callback function or if callback is not a callable function
485
+ if (_toString(fun) != "[object Function]") {
486
+ throw new TypeError(fun + " is not a function");
487
+ }
488
+
489
+ for (var i = 0; i < length; i++) {
490
+ if (i in self && fun.call(thisp, self[i], i, object)) {
491
+ return true;
492
+ }
493
+ }
494
+ return false;
495
+ };
496
+}
497
+
498
+// ES5 15.4.4.21
499
+// http://es5.github.com/#x15.4.4.21
500
+// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
501
+if (!Array.prototype.reduce) {
502
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
503
+ var object = toObject(this),
504
+ self = splitString && _toString(this) == "[object String]" ?
505
+ this.split("") :
506
+ object,
507
+ length = self.length >>> 0;
508
+
509
+ // If no callback function or if callback is not a callable function
510
+ if (_toString(fun) != "[object Function]") {
511
+ throw new TypeError(fun + " is not a function");
512
+ }
513
+
514
+ // no value to return if no initial value and an empty array
515
+ if (!length && arguments.length == 1) {
516
+ throw new TypeError("reduce of empty array with no initial value");
517
+ }
518
+
519
+ var i = 0;
520
+ var result;
521
+ if (arguments.length >= 2) {
522
+ result = arguments[1];
523
+ } else {
524
+ do {
525
+ if (i in self) {
526
+ result = self[i++];
527
+ break;
528
+ }
529
+
530
+ // if array contains no values, no initial value to return
531
+ if (++i >= length) {
532
+ throw new TypeError("reduce of empty array with no initial value");
533
+ }
534
+ } while (true);
535
+ }
536
+
537
+ for (; i < length; i++) {
538
+ if (i in self) {
539
+ result = fun.call(void 0, result, self[i], i, object);
540
+ }
541
+ }
542
+
543
+ return result;
544
+ };
545
+}
546
+
547
+// ES5 15.4.4.22
548
+// http://es5.github.com/#x15.4.4.22
549
+// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
550
+if (!Array.prototype.reduceRight) {
551
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
552
+ var object = toObject(this),
553
+ self = splitString && _toString(this) == "[object String]" ?
554
+ this.split("") :
555
+ object,
556
+ length = self.length >>> 0;
557
+
558
+ // If no callback function or if callback is not a callable function
559
+ if (_toString(fun) != "[object Function]") {
560
+ throw new TypeError(fun + " is not a function");
561
+ }
562
+
563
+ // no value to return if no initial value, empty array
564
+ if (!length && arguments.length == 1) {
565
+ throw new TypeError("reduceRight of empty array with no initial value");
566
+ }
567
+
568
+ var result, i = length - 1;
569
+ if (arguments.length >= 2) {
570
+ result = arguments[1];
571
+ } else {
572
+ do {
573
+ if (i in self) {
574
+ result = self[i--];
575
+ break;
576
+ }
577
+
578
+ // if array contains no values, no initial value to return
579
+ if (--i < 0) {
580
+ throw new TypeError("reduceRight of empty array with no initial value");
581
+ }
582
+ } while (true);
583
+ }
584
+
585
+ if (i < 0) {
586
+ return result;
587
+ }
588
+
589
+ do {
590
+ if (i in this) {
591
+ result = fun.call(void 0, result, self[i], i, object);
592
+ }
593
+ } while (i--);
594
+
595
+ return result;
596
+ };
597
+}
598
+
599
+// ES5 15.4.4.14
600
+// http://es5.github.com/#x15.4.4.14
601
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
602
+if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
603
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
604
+ var self = splitString && _toString(this) == "[object String]" ?
605
+ this.split("") :
606
+ toObject(this),
607
+ length = self.length >>> 0;
608
+
609
+ if (!length) {
610
+ return -1;
611
+ }
612
+
613
+ var i = 0;
614
+ if (arguments.length > 1) {
615
+ i = toInteger(arguments[1]);
616
+ }
617
+
618
+ // handle negative indices
619
+ i = i >= 0 ? i : Math.max(0, length + i);
620
+ for (; i < length; i++) {
621
+ if (i in self && self[i] === sought) {
622
+ return i;
623
+ }
624
+ }
625
+ return -1;
626
+ };
627
+}
628
+
629
+// ES5 15.4.4.15
630
+// http://es5.github.com/#x15.4.4.15
631
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
632
+if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
633
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
634
+ var self = splitString && _toString(this) == "[object String]" ?
635
+ this.split("") :
636
+ toObject(this),
637
+ length = self.length >>> 0;
638
+
639
+ if (!length) {
640
+ return -1;
641
+ }
642
+ var i = length - 1;
643
+ if (arguments.length > 1) {
644
+ i = Math.min(i, toInteger(arguments[1]));
645
+ }
646
+ // handle negative indices
647
+ i = i >= 0 ? i : length - Math.abs(i);
648
+ for (; i >= 0; i--) {
649
+ if (i in self && sought === self[i]) {
650
+ return i;
651
+ }
652
+ }
653
+ return -1;
654
+ };
655
+}
656
+
657
+//
658
+// Object
659
+// ======
660
+//
661
+
662
+// ES5 15.2.3.14
663
+// http://es5.github.com/#x15.2.3.14
664
+if (!Object.keys) {
665
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
666
+ var hasDontEnumBug = true,
667
+ dontEnums = [
668
+ "toString",
669
+ "toLocaleString",
670
+ "valueOf",
671
+ "hasOwnProperty",
672
+ "isPrototypeOf",
673
+ "propertyIsEnumerable",
674
+ "constructor"
675
+ ],
676
+ dontEnumsLength = dontEnums.length;
677
+
678
+ for (var key in {"toString": null}) {
679
+ hasDontEnumBug = false;
680
+ }
681
+
682
+ Object.keys = function keys(object) {
683
+
684
+ if (
685
+ (typeof object != "object" && typeof object != "function") ||
686
+ object === null
687
+ ) {
688
+ throw new TypeError("Object.keys called on a non-object");
689
+ }
690
+
691
+ var keys = [];
692
+ for (var name in object) {
693
+ if (owns(object, name)) {
694
+ keys.push(name);
695
+ }
696
+ }
697
+
698
+ if (hasDontEnumBug) {
699
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
700
+ var dontEnum = dontEnums[i];
701
+ if (owns(object, dontEnum)) {
702
+ keys.push(dontEnum);
703
+ }
704
+ }
705
+ }
706
+ return keys;
707
+ };
708
+
709
+}
710
+
711
+//
712
+// Date
713
+// ====
714
+//
715
+
716
+// ES5 15.9.5.43
717
+// http://es5.github.com/#x15.9.5.43
718
+// This function returns a String value represent the instance in time
719
+// represented by this Date object. The format of the String is the Date Time
720
+// string format defined in 15.9.1.15. All fields are present in the String.
721
+// The time zone is always UTC, denoted by the suffix Z. If the time value of
722
+// this object is not a finite Number a RangeError exception is thrown.
723
+var negativeDate = -62198755200000,
724
+ negativeYearString = "-000001";
725
+if (
726
+ !Date.prototype.toISOString ||
727
+ (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
728
+) {
729
+ Date.prototype.toISOString = function toISOString() {
730
+ var result, length, value, year, month;
731
+ if (!isFinite(this)) {
732
+ throw new RangeError("Date.prototype.toISOString called on non-finite value.");
733
+ }
734
+
735
+ year = this.getUTCFullYear();
736
+
737
+ month = this.getUTCMonth();
738
+ // see https://github.com/es-shims/es5-shim/issues/111
739
+ year += Math.floor(month / 12);
740
+ month = (month % 12 + 12) % 12;
741
+
742
+ // the date time string format is specified in 15.9.1.15.
743
+ result = [month + 1, this.getUTCDate(),
744
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
745
+ year = (
746
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
747
+ ("00000" + Math.abs(year))
748
+ .slice(0 <= year && year <= 9999 ? -4 : -6)
749
+ );
750
+
751
+ length = result.length;
752
+ while (length--) {
753
+ value = result[length];
754
+ // pad months, days, hours, minutes, and seconds to have two
755
+ // digits.
756
+ if (value < 10) {
757
+ result[length] = "0" + value;
758
+ }
759
+ }
760
+ // pad milliseconds to have three digits.
761
+ return (
762
+ year + "-" + result.slice(0, 2).join("-") +
763
+ "T" + result.slice(2).join(":") + "." +
764
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
765
+ );
766
+ };
767
+}
768
+
769
+
770
+// ES5 15.9.5.44
771
+// http://es5.github.com/#x15.9.5.44
772
+// This function provides a String representation of a Date object for use by
773
+// JSON.stringify (15.12.3).
774
+var dateToJSONIsSupported = false;
775
+try {
776
+ dateToJSONIsSupported = (
777
+ Date.prototype.toJSON &&
778
+ new Date(NaN).toJSON() === null &&
779
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
780
+ Date.prototype.toJSON.call({ // generic
781
+ toISOString: function () {
782
+ return true;
783
+ }
784
+ })
785
+ );
786
+} catch (e) {
787
+}
788
+if (!dateToJSONIsSupported) {
789
+ Date.prototype.toJSON = function toJSON(key) {
790
+ // When the toJSON method is called with argument key, the following
791
+ // steps are taken:
792
+
793
+ // 1. Let O be the result of calling ToObject, giving it the this
794
+ // value as its argument.
795
+ // 2. Let tv be toPrimitive(O, hint Number).
796
+ var o = Object(this),
797
+ tv = toPrimitive(o),
798
+ toISO;
799
+ // 3. If tv is a Number and is not finite, return null.
800
+ if (typeof tv === "number" && !isFinite(tv)) {
801
+ return null;
802
+ }
803
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
804
+ // O with argument "toISOString".
805
+ toISO = o.toISOString;
806
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
807
+ if (typeof toISO != "function") {
808
+ throw new TypeError("toISOString property is not callable");
809
+ }
810
+ // 6. Return the result of calling the [[Call]] internal method of
811
+ // toISO with O as the this value and an empty argument list.
812
+ return toISO.call(o);
813
+
814
+ // NOTE 1 The argument is ignored.
815
+
816
+ // NOTE 2 The toJSON function is intentionally generic; it does not
817
+ // require that its this value be a Date object. Therefore, it can be
818
+ // transferred to other kinds of objects for use as a method. However,
819
+ // it does require that any such object have a toISOString method. An
820
+ // object is free to use the argument key to filter its
821
+ // stringification.
822
+ };
823
+}
824
+
825
+// ES5 15.9.4.2
826
+// http://es5.github.com/#x15.9.4.2
827
+// based on work shared by Daniel Friesen (dantman)
828
+// http://gist.github.com/303249
829
+if (!Date.parse || "Date.parse is buggy") {
830
+ // XXX global assignment won't work in embeddings that use
831
+ // an alternate object for the context.
832
+ Date = (function(NativeDate) {
833
+
834
+ // Date.length === 7
835
+ function Date(Y, M, D, h, m, s, ms) {
836
+ var length = arguments.length;
837
+ if (this instanceof NativeDate) {
838
+ var date = length == 1 && String(Y) === Y ? // isString(Y)
839
+ // We explicitly pass it through parse:
840
+ new NativeDate(Date.parse(Y)) :
841
+ // We have to manually make calls depending on argument
842
+ // length here
843
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
844
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
845
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
846
+ length >= 4 ? new NativeDate(Y, M, D, h) :
847
+ length >= 3 ? new NativeDate(Y, M, D) :
848
+ length >= 2 ? new NativeDate(Y, M) :
849
+ length >= 1 ? new NativeDate(Y) :
850
+ new NativeDate();
851
+ // Prevent mixups with unfixed Date object
852
+ date.constructor = Date;
853
+ return date;
854
+ }
855
+ return NativeDate.apply(this, arguments);
856
+ };
857
+
858
+ // 15.9.1.15 Date Time String Format.
859
+ var isoDateExpression = new RegExp("^" +
860
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
861
+ // 6-digit extended year
862
+ "(?:-(\\d{2})" + // optional month capture
863
+ "(?:-(\\d{2})" + // optional day capture
864
+ "(?:" + // capture hours:minutes:seconds.milliseconds
865
+ "T(\\d{2})" + // hours capture
866
+ ":(\\d{2})" + // minutes capture
867
+ "(?:" + // optional :seconds.milliseconds
868
+ ":(\\d{2})" + // seconds capture
869
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
870
+ ")?" +
871
+ "(" + // capture UTC offset component
872
+ "Z|" + // UTC capture
873
+ "(?:" + // offset specifier +/-hours:minutes
874
+ "([-+])" + // sign capture
875
+ "(\\d{2})" + // hours offset capture
876
+ ":(\\d{2})" + // minutes offset capture
877
+ ")" +
878
+ ")?)?)?)?" +
879
+ "$");
880
+
881
+ var months = [
882
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
883
+ ];
884
+
885
+ function dayFromMonth(year, month) {
886
+ var t = month > 1 ? 1 : 0;
887
+ return (
888
+ months[month] +
889
+ Math.floor((year - 1969 + t) / 4) -
890
+ Math.floor((year - 1901 + t) / 100) +
891
+ Math.floor((year - 1601 + t) / 400) +
892
+ 365 * (year - 1970)
893
+ );
894
+ }
895
+
896
+ function toUTC(t) {
897
+ return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
898
+ }
899
+
900
+ // Copy any custom methods a 3rd party library may have added
901
+ for (var key in NativeDate) {
902
+ Date[key] = NativeDate[key];
903
+ }
904
+
905
+ // Copy "native" methods explicitly; they may be non-enumerable
906
+ Date.now = NativeDate.now;
907
+ Date.UTC = NativeDate.UTC;
908
+ Date.prototype = NativeDate.prototype;
909
+ Date.prototype.constructor = Date;
910
+
911
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
912
+ Date.parse = function parse(string) {
913
+ var match = isoDateExpression.exec(string);
914
+ if (match) {
915
+ // parse months, days, hours, minutes, seconds, and milliseconds
916
+ // provide default values if necessary
917
+ // parse the UTC offset component
918
+ var year = Number(match[1]),
919
+ month = Number(match[2] || 1) - 1,
920
+ day = Number(match[3] || 1) - 1,
921
+ hour = Number(match[4] || 0),
922
+ minute = Number(match[5] || 0),
923
+ second = Number(match[6] || 0),
924
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
925
+ // When time zone is missed, local offset should be used
926
+ // (ES 5.1 bug)
927
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
928
+ isLocalTime = Boolean(match[4] && !match[8]),
929
+ signOffset = match[9] === "-" ? 1 : -1,
930
+ hourOffset = Number(match[10] || 0),
931
+ minuteOffset = Number(match[11] || 0),
932
+ result;
933
+ if (
934
+ hour < (
935
+ minute > 0 || second > 0 || millisecond > 0 ?
936
+ 24 : 25
937
+ ) &&
938
+ minute < 60 && second < 60 && millisecond < 1000 &&
939
+ month > -1 && month < 12 && hourOffset < 24 &&
940
+ minuteOffset < 60 && // detect invalid offsets
941
+ day > -1 &&
942
+ day < (
943
+ dayFromMonth(year, month + 1) -
944
+ dayFromMonth(year, month)
945
+ )
946
+ ) {
947
+ result = (
948
+ (dayFromMonth(year, month) + day) * 24 +
949
+ hour +
950
+ hourOffset * signOffset
951
+ ) * 60;
952
+ result = (
953
+ (result + minute + minuteOffset * signOffset) * 60 +
954
+ second
955
+ ) * 1000 + millisecond;
956
+ if (isLocalTime) {
957
+ result = toUTC(result);
958
+ }
959
+ if (-8.64e15 <= result && result <= 8.64e15) {
960
+ return result;
961
+ }
962
+ }
963
+ return NaN;
964
+ }
965
+ return NativeDate.parse.apply(this, arguments);
966
+ };
967
+
968
+ return Date;
969
+ })(Date);
970
+}
971
+
972
+// ES5 15.9.4.4
973
+// http://es5.github.com/#x15.9.4.4
974
+if (!Date.now) {
975
+ Date.now = function now() {
976
+ return new Date().getTime();
977
+ };
978
+}
979
+
980
+
981
+//
982
+// Number
983
+// ======
984
+//
985
+
986
+// ES5.1 15.7.4.5
987
+// http://es5.github.com/#x15.7.4.5
988
+if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
989
+ // Hide these variables and functions
990
+ (function () {
991
+ var base, size, data, i;
992
+
993
+ base = 1e7;
994
+ size = 6;
995
+ data = [0, 0, 0, 0, 0, 0];
996
+
997
+ function multiply(n, c) {
998
+ var i = -1;
999
+ while (++i < size) {
1000
+ c += n * data[i];
1001
+ data[i] = c % base;
1002
+ c = Math.floor(c / base);
1003
+ }
1004
+ }
1005
+
1006
+ function divide(n) {
1007
+ var i = size, c = 0;
1008
+ while (--i >= 0) {
1009
+ c += data[i];
1010
+ data[i] = Math.floor(c / n);
1011
+ c = (c % n) * base;
1012
+ }
1013
+ }
1014
+
1015
+ function toString() {
1016
+ var i = size;
1017
+ var s = '';
1018
+ while (--i >= 0) {
1019
+ if (s !== '' || i === 0 || data[i] !== 0) {
1020
+ var t = String(data[i]);
1021
+ if (s === '') {
1022
+ s = t;
1023
+ } else {
1024
+ s += '0000000'.slice(0, 7 - t.length) + t;
1025
+ }
1026
+ }
1027
+ }
1028
+ return s;
1029
+ }
1030
+
1031
+ function pow(x, n, acc) {
1032
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1033
+ }
1034
+
1035
+ function log(x) {
1036
+ var n = 0;
1037
+ while (x >= 4096) {
1038
+ n += 12;
1039
+ x /= 4096;
1040
+ }
1041
+ while (x >= 2) {
1042
+ n += 1;
1043
+ x /= 2;
1044
+ }
1045
+ return n;
1046
+ }
1047
+
1048
+ Number.prototype.toFixed = function (fractionDigits) {
1049
+ var f, x, s, m, e, z, j, k;
1050
+
1051
+ // Test for NaN and round fractionDigits down
1052
+ f = Number(fractionDigits);
1053
+ f = f !== f ? 0 : Math.floor(f);
1054
+
1055
+ if (f < 0 || f > 20) {
1056
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
1057
+ }
1058
+
1059
+ x = Number(this);
1060
+
1061
+ // Test for NaN
1062
+ if (x !== x) {
1063
+ return "NaN";
1064
+ }
1065
+
1066
+ // If it is too big or small, return the string value of the number
1067
+ if (x <= -1e21 || x >= 1e21) {
1068
+ return String(x);
1069
+ }
1070
+
1071
+ s = "";
1072
+
1073
+ if (x < 0) {
1074
+ s = "-";
1075
+ x = -x;
1076
+ }
1077
+
1078
+ m = "0";
1079
+
1080
+ if (x > 1e-21) {
1081
+ // 1e-21 < x < 1e21
1082
+ // -70 < log2(x) < 70
1083
+ e = log(x * pow(2, 69, 1)) - 69;
1084
+ z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1085
+ z *= 0x10000000000000; // Math.pow(2, 52);
1086
+ e = 52 - e;
1087
+
1088
+ // -18 < e < 122
1089
+ // x = z / 2 ^ e
1090
+ if (e > 0) {
1091
+ multiply(0, z);
1092
+ j = f;
1093
+
1094
+ while (j >= 7) {
1095
+ multiply(1e7, 0);
1096
+ j -= 7;
1097
+ }
1098
+
1099
+ multiply(pow(10, j, 1), 0);
1100
+ j = e - 1;
1101
+
1102
+ while (j >= 23) {
1103
+ divide(1 << 23);
1104
+ j -= 23;
1105
+ }
1106
+
1107
+ divide(1 << j);
1108
+ multiply(1, 1);
1109
+ divide(2);
1110
+ m = toString();
1111
+ } else {
1112
+ multiply(0, z);
1113
+ multiply(1 << (-e), 0);
1114
+ m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1115
+ }
1116
+ }
1117
+
1118
+ if (f > 0) {
1119
+ k = m.length;
1120
+
1121
+ if (k <= f) {
1122
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1123
+ } else {
1124
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1125
+ }
1126
+ } else {
1127
+ m = s + m;
1128
+ }
1129
+
1130
+ return m;
1131
+ }
1132
+ }());
1133
+}
1134
+
1135
+
1136
+//
1137
+// String
1138
+// ======
1139
+//
1140
+
1141
+
1142
+// ES5 15.5.4.14
1143
+// http://es5.github.com/#x15.5.4.14
1144
+
1145
+// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1146
+// Many browsers do not split properly with regular expressions or they
1147
+// do not perform the split correctly under obscure conditions.
1148
+// See http://blog.stevenlevithan.com/archives/cross-browser-split
1149
+// I've tested in many browsers and this seems to cover the deviant ones:
1150
+// 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1151
+// '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1152
+// 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1153
+// [undefined, "t", undefined, "e", ...]
1154
+// ''.split(/.?/) should be [], not [""]
1155
+// '.'.split(/()()/) should be ["."], not ["", "", "."]
1156
+
1157
+var string_split = String.prototype.split;
1158
+if (
1159
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1160
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1161
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1162
+ ''.split(/.?/).length ||
1163
+ '.'.split(/()()/).length > 1
1164
+) {
1165
+ (function () {
1166
+ var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1167
+
1168
+ String.prototype.split = function (separator, limit) {
1169
+ var string = this;
1170
+ if (separator === void 0 && limit === 0)
1171
+ return [];
1172
+
1173
+ // If `separator` is not a regex, use native split
1174
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1175
+ return string_split.apply(this, arguments);
1176
+ }
1177
+
1178
+ var output = [],
1179
+ flags = (separator.ignoreCase ? "i" : "") +
1180
+ (separator.multiline ? "m" : "") +
1181
+ (separator.extended ? "x" : "") + // Proposed for ES6
1182
+ (separator.sticky ? "y" : ""), // Firefox 3+
1183
+ lastLastIndex = 0,
1184
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1185
+ separator = new RegExp(separator.source, flags + "g"),
1186
+ separator2, match, lastIndex, lastLength;
1187
+ string += ""; // Type-convert
1188
+ if (!compliantExecNpcg) {
1189
+ // Doesn't need flags gy, but they don't hurt
1190
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1191
+ }
1192
+ /* Values for `limit`, per the spec:
1193
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1194
+ * If 0, Infinity, or NaN: 0
1195
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1196
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1197
+ * If other: Type-convert, then use the above rules
1198
+ */
1199
+ limit = limit === void 0 ?
1200
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1201
+ limit >>> 0; // ToUint32(limit)
1202
+ while (match = separator.exec(string)) {
1203
+ // `separator.lastIndex` is not reliable cross-browser
1204
+ lastIndex = match.index + match[0].length;
1205
+ if (lastIndex > lastLastIndex) {
1206
+ output.push(string.slice(lastLastIndex, match.index));
1207
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1208
+ // nonparticipating capturing groups
1209
+ if (!compliantExecNpcg && match.length > 1) {
1210
+ match[0].replace(separator2, function () {
1211
+ for (var i = 1; i < arguments.length - 2; i++) {
1212
+ if (arguments[i] === void 0) {
1213
+ match[i] = void 0;
1214
+ }
1215
+ }
1216
+ });
1217
+ }
1218
+ if (match.length > 1 && match.index < string.length) {
1219
+ Array.prototype.push.apply(output, match.slice(1));
1220
+ }
1221
+ lastLength = match[0].length;
1222
+ lastLastIndex = lastIndex;
1223
+ if (output.length >= limit) {
1224
+ break;
1225
+ }
1226
+ }
1227
+ if (separator.lastIndex === match.index) {
1228
+ separator.lastIndex++; // Avoid an infinite loop
1229
+ }
1230
+ }
1231
+ if (lastLastIndex === string.length) {
1232
+ if (lastLength || !separator.test("")) {
1233
+ output.push("");
1234
+ }
1235
+ } else {
1236
+ output.push(string.slice(lastLastIndex));
1237
+ }
1238
+ return output.length > limit ? output.slice(0, limit) : output;
1239
+ };
1240
+ }());
1241
+
1242
+// [bugfix, chrome]
1243
+// If separator is undefined, then the result array contains just one String,
1244
+// which is the this value (converted to a String). If limit is not undefined,
1245
+// then the output array is truncated so that it contains no more than limit
1246
+// elements.
1247
+// "0".split(undefined, 0) -> []
1248
+} else if ("0".split(void 0, 0).length) {
1249
+ String.prototype.split = function(separator, limit) {
1250
+ if (separator === void 0 && limit === 0) return [];
1251
+ return string_split.apply(this, arguments);
1252
+ }
1253
+}
1254
+
1255
+
1256
+// ECMA-262, 3rd B.2.3
1257
+// Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1258
+// non-normative section suggesting uniform semantics and it should be
1259
+// normalized across all browsers
1260
+// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1261
+if ("".substr && "0b".substr(-1) !== "b") {
1262
+ var string_substr = String.prototype.substr;
1263
+ /**
1264
+ * Get the substring of a string
1265
+ * @param {integer} start where to start the substring
1266
+ * @param {integer} length how many characters to return
1267
+ * @return {string}
1268
+ */
1269
+ String.prototype.substr = function(start, length) {
1270
+ return string_substr.call(
1271
+ this,
1272
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1273
+ length
1274
+ );
1275
+ }
1276
+}
1277
+
1278
+// ES5 15.5.4.20
1279
+// http://es5.github.com/#x15.5.4.20
1280
+var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1281
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1282
+ "\u2029\uFEFF";
1283
+if (!String.prototype.trim || ws.trim()) {
1284
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1285
+ // http://perfectionkills.com/whitespace-deviations/
1286
+ ws = "[" + ws + "]";
1287
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1288
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1289
+ String.prototype.trim = function trim() {
1290
+ if (this === void 0 || this === null) {
1291
+ throw new TypeError("can't convert "+this+" to object");
1292
+ }
1293
+ return String(this)
1294
+ .replace(trimBeginRegexp, "")
1295
+ .replace(trimEndRegexp, "");
1296
+ };
1297
+}
1298
+
1299
+//
1300
+// Util
1301
+// ======
1302
+//
1303
+
1304
+// ES5 9.4
1305
+// http://es5.github.com/#x9.4
1306
+// http://jsperf.com/to-integer
1307
+
1308
+function toInteger(n) {
1309
+ n = +n;
1310
+ if (n !== n) { // isNaN
1311
+ n = 0;
1312
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1313
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1314
+ }
1315
+ return n;
1316
+}
1317
+
1318
+function isPrimitive(input) {
1319
+ var type = typeof input;
1320
+ return (
1321
+ input === null ||
1322
+ type === "undefined" ||
1323
+ type === "boolean" ||
1324
+ type === "number" ||
1325
+ type === "string"
1326
+ );
1327
+}
1328
+
1329
+function toPrimitive(input) {
1330
+ var val, valueOf, toString;
1331
+ if (isPrimitive(input)) {
1332
+ return input;
1333
+ }
1334
+ valueOf = input.valueOf;
1335
+ if (typeof valueOf === "function") {
1336
+ val = valueOf.call(input);
1337
+ if (isPrimitive(val)) {
1338
+ return val;
1339
+ }
1340
+ }
1341
+ toString = input.toString;
1342
+ if (typeof toString === "function") {
1343
+ val = toString.call(input);
1344
+ if (isPrimitive(val)) {
1345
+ return val;
1346
+ }
1347
+ }
1348
+ throw new TypeError();
1349
+}
1350
+
1351
+// ES5 9.9
1352
+// http://es5.github.com/#x9.9
1353
+var toObject = function (o) {
1354
+ if (o == null) { // this matches both null and undefined
1355
+ throw new TypeError("can't convert "+o+" to object");
1356
+ }
1357
+ return Object(o);
1358
+};
1359
+
1360
+});
docs/_layouts/default.html
+5
@@ -1,4 +1,5 @@
1
<!DOCTYPE html>
2
+<!--[if IE]><![endif]-->
3
<html>
4
<head>
5
<meta charset="utf-8">
@@ -22,6 +23,10 @@
23
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
24
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
25
26
+ <!--[if lte IE 8]>
27
+ <script type="text/javascript" src="/react/js/es5-shim.js"></script>
28
+ <script type="text/javascript" src="/react/js/es5-sham.js"></script>
29
+ <![endif]-->
30
<script type="text/javascript" src="/react/js/codemirror.js"></script>
31
<script type="text/javascript" src="/react/js/javascript.js"></script>
32
<script type="text/javascript" src="/react/js/react.min.js"></script>