webshims-rails 1.15.3 → 1.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +32 -30
  4. data/vendor/assets/javascripts/webshims/shims/canvas-blob.js +1 -7
  5. data/vendor/assets/javascripts/webshims/shims/combos/1.js +2 -0
  6. data/vendor/assets/javascripts/webshims/shims/combos/10.js +50 -41
  7. data/vendor/assets/javascripts/webshims/shims/combos/11.js +34 -30
  8. data/vendor/assets/javascripts/webshims/shims/combos/12.js +14 -2
  9. data/vendor/assets/javascripts/webshims/shims/combos/13.js +14 -2
  10. data/vendor/assets/javascripts/webshims/shims/combos/15.js +31 -21
  11. data/vendor/assets/javascripts/webshims/shims/combos/16.js +31 -21
  12. data/vendor/assets/javascripts/webshims/shims/combos/17.js +34 -30
  13. data/vendor/assets/javascripts/webshims/shims/combos/18.js +387 -527
  14. data/vendor/assets/javascripts/webshims/shims/combos/2.js +18 -11
  15. data/vendor/assets/javascripts/webshims/shims/combos/21.js +39 -2
  16. data/vendor/assets/javascripts/webshims/shims/combos/22.js +14 -2
  17. data/vendor/assets/javascripts/webshims/shims/combos/25.js +53 -26
  18. data/vendor/assets/javascripts/webshims/shims/combos/27.js +12 -15
  19. data/vendor/assets/javascripts/webshims/shims/combos/28.js +13 -10
  20. data/vendor/assets/javascripts/webshims/shims/combos/3.js +18 -11
  21. data/vendor/assets/javascripts/webshims/shims/combos/30.js +18 -11
  22. data/vendor/assets/javascripts/webshims/shims/combos/31.js +18 -11
  23. data/vendor/assets/javascripts/webshims/shims/combos/34.js +30 -13
  24. data/vendor/assets/javascripts/webshims/shims/combos/4.js +16 -11
  25. data/vendor/assets/javascripts/webshims/shims/combos/5.js +34 -30
  26. data/vendor/assets/javascripts/webshims/shims/combos/6.js +34 -30
  27. data/vendor/assets/javascripts/webshims/shims/combos/7.js +18 -11
  28. data/vendor/assets/javascripts/webshims/shims/combos/8.js +18 -11
  29. data/vendor/assets/javascripts/webshims/shims/combos/9.js +50 -41
  30. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +16 -11
  31. data/vendor/assets/javascripts/webshims/shims/es5.js +507 -481
  32. data/vendor/assets/javascripts/webshims/shims/filereader-xhr.js +12 -15
  33. data/vendor/assets/javascripts/webshims/shims/form-core.js +2 -0
  34. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +34 -30
  35. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +13 -10
  36. data/vendor/assets/javascripts/webshims/shims/form-validation.js +2 -2
  37. data/vendor/assets/javascripts/webshims/shims/form-validators.js +0 -6
  38. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +3 -3
  39. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ca.js +65 -0
  40. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ru.js +8 -1
  41. data/vendor/assets/javascripts/webshims/shims/jme/controls.css +1 -3
  42. data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  43. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
  44. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
  45. data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
  46. data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  47. data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
  48. data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  49. data/vendor/assets/javascripts/webshims/shims/mediacapture.js +9 -3
  50. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +25 -0
  51. data/vendor/assets/javascripts/webshims/shims/picture.js +387 -527
  52. data/vendor/assets/javascripts/webshims/shims/styles/color-picker.png +0 -0
  53. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +12 -4
  54. data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +5 -5
  55. data/vendor/assets/javascripts/webshims/shims/styles/progress.png +0 -0
  56. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +37 -1
  57. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +7 -5
  58. data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +22 -11
  59. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +10 -7
  60. data/vendor/assets/javascripts/webshims/shims/styles/transparent.png +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/styles/widget-font.zip +0 -0
  62. data/vendor/assets/javascripts/webshims/shims/styles/widget.eot +0 -0
  63. data/vendor/assets/javascripts/webshims/shims/styles/widget.svg +6 -2
  64. data/vendor/assets/javascripts/webshims/shims/styles/widget.ttf +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/styles/widget.woff +0 -0
  66. data/vendor/assets/javascripts/webshims/shims/track.js +14 -2
  67. data/vendor/assets/javascripts/webshims/shims/url.js +18 -7
  68. metadata +9 -7
@@ -325,20 +325,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
325
325
  };
326
326
 
327
327
  //jquery mobile and jquery ui
328
- if(!$.widget){
328
+ if(!$.widget && (!$.pluginFactory || !$.pluginFactory.mixin)){
329
329
  (function(){
330
330
  var _cleanData = $.cleanData;
331
- $.cleanData = function( elems ) {
332
- if(!$.widget){
333
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
331
+ $.cleanData = (function( orig ) {
332
+ return function( elems ) {
333
+ var events, elem, i;
334
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
334
335
  try {
335
- $( elem ).triggerHandler( "remove" );
336
- // http://bugs.jquery.com/ticket/8235
337
- } catch( e ) {}
336
+ // Only trigger remove when necessary to save time
337
+ events = $._data( elem, "events" );
338
+ if ( events && events.remove ) {
339
+ $( elem ).triggerHandler( "remove" );
340
+ }
341
+ // http://bugs.jquery.com/ticket/8235
342
+ } catch ( e ) {}
338
343
  }
339
- }
340
- _cleanData( elems );
341
- };
344
+ orig( elems );
345
+ };
346
+ })( $.cleanData );
342
347
  })();
343
348
  }
344
349
 
@@ -759,7 +764,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
759
764
  return id;
760
765
  };
761
766
  })(),
762
- domPrefixes: ["ws", "webkit", "moz", "ms", "o"],
767
+ domPrefixes: ["webkit", "moz", "ms", "o", "ws"],
763
768
 
764
769
  prefixed: function (prop, obj){
765
770
  var i, testProp;
@@ -1710,6 +1715,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1710
1715
  }
1711
1716
  return message || '';
1712
1717
  };
1718
+
1719
+ webshims.refreshCustomValidityRules = $.noop;
1713
1720
 
1714
1721
  $.fn.getErrorMessage = function(key){
1715
1722
  var message = '';
@@ -102,20 +102,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
102
102
  };
103
103
 
104
104
  //jquery mobile and jquery ui
105
- if(!$.widget){
105
+ if(!$.widget && (!$.pluginFactory || !$.pluginFactory.mixin)){
106
106
  (function(){
107
107
  var _cleanData = $.cleanData;
108
- $.cleanData = function( elems ) {
109
- if(!$.widget){
110
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
108
+ $.cleanData = (function( orig ) {
109
+ return function( elems ) {
110
+ var events, elem, i;
111
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
111
112
  try {
112
- $( elem ).triggerHandler( "remove" );
113
- // http://bugs.jquery.com/ticket/8235
114
- } catch( e ) {}
113
+ // Only trigger remove when necessary to save time
114
+ events = $._data( elem, "events" );
115
+ if ( events && events.remove ) {
116
+ $( elem ).triggerHandler( "remove" );
117
+ }
118
+ // http://bugs.jquery.com/ticket/8235
119
+ } catch ( e ) {}
115
120
  }
116
- }
117
- _cleanData( elems );
118
- };
121
+ orig( elems );
122
+ };
123
+ })( $.cleanData );
119
124
  })();
120
125
  }
121
126
 
@@ -536,7 +541,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
536
541
  return id;
537
542
  };
538
543
  })(),
539
- domPrefixes: ["ws", "webkit", "moz", "ms", "o"],
544
+ domPrefixes: ["webkit", "moz", "ms", "o", "ws"],
540
545
 
541
546
  prefixed: function (prop, obj){
542
547
  var i, testProp;
@@ -2275,9 +2280,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2275
2280
  },
2276
2281
  time: function(val, o, noCorrect){
2277
2282
  var fVal, i;
2283
+
2278
2284
  if(val){
2279
2285
 
2280
2286
  val = val.split(':');
2287
+ if(val.length != 2 || isNaN(parseInt(val[0] || '', 10)) || isNaN(parseInt(val[1] || '', 10))){
2288
+ return val.join(':');
2289
+ }
2281
2290
  if(curCfg.meridian){
2282
2291
  fVal = (val[0] * 1);
2283
2292
  if(fVal && fVal >= 12){
@@ -2432,6 +2441,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2432
2441
  createFormat('d');
2433
2442
  var tmp, obj;
2434
2443
  var ret = '';
2444
+
2435
2445
  if(opts.splitInput){
2436
2446
  obj = {yy: 0, mm: 1, dd: 2};
2437
2447
  } else {
@@ -2453,8 +2463,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2453
2463
  }
2454
2464
  ret = ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-');
2455
2465
  }
2456
- return ret
2457
- ;
2466
+ return ret;
2458
2467
  },
2459
2468
  color: function(val, opts){
2460
2469
  var ret = '#000000';
@@ -2756,9 +2765,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2756
2765
  };
2757
2766
 
2758
2767
  ['defaultValue', 'value'].forEach(function(name){
2768
+ var formatName = 'format'+name;
2759
2769
  wsWidgetProto[name] = function(val, force){
2760
- if(!this._init || force || val !== this.options[name]){
2761
- this.element.prop(name, this.formatValue(val));
2770
+ if(!this._init || force || val !== this.options[name] || this.options[formatName] != this.element.prop(name)){
2771
+ this.options[formatName] = this.formatValue(val);
2772
+ this.element.prop(name, this.options[formatName]);
2762
2773
  this.options[name] = val;
2763
2774
  this._propertyChange(name);
2764
2775
  this.mirrorValidity();
@@ -2882,36 +2893,34 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2882
2893
  var isValue = name == 'value';
2883
2894
  spinBtnProto[name] = function(val, force, isLive){
2884
2895
  var selectionEnd;
2885
- if(!this._init || force || this.options[name] !== val){
2886
- if(isValue){
2887
- this._beforeValue(val);
2888
- } else {
2889
- this.elemHelper.prop(name, val);
2890
- }
2896
+ if(isValue){
2897
+ this._beforeValue(val);
2898
+ } else {
2899
+ this.elemHelper.prop(name, val);
2900
+ }
2891
2901
 
2892
- val = formatVal[this.type](val, this.options);
2893
- if(this.options.splitInput){
2894
- $.each(this.splits, function(i, elem){
2895
- var setOption;
2896
- if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
2897
- $('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
2898
- } else {
2899
- $.prop(elem, name, val[i]);
2900
- }
2901
- });
2902
- } else {
2903
- val = this.toFixed(val);
2904
- if(isLive && this._getSelectionEnd){
2905
- selectionEnd = this._getSelectionEnd(val);
2906
- }
2907
- this.element.prop(name, val);
2908
- if(selectionEnd != null){
2909
- this.element.prop('selectionEnd', selectionEnd);
2902
+ val = formatVal[this.type](val, this.options);
2903
+ if(this.options.splitInput){
2904
+ $.each(this.splits, function(i, elem){
2905
+ var setOption;
2906
+ if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){
2907
+ $('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true);
2908
+ } else {
2909
+ $.prop(elem, name, val[i]);
2910
2910
  }
2911
+ });
2912
+ } else {
2913
+ val = this.toFixed(val);
2914
+ if(isLive && this._getSelectionEnd){
2915
+ selectionEnd = this._getSelectionEnd(val);
2916
+ }
2917
+ this.element.prop(name, val);
2918
+ if(selectionEnd != null){
2919
+ this.element.prop('selectionEnd', selectionEnd);
2911
2920
  }
2912
- this._propertyChange(name);
2913
- this.mirrorValidity();
2914
2921
  }
2922
+ this._propertyChange(name);
2923
+ this.mirrorValidity();
2915
2924
  };
2916
2925
  });
2917
2926
 
@@ -102,20 +102,25 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
102
102
  };
103
103
 
104
104
  //jquery mobile and jquery ui
105
- if(!$.widget){
105
+ if(!$.widget && (!$.pluginFactory || !$.pluginFactory.mixin)){
106
106
  (function(){
107
107
  var _cleanData = $.cleanData;
108
- $.cleanData = function( elems ) {
109
- if(!$.widget){
110
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
108
+ $.cleanData = (function( orig ) {
109
+ return function( elems ) {
110
+ var events, elem, i;
111
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
111
112
  try {
112
- $( elem ).triggerHandler( "remove" );
113
- // http://bugs.jquery.com/ticket/8235
114
- } catch( e ) {}
113
+ // Only trigger remove when necessary to save time
114
+ events = $._data( elem, "events" );
115
+ if ( events && events.remove ) {
116
+ $( elem ).triggerHandler( "remove" );
117
+ }
118
+ // http://bugs.jquery.com/ticket/8235
119
+ } catch ( e ) {}
115
120
  }
116
- }
117
- _cleanData( elems );
118
- };
121
+ orig( elems );
122
+ };
123
+ })( $.cleanData );
119
124
  })();
120
125
  }
121
126
 
@@ -536,7 +541,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
536
541
  return id;
537
542
  };
538
543
  })(),
539
- domPrefixes: ["ws", "webkit", "moz", "ms", "o"],
544
+ domPrefixes: ["webkit", "moz", "ms", "o", "ws"],
540
545
 
541
546
  prefixed: function (prop, obj){
542
547
  var i, testProp;
@@ -16,40 +16,147 @@ setTimeout(function(){
16
16
 
17
17
  // Shortcut to an often accessed properties, in order to avoid multiple
18
18
  // dereference that costs universally.
19
- var call = Function.prototype.call;
20
- var prototypeOfArray = Array.prototype;
21
- var prototypeOfObject = Object.prototype;
22
- var _Array_slice_ = prototypeOfArray.slice;
23
- var array_splice = Array.prototype.splice;
24
- var array_push = Array.prototype.push;
25
- var array_unshift = Array.prototype.unshift;
19
+ var ArrayPrototype = Array.prototype;
20
+ var ObjectPrototype = Object.prototype;
21
+ var FunctionPrototype = Function.prototype;
22
+ var StringPrototype = String.prototype;
23
+ var NumberPrototype = Number.prototype;
24
+ var array_slice = ArrayPrototype.slice;
25
+ var array_splice = ArrayPrototype.splice;
26
+ var array_push = ArrayPrototype.push;
27
+ var array_unshift = ArrayPrototype.unshift;
28
+ var call = FunctionPrototype.call;
26
29
 
27
30
  // Having a toString local variable name breaks in Opera so use _toString.
28
- var _toString = prototypeOfObject.toString;
31
+ var _toString = ObjectPrototype.toString;
29
32
 
30
33
  var isFunction = function (val) {
31
- return prototypeOfObject.toString.call(val) === '[object Function]';
34
+ return ObjectPrototype.toString.call(val) === '[object Function]';
32
35
  };
33
36
  var isRegex = function (val) {
34
- return prototypeOfObject.toString.call(val) === '[object RegExp]';
37
+ return ObjectPrototype.toString.call(val) === '[object RegExp]';
35
38
  };
36
39
  var isArray = function isArray(obj) {
37
40
  return _toString.call(obj) === "[object Array]";
38
41
  };
42
+ var isString = function isString(obj) {
43
+ return _toString.call(obj) === "[object String]";
44
+ };
39
45
  var isArguments = function isArguments(value) {
40
46
  var str = _toString.call(value);
41
47
  var isArgs = str === '[object Arguments]';
42
48
  if (!isArgs) {
43
- isArgs = !isArray(str)
44
- && value !== null
45
- && typeof value === 'object'
46
- && typeof value.length === 'number'
47
- && value.length >= 0
48
- && isFunction(value.callee);
49
+ isArgs = !isArray(value)
50
+ && value !== null
51
+ && typeof value === 'object'
52
+ && typeof value.length === 'number'
53
+ && value.length >= 0
54
+ && isFunction(value.callee);
49
55
  }
50
56
  return isArgs;
51
57
  };
52
58
 
59
+ var supportsDescriptors = Object.defineProperty && (function () {
60
+ try {
61
+ Object.defineProperty({}, 'x', {});
62
+ return true;
63
+ } catch (e) { /* this is ES3 */
64
+ return false;
65
+ }
66
+ }());
67
+
68
+ // Define configurable, writable and non-enumerable props
69
+ // if they don't exist.
70
+ var defineProperty;
71
+ if (supportsDescriptors) {
72
+ defineProperty = function (object, name, method, forceAssign) {
73
+ if (!forceAssign && (name in object)) { return; }
74
+ Object.defineProperty(object, name, {
75
+ configurable: true,
76
+ enumerable: false,
77
+ writable: true,
78
+ value: method
79
+ });
80
+ };
81
+ } else {
82
+ defineProperty = function (object, name, method, forceAssign) {
83
+ if (!forceAssign && (name in object)) { return; }
84
+ object[name] = method;
85
+ };
86
+ }
87
+ var defineProperties = function (object, map, forceAssign) {
88
+ for (var name in map) {
89
+ if (ObjectPrototype.hasOwnProperty.call(map, name)) {
90
+ defineProperty(object, name, map[name], forceAssign);
91
+ }
92
+ }
93
+ };
94
+
95
+ //
96
+ // Util
97
+ // ======
98
+ //
99
+
100
+ // ES5 9.4
101
+ // http://es5.github.com/#x9.4
102
+ // http://jsperf.com/to-integer
103
+
104
+ function toInteger(n) {
105
+ n = +n;
106
+ if (n !== n) { // isNaN
107
+ n = 0;
108
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
109
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
110
+ }
111
+ return n;
112
+ }
113
+
114
+ function isPrimitive(input) {
115
+ var type = typeof input;
116
+ return (
117
+ input === null ||
118
+ type === "undefined" ||
119
+ type === "boolean" ||
120
+ type === "number" ||
121
+ type === "string"
122
+ );
123
+ }
124
+
125
+ function toPrimitive(input) {
126
+ var val, valueOf, toStr;
127
+ if (isPrimitive(input)) {
128
+ return input;
129
+ }
130
+ valueOf = input.valueOf;
131
+ if (isFunction(valueOf)) {
132
+ val = valueOf.call(input);
133
+ if (isPrimitive(val)) {
134
+ return val;
135
+ }
136
+ }
137
+ toStr = input.toString;
138
+ if (isFunction(toStr)) {
139
+ val = toStr.call(input);
140
+ if (isPrimitive(val)) {
141
+ return val;
142
+ }
143
+ }
144
+ throw new TypeError();
145
+ }
146
+
147
+ // ES5 9.9
148
+ // http://es5.github.com/#x9.9
149
+ var toObject = function (o) {
150
+ if (o == null) { // this matches both null and undefined
151
+ throw new TypeError("can't convert " + o + " to object");
152
+ }
153
+ return Object(o);
154
+ };
155
+
156
+ var ToUint32 = function ToUint32(x) {
157
+ return x >>> 0;
158
+ };
159
+
53
160
  //
54
161
  // Function
55
162
  // ========
@@ -60,8 +167,8 @@ setTimeout(function(){
60
167
 
61
168
  function Empty() {}
62
169
 
63
- if (!Function.prototype.bind) {
64
- Function.prototype.bind = function bind(that) { // .length is 1
170
+ defineProperties(FunctionPrototype, {
171
+ bind: function bind(that) { // .length is 1
65
172
  // 1. Let Target be the this value.
66
173
  var target = this;
67
174
  // 2. If IsCallable(Target) is false, throw a TypeError exception.
@@ -69,18 +176,18 @@ setTimeout(function(){
69
176
  throw new TypeError("Function.prototype.bind called on incompatible " + target);
70
177
  }
71
178
  // 3. Let A be a new (possibly empty) internal list of all of the
72
- // argument values provided after thisArg (arg1, arg2 etc), in order.
179
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
73
180
  // XXX slicedArgs will stand in for "A" if used
74
- var args = _Array_slice_.call(arguments, 1); // for normal call
181
+ var args = array_slice.call(arguments, 1); // for normal call
75
182
  // 4. Let F be a new native ECMAScript object.
76
183
  // 11. Set the [[Prototype]] internal property of F to the standard
77
- // built-in Function prototype object as specified in 15.3.3.1.
184
+ // built-in Function prototype object as specified in 15.3.3.1.
78
185
  // 12. Set the [[Call]] internal property of F as described in
79
- // 15.3.4.5.1.
186
+ // 15.3.4.5.1.
80
187
  // 13. Set the [[Construct]] internal property of F as described in
81
- // 15.3.4.5.2.
188
+ // 15.3.4.5.2.
82
189
  // 14. Set the [[HasInstance]] internal property of F as described in
83
- // 15.3.4.5.3.
190
+ // 15.3.4.5.3.
84
191
  var binder = function () {
85
192
 
86
193
  if (this instanceof bound) {
@@ -89,20 +196,20 @@ setTimeout(function(){
89
196
  // F that was created using the bind function is called with a
90
197
  // list of arguments ExtraArgs, the following steps are taken:
91
198
  // 1. Let target be the value of F's [[TargetFunction]]
92
- // internal property.
199
+ // internal property.
93
200
  // 2. If target has no [[Construct]] internal method, a
94
- // TypeError exception is thrown.
201
+ // TypeError exception is thrown.
95
202
  // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
96
- // property.
203
+ // property.
97
204
  // 4. Let args be a new list containing the same values as the
98
- // list boundArgs in the same order followed by the same
99
- // values as the list ExtraArgs in the same order.
205
+ // list boundArgs in the same order followed by the same
206
+ // values as the list ExtraArgs in the same order.
100
207
  // 5. Return the result of calling the [[Construct]] internal
101
- // method of target providing args as the arguments.
208
+ // method of target providing args as the arguments.
102
209
 
103
210
  var result = target.apply(
104
211
  this,
105
- args.concat(_Array_slice_.call(arguments))
212
+ args.concat(array_slice.call(arguments))
106
213
  );
107
214
  if (Object(result) === result) {
108
215
  return result;
@@ -116,22 +223,22 @@ setTimeout(function(){
116
223
  // this value and a list of arguments ExtraArgs, the following
117
224
  // steps are taken:
118
225
  // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
119
- // property.
226
+ // property.
120
227
  // 2. Let boundThis be the value of F's [[BoundThis]] internal
121
- // property.
228
+ // property.
122
229
  // 3. Let target be the value of F's [[TargetFunction]] internal
123
- // property.
230
+ // property.
124
231
  // 4. Let args be a new list containing the same values as the
125
- // list boundArgs in the same order followed by the same
126
- // values as the list ExtraArgs in the same order.
232
+ // list boundArgs in the same order followed by the same
233
+ // values as the list ExtraArgs in the same order.
127
234
  // 5. Return the result of calling the [[Call]] internal method
128
- // of target providing boundThis as the this value and
129
- // providing args as the arguments.
235
+ // of target providing boundThis as the this value and
236
+ // providing args as the arguments.
130
237
 
131
238
  // equiv: target.call(this, ...boundArgs, ...args)
132
239
  return target.apply(
133
240
  that,
134
- args.concat(_Array_slice_.call(arguments))
241
+ args.concat(array_slice.call(arguments))
135
242
  );
136
243
 
137
244
  }
@@ -139,15 +246,15 @@ setTimeout(function(){
139
246
  };
140
247
 
141
248
  // 15. If the [[Class]] internal property of Target is "Function", then
142
- // a. Let L be the length property of Target minus the length of A.
143
- // b. Set the length own property of F to either 0 or L, whichever is
144
- // larger.
249
+ // a. Let L be the length property of Target minus the length of A.
250
+ // b. Set the length own property of F to either 0 or L, whichever is
251
+ // larger.
145
252
  // 16. Else set the length own property of F to 0.
146
253
 
147
254
  var boundLength = Math.max(0, target.length - args.length);
148
255
 
149
256
  // 17. Set the attributes of the length own property of F to the values
150
- // specified in 15.3.5.1.
257
+ // specified in 15.3.5.1.
151
258
  var boundArgs = [];
152
259
  for (var i = 0; i < boundLength; i++) {
153
260
  boundArgs.push("$" + i);
@@ -174,13 +281,13 @@ setTimeout(function(){
174
281
  // TODO
175
282
  // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
176
283
  // 20. Call the [[DefineOwnProperty]] internal method of F with
177
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
178
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
179
- // false.
284
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
285
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
286
+ // false.
180
287
  // 21. Call the [[DefineOwnProperty]] internal method of F with
181
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
182
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
183
- // and false.
288
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
289
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
290
+ // and false.
184
291
 
185
292
  // TODO
186
293
  // NOTE Function objects created using Function.prototype.bind do not
@@ -190,12 +297,12 @@ setTimeout(function(){
190
297
 
191
298
  // 22. Return F.
192
299
  return bound;
193
- };
194
- }
300
+ }
301
+ });
195
302
 
196
303
  // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
197
304
  // us it in defining shortcuts.
198
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
305
+ var owns = call.bind(ObjectPrototype.hasOwnProperty);
199
306
 
200
307
  // If JS engine supports accessors creating shortcuts.
201
308
  var defineGetter;
@@ -203,11 +310,11 @@ setTimeout(function(){
203
310
  var lookupGetter;
204
311
  var lookupSetter;
205
312
  var supportsAccessors;
206
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
207
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
208
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
209
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
210
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
313
+ if ((supportsAccessors = owns(ObjectPrototype, "__defineGetter__"))) {
314
+ defineGetter = call.bind(ObjectPrototype.__defineGetter__);
315
+ defineSetter = call.bind(ObjectPrototype.__defineSetter__);
316
+ lookupGetter = call.bind(ObjectPrototype.__lookupGetter__);
317
+ lookupSetter = call.bind(ObjectPrototype.__lookupSetter__);
211
318
  }
212
319
 
213
320
  //
@@ -217,63 +324,68 @@ setTimeout(function(){
217
324
 
218
325
  // ES5 15.4.4.12
219
326
  // http://es5.github.com/#x15.4.4.12
220
- var spliceWorksWithEmptyObject = (function () {
221
- var obj = {};
222
- Array.prototype.splice.call(obj, 0, 0, 1);
223
- return obj.length === 1;
224
- }());
225
- var omittingSecondSpliceArgIsNoop = [1].splice(0).length === 0;
226
327
  var spliceNoopReturnsEmptyArray = (function () {
227
328
  var a = [1, 2];
228
329
  var result = a.splice();
229
330
  return a.length === 2 && isArray(result) && result.length === 0;
230
331
  }());
231
- if (spliceNoopReturnsEmptyArray) {
232
- // Safari 5.0 bug where .split() returns undefined
233
- Array.prototype.splice = function splice(start, deleteCount) {
234
- if (arguments.length === 0) { return []; }
235
- else { return array_splice.apply(this, arguments); }
236
- };
237
- }
238
- if (!omittingSecondSpliceArgIsNoop || !spliceWorksWithEmptyObject) {
239
- Array.prototype.splice = function splice(start, deleteCount) {
332
+ defineProperties(ArrayPrototype, {
333
+ // Safari 5.0 bug where .splice() returns undefined
334
+ splice: function splice(start, deleteCount) {
335
+ if (arguments.length === 0) {
336
+ return [];
337
+ } else {
338
+ return array_splice.apply(this, arguments);
339
+ }
340
+ }
341
+ }, spliceNoopReturnsEmptyArray);
342
+
343
+ var spliceWorksWithEmptyObject = (function () {
344
+ var obj = {};
345
+ ArrayPrototype.splice.call(obj, 0, 0, 1);
346
+ return obj.length === 1;
347
+ }());
348
+ defineProperties(ArrayPrototype, {
349
+ splice: function splice(start, deleteCount) {
240
350
  if (arguments.length === 0) { return []; }
241
351
  var args = arguments;
242
352
  this.length = Math.max(toInteger(this.length), 0);
243
353
  if (arguments.length > 0 && typeof deleteCount !== 'number') {
244
- args = _Array_slice_.call(arguments);
245
- if (args.length < 2) { args.push(toInteger(deleteCount)); }
246
- else { args[1] = toInteger(deleteCount); }
354
+ args = array_slice.call(arguments);
355
+ if (args.length < 2) {
356
+ args.push(this.length - start);
357
+ } else {
358
+ args[1] = toInteger(deleteCount);
359
+ }
247
360
  }
248
361
  return array_splice.apply(this, args);
249
- };
250
- }
362
+ }
363
+ }, !spliceWorksWithEmptyObject);
251
364
 
252
365
  // ES5 15.4.4.12
253
366
  // http://es5.github.com/#x15.4.4.13
254
367
  // Return len+argCount.
255
368
  // [bugfix, ielt8]
256
369
  // IE < 8 bug: [].unshift(0) === undefined but should be "1"
257
- if ([].unshift(0) !== 1) {
258
- Array.prototype.unshift = function () {
370
+ var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
371
+ defineProperties(ArrayPrototype, {
372
+ unshift: function () {
259
373
  array_unshift.apply(this, arguments);
260
374
  return this.length;
261
- };
262
- }
375
+ }
376
+ }, hasUnshiftReturnValueBug);
263
377
 
264
378
  // ES5 15.4.3.2
265
379
  // http://es5.github.com/#x15.4.3.2
266
380
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
267
- if (!Array.isArray) {
268
- Array.isArray = isArray;
269
- }
381
+ defineProperties(Array, { isArray: isArray });
270
382
 
271
383
  // The IsCallable() check in the Array functions
272
384
  // has been replaced with a strict check on the
273
385
  // internal class of the object to trap cases where
274
386
  // the provided function was actually a regular
275
387
  // expression literal, which in V8 and
276
- // JavaScriptCore is a typeof "function". Only in
388
+ // JavaScriptCore is a typeof "function". Only in
277
389
  // V8 are regular expression literals permitted as
278
390
  // reduce parameters, so it is desirable in the
279
391
  // general case for the shim to match the more
@@ -306,12 +418,10 @@ setTimeout(function(){
306
418
  return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
307
419
  };
308
420
 
309
- if (!Array.prototype.forEach || !properlyBoxesContext(Array.prototype.forEach)) {
310
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
421
+ defineProperties(ArrayPrototype, {
422
+ forEach: function forEach(fun /*, thisp*/) {
311
423
  var object = toObject(this),
312
- self = splitString && _toString.call(this) === "[object String]" ?
313
- this.split("") :
314
- object,
424
+ self = splitString && isString(this) ? this.split('') : object,
315
425
  thisp = arguments[1],
316
426
  i = -1,
317
427
  length = self.length >>> 0;
@@ -329,18 +439,16 @@ setTimeout(function(){
329
439
  fun.call(thisp, self[i], i, object);
330
440
  }
331
441
  }
332
- };
333
- }
442
+ }
443
+ }, !properlyBoxesContext(ArrayPrototype.forEach));
334
444
 
335
445
  // ES5 15.4.4.19
336
446
  // http://es5.github.com/#x15.4.4.19
337
447
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
338
- if (!Array.prototype.map || !properlyBoxesContext(Array.prototype.map)) {
339
- Array.prototype.map = function map(fun /*, thisp*/) {
448
+ defineProperties(ArrayPrototype, {
449
+ map: function map(fun /*, thisp*/) {
340
450
  var object = toObject(this),
341
- self = splitString && _toString.call(this) === "[object String]" ?
342
- this.split("") :
343
- object,
451
+ self = splitString && isString(this) ? this.split('') : object,
344
452
  length = self.length >>> 0,
345
453
  result = Array(length),
346
454
  thisp = arguments[1];
@@ -356,18 +464,16 @@ setTimeout(function(){
356
464
  }
357
465
  }
358
466
  return result;
359
- };
360
- }
467
+ }
468
+ }, !properlyBoxesContext(ArrayPrototype.map));
361
469
 
362
470
  // ES5 15.4.4.20
363
471
  // http://es5.github.com/#x15.4.4.20
364
472
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
365
- if (!Array.prototype.filter || !properlyBoxesContext(Array.prototype.filter)) {
366
- Array.prototype.filter = function filter(fun /*, thisp */) {
473
+ defineProperties(ArrayPrototype, {
474
+ filter: function filter(fun /*, thisp */) {
367
475
  var object = toObject(this),
368
- self = splitString && _toString.call(this) === "[object String]" ?
369
- this.split("") :
370
- object,
476
+ self = splitString && isString(this) ? this.split('') : object,
371
477
  length = self.length >>> 0,
372
478
  result = [],
373
479
  value,
@@ -387,18 +493,16 @@ setTimeout(function(){
387
493
  }
388
494
  }
389
495
  return result;
390
- };
391
- }
496
+ }
497
+ }, !properlyBoxesContext(ArrayPrototype.filter));
392
498
 
393
499
  // ES5 15.4.4.16
394
500
  // http://es5.github.com/#x15.4.4.16
395
501
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
396
- if (!Array.prototype.every || !properlyBoxesContext(Array.prototype.every)) {
397
- Array.prototype.every = function every(fun /*, thisp */) {
502
+ defineProperties(ArrayPrototype, {
503
+ every: function every(fun /*, thisp */) {
398
504
  var object = toObject(this),
399
- self = splitString && _toString.call(this) === "[object String]" ?
400
- this.split("") :
401
- object,
505
+ self = splitString && isString(this) ? this.split('') : object,
402
506
  length = self.length >>> 0,
403
507
  thisp = arguments[1];
404
508
 
@@ -413,18 +517,16 @@ setTimeout(function(){
413
517
  }
414
518
  }
415
519
  return true;
416
- };
417
- }
520
+ }
521
+ }, !properlyBoxesContext(ArrayPrototype.every));
418
522
 
419
523
  // ES5 15.4.4.17
420
524
  // http://es5.github.com/#x15.4.4.17
421
525
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
422
- if (!Array.prototype.some || !properlyBoxesContext(Array.prototype.some)) {
423
- Array.prototype.some = function some(fun /*, thisp */) {
526
+ defineProperties(ArrayPrototype, {
527
+ some: function some(fun /*, thisp */) {
424
528
  var object = toObject(this),
425
- self = splitString && _toString.call(this) === "[object String]" ?
426
- this.split("") :
427
- object,
529
+ self = splitString && isString(this) ? this.split('') : object,
428
530
  length = self.length >>> 0,
429
531
  thisp = arguments[1];
430
532
 
@@ -439,22 +541,20 @@ setTimeout(function(){
439
541
  }
440
542
  }
441
543
  return false;
442
- };
443
- }
544
+ }
545
+ }, !properlyBoxesContext(ArrayPrototype.some));
444
546
 
445
547
  // ES5 15.4.4.21
446
548
  // http://es5.github.com/#x15.4.4.21
447
549
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
448
550
  var reduceCoercesToObject = false;
449
- if (Array.prototype.reduce) {
450
- reduceCoercesToObject = typeof Array.prototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
551
+ if (ArrayPrototype.reduce) {
552
+ reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
451
553
  }
452
- if (!Array.prototype.reduce || !reduceCoercesToObject) {
453
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
554
+ defineProperties(ArrayPrototype, {
555
+ reduce: function reduce(fun /*, initial*/) {
454
556
  var object = toObject(this),
455
- self = splitString && _toString.call(this) === "[object String]" ?
456
- this.split("") :
457
- object,
557
+ self = splitString && isString(this) ? this.split('') : object,
458
558
  length = self.length >>> 0;
459
559
 
460
560
  // If no callback function or if callback is not a callable function
@@ -492,22 +592,20 @@ setTimeout(function(){
492
592
  }
493
593
 
494
594
  return result;
495
- };
496
- }
595
+ }
596
+ }, !reduceCoercesToObject);
497
597
 
498
598
  // ES5 15.4.4.22
499
599
  // http://es5.github.com/#x15.4.4.22
500
600
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
501
601
  var reduceRightCoercesToObject = false;
502
- if (Array.prototype.reduceRight) {
503
- reduceRightCoercesToObject = typeof Array.prototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
602
+ if (ArrayPrototype.reduceRight) {
603
+ reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
504
604
  }
505
- if (!Array.prototype.reduceRight || !reduceRightCoercesToObject) {
506
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
605
+ defineProperties(ArrayPrototype, {
606
+ reduceRight: function reduceRight(fun /*, initial*/) {
507
607
  var object = toObject(this),
508
- self = splitString && _toString.call(this) === "[object String]" ?
509
- this.split("") :
510
- object,
608
+ self = splitString && isString(this) ? this.split('') : object,
511
609
  length = self.length >>> 0;
512
610
 
513
611
  // If no callback function or if callback is not a callable function
@@ -548,17 +646,16 @@ setTimeout(function(){
548
646
  } while (i--);
549
647
 
550
648
  return result;
551
- };
552
- }
649
+ }
650
+ }, !reduceRightCoercesToObject);
553
651
 
554
652
  // ES5 15.4.4.14
555
653
  // http://es5.github.com/#x15.4.4.14
556
654
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
557
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) !== -1)) {
558
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
559
- var self = splitString && _toString.call(this) === "[object String]" ?
560
- this.split("") :
561
- toObject(this),
655
+ var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
656
+ defineProperties(ArrayPrototype, {
657
+ indexOf: function indexOf(sought /*, fromIndex */ ) {
658
+ var self = splitString && isString(this) ? this.split('') : toObject(this),
562
659
  length = self.length >>> 0;
563
660
 
564
661
  if (!length) {
@@ -578,17 +675,16 @@ setTimeout(function(){
578
675
  }
579
676
  }
580
677
  return -1;
581
- };
582
- }
678
+ }
679
+ }, hasFirefox2IndexOfBug);
583
680
 
584
681
  // ES5 15.4.4.15
585
682
  // http://es5.github.com/#x15.4.4.15
586
683
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
587
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) !== -1)) {
588
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
589
- var self = splitString && _toString.call(this) === "[object String]" ?
590
- this.split("") :
591
- toObject(this),
684
+ var hasFirefox2LastIndexOfBug = Array.prototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
685
+ defineProperties(ArrayPrototype, {
686
+ lastIndexOf: function lastIndexOf(sought /*, fromIndex */) {
687
+ var self = splitString && isString(this) ? this.split('') : toObject(this),
592
688
  length = self.length >>> 0;
593
689
 
594
690
  if (!length) {
@@ -606,8 +702,8 @@ setTimeout(function(){
606
702
  }
607
703
  }
608
704
  return -1;
609
- };
610
- }
705
+ }
706
+ }, hasFirefox2LastIndexOfBug);
611
707
 
612
708
  //
613
709
  // Object
@@ -616,29 +712,27 @@ setTimeout(function(){
616
712
 
617
713
  // ES5 15.2.3.14
618
714
  // http://es5.github.com/#x15.2.3.14
619
- var keysWorksWithArguments = Object.keys && (function () {
620
- return Object.keys(arguments).length === 2;
621
- }(1, 2));
622
- if (!Object.keys) {
623
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
624
- var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
625
- hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
626
- dontEnums = [
627
- "toString",
628
- "toLocaleString",
629
- "valueOf",
630
- "hasOwnProperty",
631
- "isPrototypeOf",
632
- "propertyIsEnumerable",
633
- "constructor"
634
- ],
635
- dontEnumsLength = dontEnums.length;
636
-
637
- Object.keys = function keys(object) {
715
+
716
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
717
+ var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
718
+ hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
719
+ dontEnums = [
720
+ "toString",
721
+ "toLocaleString",
722
+ "valueOf",
723
+ "hasOwnProperty",
724
+ "isPrototypeOf",
725
+ "propertyIsEnumerable",
726
+ "constructor"
727
+ ],
728
+ dontEnumsLength = dontEnums.length;
729
+
730
+ defineProperties(Object, {
731
+ keys: function keys(object) {
638
732
  var isFn = isFunction(object),
639
733
  isArgs = isArguments(object),
640
734
  isObject = object !== null && typeof object === 'object',
641
- isString = isObject && _toString.call(object) === '[object String]';
735
+ isStr = isObject && isString(object);
642
736
 
643
737
  if (!isObject && !isFn && !isArgs) {
644
738
  throw new TypeError("Object.keys called on a non-object");
@@ -646,7 +740,7 @@ setTimeout(function(){
646
740
 
647
741
  var theKeys = [];
648
742
  var skipProto = hasProtoEnumBug && isFn;
649
- if (isString || isArgs) {
743
+ if (isStr || isArgs) {
650
744
  for (var i = 0; i < object.length; ++i) {
651
745
  theKeys.push(String(i));
652
746
  }
@@ -669,18 +763,23 @@ setTimeout(function(){
669
763
  }
670
764
  }
671
765
  return theKeys;
672
- };
673
- } else if (!keysWorksWithArguments) {
674
- // Safari 5.0 bug
675
- var originalKeys = Object.keys;
676
- Object.keys = function keys(object) {
766
+ }
767
+ });
768
+
769
+ var keysWorksWithArguments = Object.keys && (function () {
770
+ // Safari 5.0 bug
771
+ return Object.keys(arguments).length === 2;
772
+ }(1, 2));
773
+ var originalKeys = Object.keys;
774
+ defineProperties(Object, {
775
+ keys: function keys(object) {
677
776
  if (isArguments(object)) {
678
- return originalKeys(Array.prototype.slice.call(object));
777
+ return originalKeys(ArrayPrototype.slice.call(object));
679
778
  } else {
680
779
  return originalKeys(object);
681
780
  }
682
- };
683
- }
781
+ }
782
+ }, !keysWorksWithArguments);
684
783
 
685
784
  //
686
785
  // Date
@@ -694,13 +793,12 @@ setTimeout(function(){
694
793
  // string format defined in 15.9.1.15. All fields are present in the String.
695
794
  // The time zone is always UTC, denoted by the suffix Z. If the time value of
696
795
  // this object is not a finite Number a RangeError exception is thrown.
697
- var negativeDate = -62198755200000,
698
- negativeYearString = "-000001";
699
- if (
700
- !Date.prototype.toISOString ||
701
- (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
702
- ) {
703
- Date.prototype.toISOString = function toISOString() {
796
+ var negativeDate = -62198755200000;
797
+ var negativeYearString = "-000001";
798
+ var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
799
+
800
+ defineProperties(Date.prototype, {
801
+ toISOString: function toISOString() {
704
802
  var result, length, value, year, month;
705
803
  if (!isFinite(this)) {
706
804
  throw new RangeError("Date.prototype.toISOString called on non-finite value.");
@@ -716,9 +814,9 @@ setTimeout(function(){
716
814
  // the date time string format is specified in 15.9.1.15.
717
815
  result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
718
816
  year = (
719
- (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
720
- ("00000" + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6)
721
- );
817
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
818
+ ("00000" + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6)
819
+ );
722
820
 
723
821
  length = result.length;
724
822
  while (length--) {
@@ -731,12 +829,12 @@ setTimeout(function(){
731
829
  }
732
830
  // pad milliseconds to have three digits.
733
831
  return (
734
- year + "-" + result.slice(0, 2).join("-") +
735
- "T" + result.slice(2).join(":") + "." +
736
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
737
- );
738
- };
739
- }
832
+ year + "-" + result.slice(0, 2).join("-") +
833
+ "T" + result.slice(2).join(":") + "." +
834
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
835
+ );
836
+ }
837
+ }, hasNegativeDateBug);
740
838
 
741
839
 
742
840
  // ES5 15.9.5.44
@@ -746,15 +844,15 @@ setTimeout(function(){
746
844
  var dateToJSONIsSupported = false;
747
845
  try {
748
846
  dateToJSONIsSupported = (
749
- Date.prototype.toJSON &&
750
- new Date(NaN).toJSON() === null &&
751
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
752
- Date.prototype.toJSON.call({ // generic
753
- toISOString: function () {
754
- return true;
755
- }
756
- })
757
- );
847
+ Date.prototype.toJSON &&
848
+ new Date(NaN).toJSON() === null &&
849
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
850
+ Date.prototype.toJSON.call({ // generic
851
+ toISOString: function () {
852
+ return true;
853
+ }
854
+ })
855
+ );
758
856
  } catch (e) {
759
857
  }
760
858
  if (!dateToJSONIsSupported) {
@@ -762,7 +860,7 @@ setTimeout(function(){
762
860
  // When the toJSON method is called with argument key, the following
763
861
  // steps are taken:
764
862
 
765
- // 1. Let O be the result of calling ToObject, giving it the this
863
+ // 1. Let O be the result of calling ToObject, giving it the this
766
864
  // value as its argument.
767
865
  // 2. Let tv be toPrimitive(O, hint Number).
768
866
  var o = Object(this),
@@ -780,7 +878,7 @@ setTimeout(function(){
780
878
  throw new TypeError("toISOString property is not callable");
781
879
  }
782
880
  // 6. Return the result of calling the [[Call]] internal method of
783
- // toISO with O as the this value and an empty argument list.
881
+ // toISO with O as the this value and an empty argument list.
784
882
  return toISO.call(o);
785
883
 
786
884
  // NOTE 1 The argument is ignored.
@@ -832,26 +930,26 @@ setTimeout(function(){
832
930
 
833
931
  // 15.9.1.15 Date Time String Format.
834
932
  var isoDateExpression = new RegExp("^" +
835
- "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
836
- // 6-digit extended year
837
- "(?:-(\\d{2})" + // optional month capture
838
- "(?:-(\\d{2})" + // optional day capture
839
- "(?:" + // capture hours:minutes:seconds.milliseconds
840
- "T(\\d{2})" + // hours capture
841
- ":(\\d{2})" + // minutes capture
842
- "(?:" + // optional :seconds.milliseconds
843
- ":(\\d{2})" + // seconds capture
844
- "(?:(\\.\\d{1,}))?" + // milliseconds capture
845
- ")?" +
846
- "(" + // capture UTC offset component
847
- "Z|" + // UTC capture
848
- "(?:" + // offset specifier +/-hours:minutes
849
- "([-+])" + // sign capture
850
- "(\\d{2})" + // hours offset capture
851
- ":(\\d{2})" + // minutes offset capture
852
- ")" +
853
- ")?)?)?)?" +
854
- "$");
933
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
934
+ // 6-digit extended year
935
+ "(?:-(\\d{2})" + // optional month capture
936
+ "(?:-(\\d{2})" + // optional day capture
937
+ "(?:" + // capture hours:minutes:seconds.milliseconds
938
+ "T(\\d{2})" + // hours capture
939
+ ":(\\d{2})" + // minutes capture
940
+ "(?:" + // optional :seconds.milliseconds
941
+ ":(\\d{2})" + // seconds capture
942
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
943
+ ")?" +
944
+ "(" + // capture UTC offset component
945
+ "Z|" + // UTC capture
946
+ "(?:" + // offset specifier +/-hours:minutes
947
+ "([-+])" + // sign capture
948
+ "(\\d{2})" + // hours offset capture
949
+ ":(\\d{2})" + // minutes offset capture
950
+ ")" +
951
+ ")?)?)?)?" +
952
+ "$");
855
953
 
856
954
  var months = [
857
955
  0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
@@ -860,12 +958,12 @@ setTimeout(function(){
860
958
  function dayFromMonth(year, month) {
861
959
  var t = month > 1 ? 1 : 0;
862
960
  return (
863
- months[month] +
864
- Math.floor((year - 1969 + t) / 4) -
865
- Math.floor((year - 1901 + t) / 100) +
866
- Math.floor((year - 1601 + t) / 400) +
867
- 365 * (year - 1970)
868
- );
961
+ months[month] +
962
+ Math.floor((year - 1969 + t) / 4) -
963
+ Math.floor((year - 1901 + t) / 100) +
964
+ Math.floor((year - 1601 + t) / 400) +
965
+ 365 * (year - 1970)
966
+ );
869
967
  }
870
968
 
871
969
  function toUTC(t) {
@@ -909,25 +1007,25 @@ setTimeout(function(){
909
1007
  hour < (
910
1008
  minute > 0 || second > 0 || millisecond > 0 ?
911
1009
  24 : 25
912
- ) &&
913
- minute < 60 && second < 60 && millisecond < 1000 &&
914
- month > -1 && month < 12 && hourOffset < 24 &&
915
- minuteOffset < 60 && // detect invalid offsets
916
- day > -1 &&
917
- day < (
918
- dayFromMonth(year, month + 1) -
919
- dayFromMonth(year, month)
920
- )
921
- ) {
1010
+ ) &&
1011
+ minute < 60 && second < 60 && millisecond < 1000 &&
1012
+ month > -1 && month < 12 && hourOffset < 24 &&
1013
+ minuteOffset < 60 && // detect invalid offsets
1014
+ day > -1 &&
1015
+ day < (
1016
+ dayFromMonth(year, month + 1) -
1017
+ dayFromMonth(year, month)
1018
+ )
1019
+ ) {
922
1020
  result = (
923
- (dayFromMonth(year, month) + day) * 24 +
924
- hour +
925
- hourOffset * signOffset
926
- ) * 60;
1021
+ (dayFromMonth(year, month) + day) * 24 +
1022
+ hour +
1023
+ hourOffset * signOffset
1024
+ ) * 60;
927
1025
  result = (
928
- (result + minute + minuteOffset * signOffset) * 60 +
929
- second
930
- ) * 1000 + millisecond;
1026
+ (result + minute + minuteOffset * signOffset) * 60 +
1027
+ second
1028
+ ) * 1000 + millisecond;
931
1029
  if (isLocalTime) {
932
1030
  result = toUTC(result);
933
1031
  }
@@ -960,152 +1058,151 @@ setTimeout(function(){
960
1058
 
961
1059
  // ES5.1 15.7.4.5
962
1060
  // http://es5.github.com/#x15.7.4.5
963
- 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") {
964
- // Hide these variables and functions
965
- (function () {
966
- var base, size, data, i;
967
-
968
- base = 1e7;
969
- size = 6;
970
- data = [0, 0, 0, 0, 0, 0];
971
-
972
- function multiply(n, c) {
973
- var i = -1;
974
- while (++i < size) {
975
- c += n * data[i];
976
- data[i] = c % base;
977
- c = Math.floor(c / base);
978
- }
1061
+ var hasToFixedBugs = NumberPrototype.toFixed && (
1062
+ (0.00008).toFixed(3) !== '0.000'
1063
+ || (0.9).toFixed(0) !== '1'
1064
+ || (1.255).toFixed(2) !== '1.25'
1065
+ || (1000000000000000128).toFixed(0) !== "1000000000000000128"
1066
+ );
1067
+
1068
+ var toFixedHelpers = {
1069
+ base: 1e7,
1070
+ size: 6,
1071
+ data: [0, 0, 0, 0, 0, 0],
1072
+ multiply: function multiply(n, c) {
1073
+ var i = -1;
1074
+ while (++i < toFixedHelpers.size) {
1075
+ c += n * toFixedHelpers.data[i];
1076
+ toFixedHelpers.data[i] = c % toFixedHelpers.base;
1077
+ c = Math.floor(c / toFixedHelpers.base);
979
1078
  }
980
-
981
- function divide(n) {
982
- var i = size, c = 0;
983
- while (--i >= 0) {
984
- c += data[i];
985
- data[i] = Math.floor(c / n);
986
- c = (c % n) * base;
987
- }
1079
+ },
1080
+ divide: function divide(n) {
1081
+ var i = toFixedHelpers.size, c = 0;
1082
+ while (--i >= 0) {
1083
+ c += toFixedHelpers.data[i];
1084
+ toFixedHelpers.data[i] = Math.floor(c / n);
1085
+ c = (c % n) * toFixedHelpers.base;
988
1086
  }
989
-
990
- function numToString() {
991
- var i = size;
992
- var s = '';
993
- while (--i >= 0) {
994
- if (s !== '' || i === 0 || data[i] !== 0) {
995
- var t = String(data[i]);
996
- if (s === '') {
997
- s = t;
998
- } else {
999
- s += '0000000'.slice(0, 7 - t.length) + t;
1000
- }
1087
+ },
1088
+ numToString: function numToString() {
1089
+ var i = toFixedHelpers.size;
1090
+ var s = '';
1091
+ while (--i >= 0) {
1092
+ if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
1093
+ var t = String(toFixedHelpers.data[i]);
1094
+ if (s === '') {
1095
+ s = t;
1096
+ } else {
1097
+ s += '0000000'.slice(0, 7 - t.length) + t;
1001
1098
  }
1002
1099
  }
1003
- return s;
1004
1100
  }
1005
-
1006
- function pow(x, n, acc) {
1007
- return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1101
+ return s;
1102
+ },
1103
+ pow: function pow(x, n, acc) {
1104
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1105
+ },
1106
+ log: function log(x) {
1107
+ var n = 0;
1108
+ while (x >= 4096) {
1109
+ n += 12;
1110
+ x /= 4096;
1008
1111
  }
1009
-
1010
- function log(x) {
1011
- var n = 0;
1012
- while (x >= 4096) {
1013
- n += 12;
1014
- x /= 4096;
1015
- }
1016
- while (x >= 2) {
1017
- n += 1;
1018
- x /= 2;
1019
- }
1020
- return n;
1112
+ while (x >= 2) {
1113
+ n += 1;
1114
+ x /= 2;
1021
1115
  }
1116
+ return n;
1117
+ }
1118
+ };
1022
1119
 
1023
- Number.prototype.toFixed = function toFixed(fractionDigits) {
1024
- var f, x, s, m, e, z, j, k;
1025
-
1026
- // Test for NaN and round fractionDigits down
1027
- f = Number(fractionDigits);
1028
- f = f !== f ? 0 : Math.floor(f);
1120
+ defineProperties(NumberPrototype, {
1121
+ toFixed: function toFixed(fractionDigits) {
1122
+ var f, x, s, m, e, z, j, k;
1029
1123
 
1030
- if (f < 0 || f > 20) {
1031
- throw new RangeError("Number.toFixed called with invalid number of decimals");
1032
- }
1124
+ // Test for NaN and round fractionDigits down
1125
+ f = Number(fractionDigits);
1126
+ f = f !== f ? 0 : Math.floor(f);
1033
1127
 
1034
- x = Number(this);
1128
+ if (f < 0 || f > 20) {
1129
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
1130
+ }
1035
1131
 
1036
- // Test for NaN
1037
- if (x !== x) {
1038
- return "NaN";
1039
- }
1132
+ x = Number(this);
1040
1133
 
1041
- // If it is too big or small, return the string value of the number
1042
- if (x <= -1e21 || x >= 1e21) {
1043
- return String(x);
1044
- }
1134
+ // Test for NaN
1135
+ if (x !== x) {
1136
+ return "NaN";
1137
+ }
1045
1138
 
1046
- s = "";
1139
+ // If it is too big or small, return the string value of the number
1140
+ if (x <= -1e21 || x >= 1e21) {
1141
+ return String(x);
1142
+ }
1047
1143
 
1048
- if (x < 0) {
1049
- s = "-";
1050
- x = -x;
1051
- }
1144
+ s = "";
1052
1145
 
1053
- m = "0";
1054
-
1055
- if (x > 1e-21) {
1056
- // 1e-21 < x < 1e21
1057
- // -70 < log2(x) < 70
1058
- e = log(x * pow(2, 69, 1)) - 69;
1059
- z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1060
- z *= 0x10000000000000; // Math.pow(2, 52);
1061
- e = 52 - e;
1062
-
1063
- // -18 < e < 122
1064
- // x = z / 2 ^ e
1065
- if (e > 0) {
1066
- multiply(0, z);
1067
- j = f;
1068
-
1069
- while (j >= 7) {
1070
- multiply(1e7, 0);
1071
- j -= 7;
1072
- }
1146
+ if (x < 0) {
1147
+ s = "-";
1148
+ x = -x;
1149
+ }
1073
1150
 
1074
- multiply(pow(10, j, 1), 0);
1075
- j = e - 1;
1151
+ m = "0";
1152
+
1153
+ if (x > 1e-21) {
1154
+ // 1e-21 < x < 1e21
1155
+ // -70 < log2(x) < 70
1156
+ e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
1157
+ z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
1158
+ z *= 0x10000000000000; // Math.pow(2, 52);
1159
+ e = 52 - e;
1160
+
1161
+ // -18 < e < 122
1162
+ // x = z / 2 ^ e
1163
+ if (e > 0) {
1164
+ toFixedHelpers.multiply(0, z);
1165
+ j = f;
1166
+
1167
+ while (j >= 7) {
1168
+ toFixedHelpers.multiply(1e7, 0);
1169
+ j -= 7;
1170
+ }
1076
1171
 
1077
- while (j >= 23) {
1078
- divide(1 << 23);
1079
- j -= 23;
1080
- }
1172
+ toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
1173
+ j = e - 1;
1081
1174
 
1082
- divide(1 << j);
1083
- multiply(1, 1);
1084
- divide(2);
1085
- m = numToString();
1086
- } else {
1087
- multiply(0, z);
1088
- multiply(1 << (-e), 0);
1089
- m = numToString() + '0.00000000000000000000'.slice(2, 2 + f);
1175
+ while (j >= 23) {
1176
+ toFixedHelpers.divide(1 << 23);
1177
+ j -= 23;
1090
1178
  }
1179
+
1180
+ toFixedHelpers.divide(1 << j);
1181
+ toFixedHelpers.multiply(1, 1);
1182
+ toFixedHelpers.divide(2);
1183
+ m = toFixedHelpers.numToString();
1184
+ } else {
1185
+ toFixedHelpers.multiply(0, z);
1186
+ toFixedHelpers.multiply(1 << (-e), 0);
1187
+ m = toFixedHelpers.numToString() + '0.00000000000000000000'.slice(2, 2 + f);
1091
1188
  }
1189
+ }
1092
1190
 
1093
- if (f > 0) {
1094
- k = m.length;
1191
+ if (f > 0) {
1192
+ k = m.length;
1095
1193
 
1096
- if (k <= f) {
1097
- m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1098
- } else {
1099
- m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1100
- }
1194
+ if (k <= f) {
1195
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1101
1196
  } else {
1102
- m = s + m;
1197
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1103
1198
  }
1199
+ } else {
1200
+ m = s + m;
1201
+ }
1104
1202
 
1105
- return m;
1106
- };
1107
- }());
1108
- }
1203
+ return m;
1204
+ }
1205
+ }, hasToFixedBugs);
1109
1206
 
1110
1207
 
1111
1208
  //
@@ -1121,26 +1218,26 @@ setTimeout(function(){
1121
1218
  // do not perform the split correctly under obscure conditions.
1122
1219
  // See http://blog.stevenlevithan.com/archives/cross-browser-split
1123
1220
  // I've tested in many browsers and this seems to cover the deviant ones:
1124
- // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1125
- // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1126
- // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1127
- // [undefined, "t", undefined, "e", ...]
1128
- // ''.split(/.?/) should be [], not [""]
1129
- // '.'.split(/()()/) should be ["."], not ["", "", "."]
1130
-
1131
- var string_split = String.prototype.split;
1221
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1222
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1223
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1224
+ // [undefined, "t", undefined, "e", ...]
1225
+ // ''.split(/.?/) should be [], not [""]
1226
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1227
+
1228
+ var string_split = StringPrototype.split;
1132
1229
  if (
1133
1230
  'ab'.split(/(?:ab)*/).length !== 2 ||
1134
- '.'.split(/(.?)(.?)/).length !== 4 ||
1135
- 'tesst'.split(/(s)*/)[1] === "t" ||
1136
- 'test'.split(/(?:)/, -1).length !== 4 ||
1137
- ''.split(/.?/).length ||
1138
- '.'.split(/()()/).length > 1
1139
- ) {
1231
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1232
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1233
+ 'test'.split(/(?:)/, -1).length !== 4 ||
1234
+ ''.split(/.?/).length ||
1235
+ '.'.split(/()()/).length > 1
1236
+ ) {
1140
1237
  (function () {
1141
1238
  var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1142
1239
 
1143
- String.prototype.split = function (separator, limit) {
1240
+ StringPrototype.split = function (separator, limit) {
1144
1241
  var string = this;
1145
1242
  if (separator === void 0 && limit === 0) {
1146
1243
  return [];
@@ -1153,9 +1250,9 @@ setTimeout(function(){
1153
1250
 
1154
1251
  var output = [],
1155
1252
  flags = (separator.ignoreCase ? "i" : "") +
1156
- (separator.multiline ? "m" : "") +
1157
- (separator.extended ? "x" : "") + // Proposed for ES6
1158
- (separator.sticky ? "y" : ""), // Firefox 3+
1253
+ (separator.multiline ? "m" : "") +
1254
+ (separator.extended ? "x" : "") + // Proposed for ES6
1255
+ (separator.sticky ? "y" : ""), // Firefox 3+
1159
1256
  lastLastIndex = 0,
1160
1257
  // Make `global` and avoid `lastIndex` issues by working with a copy
1161
1258
  separator2, match, lastIndex, lastLength;
@@ -1173,7 +1270,7 @@ setTimeout(function(){
1173
1270
  * If other: Type-convert, then use the above rules
1174
1271
  */
1175
1272
  limit = limit === void 0 ?
1176
- -1 >>> 0 : // Math.pow(2, 32) - 1
1273
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1177
1274
  ToUint32(limit);
1178
1275
  while (match = separator.exec(string)) {
1179
1276
  // `separator.lastIndex` is not reliable cross-browser
@@ -1192,7 +1289,7 @@ setTimeout(function(){
1192
1289
  });
1193
1290
  }
1194
1291
  if (match.length > 1 && match.index < string.length) {
1195
- Array.prototype.push.apply(output, match.slice(1));
1292
+ ArrayPrototype.push.apply(output, match.slice(1));
1196
1293
  }
1197
1294
  lastLength = match[0].length;
1198
1295
  lastLastIndex = lastIndex;
@@ -1222,13 +1319,13 @@ setTimeout(function(){
1222
1319
  // elements.
1223
1320
  // "0".split(undefined, 0) -> []
1224
1321
  } else if ("0".split(void 0, 0).length) {
1225
- String.prototype.split = function split(separator, limit) {
1322
+ StringPrototype.split = function split(separator, limit) {
1226
1323
  if (separator === void 0 && limit === 0) { return []; }
1227
1324
  return string_split.call(this, separator, limit);
1228
1325
  };
1229
1326
  }
1230
1327
 
1231
- var str_replace = String.prototype.replace;
1328
+ var str_replace = StringPrototype.replace;
1232
1329
  var replaceReportsGroupsCorrectly = (function () {
1233
1330
  var groups = [];
1234
1331
  'x'.replace(/x(.)?/g, function (match, group) {
@@ -1238,7 +1335,7 @@ setTimeout(function(){
1238
1335
  }());
1239
1336
 
1240
1337
  if (!replaceReportsGroupsCorrectly) {
1241
- String.prototype.replace = function replace(searchValue, replaceValue) {
1338
+ StringPrototype.replace = function replace(searchValue, replaceValue) {
1242
1339
  var isFn = isFunction(replaceValue);
1243
1340
  var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
1244
1341
  if (!isFn || !hasCapturingGroups) {
@@ -1263,22 +1360,17 @@ setTimeout(function(){
1263
1360
  // non-normative section suggesting uniform semantics and it should be
1264
1361
  // normalized across all browsers
1265
1362
  // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1266
- if ("".substr && "0b".substr(-1) !== "b") {
1267
- var string_substr = String.prototype.substr;
1268
- /**
1269
- * Get the substring of a string
1270
- * @param {integer} start where to start the substring
1271
- * @param {integer} length how many characters to return
1272
- * @return {string}
1273
- */
1274
- String.prototype.substr = function substr(start, length) {
1363
+ var string_substr = StringPrototype.substr;
1364
+ var hasNegativeSubstrBug = "".substr && "0b".substr(-1) !== "b";
1365
+ defineProperties(StringPrototype, {
1366
+ substr: function substr(start, length) {
1275
1367
  return string_substr.call(
1276
1368
  this,
1277
1369
  start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1278
1370
  length
1279
1371
  );
1280
- };
1281
- }
1372
+ }
1373
+ }, hasNegativeSubstrBug);
1282
1374
 
1283
1375
  // ES5 15.5.4.20
1284
1376
  // whitespace from: http://es5.github.io/#x15.5.4.20
@@ -1286,21 +1378,20 @@ setTimeout(function(){
1286
1378
  "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1287
1379
  "\u2029\uFEFF";
1288
1380
  var zeroWidth = '\u200b';
1289
- if (!String.prototype.trim || ws.trim() || !zeroWidth.trim()) {
1381
+ var wsRegexChars = "[" + ws + "]";
1382
+ var trimBeginRegexp = new RegExp("^" + wsRegexChars + wsRegexChars + "*");
1383
+ var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + "*$");
1384
+ var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
1385
+ defineProperties(StringPrototype, {
1290
1386
  // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1291
1387
  // http://perfectionkills.com/whitespace-deviations/
1292
- ws = "[" + ws + "]";
1293
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1294
- trimEndRegexp = new RegExp(ws + ws + "*$");
1295
- String.prototype.trim = function trim() {
1388
+ trim: function trim() {
1296
1389
  if (this === void 0 || this === null) {
1297
1390
  throw new TypeError("can't convert " + this + " to object");
1298
1391
  }
1299
- return String(this)
1300
- .replace(trimBeginRegexp, "")
1301
- .replace(trimEndRegexp, "");
1302
- };
1303
- }
1392
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
1393
+ }
1394
+ }, hasTrimWhitespaceBug);
1304
1395
 
1305
1396
  // ES-5 15.1.2.2
1306
1397
  if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
@@ -1316,71 +1407,6 @@ setTimeout(function(){
1316
1407
  }(parseInt));
1317
1408
  }
1318
1409
 
1319
- //
1320
- // Util
1321
- // ======
1322
- //
1323
-
1324
- // ES5 9.4
1325
- // http://es5.github.com/#x9.4
1326
- // http://jsperf.com/to-integer
1327
-
1328
- function toInteger(n) {
1329
- n = +n;
1330
- if (n !== n) { // isNaN
1331
- n = 0;
1332
- } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1333
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
1334
- }
1335
- return n;
1336
- }
1337
-
1338
- function isPrimitive(input) {
1339
- var type = typeof input;
1340
- return (
1341
- input === null ||
1342
- type === "undefined" ||
1343
- type === "boolean" ||
1344
- type === "number" ||
1345
- type === "string"
1346
- );
1347
- }
1348
-
1349
- function toPrimitive(input) {
1350
- var val, valueOf, toStr;
1351
- if (isPrimitive(input)) {
1352
- return input;
1353
- }
1354
- valueOf = input.valueOf;
1355
- if (isFunction(valueOf)) {
1356
- val = valueOf.call(input);
1357
- if (isPrimitive(val)) {
1358
- return val;
1359
- }
1360
- }
1361
- toStr = input.toString;
1362
- if (isFunction(toStr)) {
1363
- val = toStr.call(input);
1364
- if (isPrimitive(val)) {
1365
- return val;
1366
- }
1367
- }
1368
- throw new TypeError();
1369
- }
1370
-
1371
- // ES5 9.9
1372
- // http://es5.github.com/#x9.9
1373
- var toObject = function (o) {
1374
- if (o == null) { // this matches both null and undefined
1375
- throw new TypeError("can't convert " + o + " to object");
1376
- }
1377
- return Object(o);
1378
- };
1379
-
1380
- var ToUint32 = function ToUint32(x) {
1381
- return x >>> 0;
1382
- };
1383
-
1384
1410
  })();
1385
1411
 
1386
1412