From 059446f536f9e6af387b06a736a0d3a60bc41908 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 17 Dec 2015 18:28:37 +0600 Subject: [PATCH] remove `arguments` shortcuts - old webkit bug, close #150 --- library/modules/_array-copy-within.js | 3 +-- library/modules/_array-fill.js | 7 +++---- library/modules/_object-assign.js | 7 +++---- library/modules/_partial.js | 11 +++++------ library/modules/_typed-array.js | 7 +++---- library/modules/es6.array.from.js | 7 +++---- library/modules/es6.array.of.js | 9 ++++----- library/modules/es6.math.hypot.js | 13 ++++++------- library/modules/es6.string.ends-with.js | 3 +-- library/modules/es6.string.from-code-point.js | 11 +++++------ library/modules/es6.string.raw.js | 13 ++++++------- library/modules/es6.string.starts-with.js | 3 +-- library/modules/es6.symbol.js | 3 +-- modules/_array-copy-within.js | 3 +-- modules/_array-fill.js | 7 +++---- modules/_object-assign.js | 7 +++---- modules/_partial.js | 11 +++++------ modules/_typed-array.js | 7 +++---- modules/es6.array.from.js | 7 +++---- modules/es6.array.of.js | 9 ++++----- modules/es6.math.hypot.js | 13 ++++++------- modules/es6.string.ends-with.js | 3 +-- modules/es6.string.from-code-point.js | 11 +++++------ modules/es6.string.raw.js | 13 ++++++------- modules/es6.string.starts-with.js | 3 +-- modules/es6.symbol.js | 3 +-- 26 files changed, 84 insertions(+), 110 deletions(-) diff --git a/library/modules/_array-copy-within.js b/library/modules/_array-copy-within.js index f81d3d17f9e4..d901a32f5fc6 100644 --- a/library/modules/_array-copy-within.js +++ b/library/modules/_array-copy-within.js @@ -9,8 +9,7 @@ module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, , len = toLength(O.length) , to = toIndex(target, len) , from = toIndex(start, len) - , $$ = arguments - , end = $$.length > 2 ? $$[2] : undefined + , end = arguments.length > 2 ? arguments[2] : undefined , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to) , inc = 1; if(from < to && to < from + count){ diff --git a/library/modules/_array-fill.js b/library/modules/_array-fill.js index c5155f81f7f0..b21bb7edd385 100644 --- a/library/modules/_array-fill.js +++ b/library/modules/_array-fill.js @@ -6,10 +6,9 @@ var toObject = require('./_to-object') module.exports = function fill(value /*, start = 0, end = @length */){ var O = toObject(this) , length = toLength(O.length) - , $$ = arguments - , $$len = $$.length - , index = toIndex($$len > 1 ? $$[1] : undefined, length) - , end = $$len > 2 ? $$[2] : undefined + , aLen = arguments.length + , index = toIndex(aLen > 1 ? arguments[1] : undefined, length) + , end = aLen > 2 ? arguments[2] : undefined , endPos = end === undefined ? length : toIndex(end, length); while(endPos > index)O[index++] = value; return O; diff --git a/library/modules/_object-assign.js b/library/modules/_object-assign.js index ee42eb8a3a7e..5dadb23a99da 100644 --- a/library/modules/_object-assign.js +++ b/library/modules/_object-assign.js @@ -15,14 +15,13 @@ module.exports = require('./_fails')(function(){ return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; }) ? function assign(target, source){ // eslint-disable-line no-unused-vars var T = toObject(target) - , $$ = arguments - , $$len = $$.length + , aLen = arguments.length , index = 1 , getKeys = $.getKeys , getSymbols = $.getSymbols , isEnum = $.isEnum; - while($$len > index){ - var S = IObject($$[index++]) + while(aLen > index){ + var S = IObject(arguments[index++]) , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) , length = keys.length , j = 0 diff --git a/library/modules/_partial.js b/library/modules/_partial.js index 885211ea3026..3d411b705de6 100644 --- a/library/modules/_partial.js +++ b/library/modules/_partial.js @@ -11,14 +11,13 @@ module.exports = function(/* ...pargs */){ , holder = false; while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true; return function(/* ...args */){ - var that = this - , $$ = arguments - , $$len = $$.length + var that = this + , aLen = arguments.length , j = 0, k = 0, args; - if(!holder && !$$len)return invoke(fn, pargs, that); + if(!holder && !aLen)return invoke(fn, pargs, that); args = pargs.slice(); - if(holder)for(;length > j; j++)if(args[j] === _)args[j] = $$[k++]; - while($$len > k)args.push($$[k++]); + if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++]; + while(aLen > k)args.push(arguments[k++]); return invoke(fn, args, that); }; }; \ No newline at end of file diff --git a/library/modules/_typed-array.js b/library/modules/_typed-array.js index 19bfaee8ebc6..f53625463b0e 100644 --- a/library/modules/_typed-array.js +++ b/library/modules/_typed-array.js @@ -128,9 +128,8 @@ if(require('./_descriptors')){ var $from = function from(source /*, mapfn, thisArg */){ var O = toObject(source) - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined , mapping = mapfn !== undefined , iterFn = getIterFn(O) , i, length, values, result, step, iterator; @@ -139,7 +138,7 @@ if(require('./_descriptors')){ values.push(step.value); } O = values; } - if(mapping && $$len > 2)mapfn = ctx(mapfn, $$[2], 2); + if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2); for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){ result[i] = mapping ? mapfn(O[i], i) : O[i]; } diff --git a/library/modules/es6.array.from.js b/library/modules/es6.array.from.js index d4026bede651..739f12d8284a 100644 --- a/library/modules/es6.array.from.js +++ b/library/modules/es6.array.from.js @@ -11,14 +11,13 @@ $export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ var O = toObject(arrayLike) , C = typeof this == 'function' ? this : Array - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined , mapping = mapfn !== undefined , index = 0 , iterFn = getIterFn(O) , length, result, step, iterator; - if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); + if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ diff --git a/library/modules/es6.array.of.js b/library/modules/es6.array.of.js index 78daae631f9c..f5cba5d688af 100644 --- a/library/modules/es6.array.of.js +++ b/library/modules/es6.array.of.js @@ -9,11 +9,10 @@ $export($export.S + $export.F * require('./_fails')(function(){ // 22.1.2.3 Array.of( ...items) of: function of(/* ...args */){ var index = 0 - , $$ = arguments - , $$len = $$.length - , result = new (typeof this == 'function' ? this : Array)($$len); - while($$len > index)result[index] = $$[index++]; - result.length = $$len; + , aLen = arguments.length + , result = new (typeof this == 'function' ? this : Array)(aLen); + while(aLen > index)result[index] = arguments[index++]; + result.length = aLen; return result; } }); \ No newline at end of file diff --git a/library/modules/es6.math.hypot.js b/library/modules/es6.math.hypot.js index 9414562affd1..508521b69da8 100644 --- a/library/modules/es6.math.hypot.js +++ b/library/modules/es6.math.hypot.js @@ -4,14 +4,13 @@ var $export = require('./_export') $export($export.S, 'Math', { hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars - var sum = 0 - , i = 0 - , $$ = arguments - , $$len = $$.length - , larg = 0 + var sum = 0 + , i = 0 + , aLen = arguments.length + , larg = 0 , arg, div; - while(i < $$len){ - arg = abs($$[i++]); + while(i < aLen){ + arg = abs(arguments[i++]); if(larg < arg){ div = larg / arg; sum = sum * div * div + 1; diff --git a/library/modules/es6.string.ends-with.js b/library/modules/es6.string.ends-with.js index 54f518bfd425..80baed9ad81d 100644 --- a/library/modules/es6.string.ends-with.js +++ b/library/modules/es6.string.ends-with.js @@ -9,8 +9,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', { endsWith: function endsWith(searchString /*, endPosition = @length */){ var that = context(this, searchString, ENDS_WITH) - , $$ = arguments - , endPosition = $$.length > 1 ? $$[1] : undefined + , endPosition = arguments.length > 1 ? arguments[1] : undefined , len = toLength(that.length) , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len) , search = String(searchString); diff --git a/library/modules/es6.string.from-code-point.js b/library/modules/es6.string.from-code-point.js index c12edb9e19e9..c8776d871104 100644 --- a/library/modules/es6.string.from-code-point.js +++ b/library/modules/es6.string.from-code-point.js @@ -7,13 +7,12 @@ var $export = require('./_export') $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { // 21.1.2.2 String.fromCodePoint(...codePoints) fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars - var res = [] - , $$ = arguments - , $$len = $$.length - , i = 0 + var res = [] + , aLen = arguments.length + , i = 0 , code; - while($$len > i){ - code = +$$[i++]; + while(aLen > i){ + code = +arguments[i++]; if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point'); res.push(code < 0x10000 ? fromCharCode(code) diff --git a/library/modules/es6.string.raw.js b/library/modules/es6.string.raw.js index b0b9dbea236c..1016acfa2e7e 100644 --- a/library/modules/es6.string.raw.js +++ b/library/modules/es6.string.raw.js @@ -5,15 +5,14 @@ var $export = require('./_export') $export($export.S, 'String', { // 21.1.2.4 String.raw(callSite, ...substitutions) raw: function raw(callSite){ - var tpl = toIObject(callSite.raw) - , len = toLength(tpl.length) - , $$ = arguments - , $$len = $$.length - , res = [] - , i = 0; + var tpl = toIObject(callSite.raw) + , len = toLength(tpl.length) + , aLen = arguments.length + , res = [] + , i = 0; while(len > i){ res.push(String(tpl[i++])); - if(i < $$len)res.push(String($$[i])); + if(i < aLen)res.push(String(arguments[i])); } return res.join(''); } }); \ No newline at end of file diff --git a/library/modules/es6.string.starts-with.js b/library/modules/es6.string.starts-with.js index 8e44eef1dcc5..017805f01994 100644 --- a/library/modules/es6.string.starts-with.js +++ b/library/modules/es6.string.starts-with.js @@ -9,8 +9,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', { startsWith: function startsWith(searchString /*, position = 0 */){ var that = context(this, searchString, STARTS_WITH) - , $$ = arguments - , index = toLength(Math.min($$.length > 1 ? $$[1] : undefined, that.length)) + , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length)) , search = String(searchString); return $startsWith ? $startsWith.call(that, search, index) diff --git a/library/modules/es6.symbol.js b/library/modules/es6.symbol.js index 79481a48b51e..615acc74e241 100644 --- a/library/modules/es6.symbol.js +++ b/library/modules/es6.symbol.js @@ -117,9 +117,8 @@ var $stringify = function stringify(it){ if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined var args = [it] , i = 1 - , $$ = arguments , replacer, $replacer; - while($$.length > i)args.push($$[i++]); + while(arguments.length > i)args.push(arguments[i++]); replacer = args[1]; if(typeof replacer == 'function')$replacer = replacer; if($replacer || !isArray(replacer))replacer = function(key, value){ diff --git a/modules/_array-copy-within.js b/modules/_array-copy-within.js index f81d3d17f9e4..d901a32f5fc6 100644 --- a/modules/_array-copy-within.js +++ b/modules/_array-copy-within.js @@ -9,8 +9,7 @@ module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, , len = toLength(O.length) , to = toIndex(target, len) , from = toIndex(start, len) - , $$ = arguments - , end = $$.length > 2 ? $$[2] : undefined + , end = arguments.length > 2 ? arguments[2] : undefined , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to) , inc = 1; if(from < to && to < from + count){ diff --git a/modules/_array-fill.js b/modules/_array-fill.js index c5155f81f7f0..b21bb7edd385 100644 --- a/modules/_array-fill.js +++ b/modules/_array-fill.js @@ -6,10 +6,9 @@ var toObject = require('./_to-object') module.exports = function fill(value /*, start = 0, end = @length */){ var O = toObject(this) , length = toLength(O.length) - , $$ = arguments - , $$len = $$.length - , index = toIndex($$len > 1 ? $$[1] : undefined, length) - , end = $$len > 2 ? $$[2] : undefined + , aLen = arguments.length + , index = toIndex(aLen > 1 ? arguments[1] : undefined, length) + , end = aLen > 2 ? arguments[2] : undefined , endPos = end === undefined ? length : toIndex(end, length); while(endPos > index)O[index++] = value; return O; diff --git a/modules/_object-assign.js b/modules/_object-assign.js index ee42eb8a3a7e..5dadb23a99da 100644 --- a/modules/_object-assign.js +++ b/modules/_object-assign.js @@ -15,14 +15,13 @@ module.exports = require('./_fails')(function(){ return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; }) ? function assign(target, source){ // eslint-disable-line no-unused-vars var T = toObject(target) - , $$ = arguments - , $$len = $$.length + , aLen = arguments.length , index = 1 , getKeys = $.getKeys , getSymbols = $.getSymbols , isEnum = $.isEnum; - while($$len > index){ - var S = IObject($$[index++]) + while(aLen > index){ + var S = IObject(arguments[index++]) , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) , length = keys.length , j = 0 diff --git a/modules/_partial.js b/modules/_partial.js index 885211ea3026..3d411b705de6 100644 --- a/modules/_partial.js +++ b/modules/_partial.js @@ -11,14 +11,13 @@ module.exports = function(/* ...pargs */){ , holder = false; while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true; return function(/* ...args */){ - var that = this - , $$ = arguments - , $$len = $$.length + var that = this + , aLen = arguments.length , j = 0, k = 0, args; - if(!holder && !$$len)return invoke(fn, pargs, that); + if(!holder && !aLen)return invoke(fn, pargs, that); args = pargs.slice(); - if(holder)for(;length > j; j++)if(args[j] === _)args[j] = $$[k++]; - while($$len > k)args.push($$[k++]); + if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++]; + while(aLen > k)args.push(arguments[k++]); return invoke(fn, args, that); }; }; \ No newline at end of file diff --git a/modules/_typed-array.js b/modules/_typed-array.js index 19bfaee8ebc6..f53625463b0e 100644 --- a/modules/_typed-array.js +++ b/modules/_typed-array.js @@ -128,9 +128,8 @@ if(require('./_descriptors')){ var $from = function from(source /*, mapfn, thisArg */){ var O = toObject(source) - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined , mapping = mapfn !== undefined , iterFn = getIterFn(O) , i, length, values, result, step, iterator; @@ -139,7 +138,7 @@ if(require('./_descriptors')){ values.push(step.value); } O = values; } - if(mapping && $$len > 2)mapfn = ctx(mapfn, $$[2], 2); + if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2); for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){ result[i] = mapping ? mapfn(O[i], i) : O[i]; } diff --git a/modules/es6.array.from.js b/modules/es6.array.from.js index d4026bede651..739f12d8284a 100644 --- a/modules/es6.array.from.js +++ b/modules/es6.array.from.js @@ -11,14 +11,13 @@ $export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ var O = toObject(arrayLike) , C = typeof this == 'function' ? this : Array - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined , mapping = mapfn !== undefined , index = 0 , iterFn = getIterFn(O) , length, result, step, iterator; - if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); + if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ diff --git a/modules/es6.array.of.js b/modules/es6.array.of.js index 78daae631f9c..f5cba5d688af 100644 --- a/modules/es6.array.of.js +++ b/modules/es6.array.of.js @@ -9,11 +9,10 @@ $export($export.S + $export.F * require('./_fails')(function(){ // 22.1.2.3 Array.of( ...items) of: function of(/* ...args */){ var index = 0 - , $$ = arguments - , $$len = $$.length - , result = new (typeof this == 'function' ? this : Array)($$len); - while($$len > index)result[index] = $$[index++]; - result.length = $$len; + , aLen = arguments.length + , result = new (typeof this == 'function' ? this : Array)(aLen); + while(aLen > index)result[index] = arguments[index++]; + result.length = aLen; return result; } }); \ No newline at end of file diff --git a/modules/es6.math.hypot.js b/modules/es6.math.hypot.js index 9414562affd1..508521b69da8 100644 --- a/modules/es6.math.hypot.js +++ b/modules/es6.math.hypot.js @@ -4,14 +4,13 @@ var $export = require('./_export') $export($export.S, 'Math', { hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars - var sum = 0 - , i = 0 - , $$ = arguments - , $$len = $$.length - , larg = 0 + var sum = 0 + , i = 0 + , aLen = arguments.length + , larg = 0 , arg, div; - while(i < $$len){ - arg = abs($$[i++]); + while(i < aLen){ + arg = abs(arguments[i++]); if(larg < arg){ div = larg / arg; sum = sum * div * div + 1; diff --git a/modules/es6.string.ends-with.js b/modules/es6.string.ends-with.js index 54f518bfd425..80baed9ad81d 100644 --- a/modules/es6.string.ends-with.js +++ b/modules/es6.string.ends-with.js @@ -9,8 +9,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', { endsWith: function endsWith(searchString /*, endPosition = @length */){ var that = context(this, searchString, ENDS_WITH) - , $$ = arguments - , endPosition = $$.length > 1 ? $$[1] : undefined + , endPosition = arguments.length > 1 ? arguments[1] : undefined , len = toLength(that.length) , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len) , search = String(searchString); diff --git a/modules/es6.string.from-code-point.js b/modules/es6.string.from-code-point.js index c12edb9e19e9..c8776d871104 100644 --- a/modules/es6.string.from-code-point.js +++ b/modules/es6.string.from-code-point.js @@ -7,13 +7,12 @@ var $export = require('./_export') $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { // 21.1.2.2 String.fromCodePoint(...codePoints) fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars - var res = [] - , $$ = arguments - , $$len = $$.length - , i = 0 + var res = [] + , aLen = arguments.length + , i = 0 , code; - while($$len > i){ - code = +$$[i++]; + while(aLen > i){ + code = +arguments[i++]; if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point'); res.push(code < 0x10000 ? fromCharCode(code) diff --git a/modules/es6.string.raw.js b/modules/es6.string.raw.js index b0b9dbea236c..1016acfa2e7e 100644 --- a/modules/es6.string.raw.js +++ b/modules/es6.string.raw.js @@ -5,15 +5,14 @@ var $export = require('./_export') $export($export.S, 'String', { // 21.1.2.4 String.raw(callSite, ...substitutions) raw: function raw(callSite){ - var tpl = toIObject(callSite.raw) - , len = toLength(tpl.length) - , $$ = arguments - , $$len = $$.length - , res = [] - , i = 0; + var tpl = toIObject(callSite.raw) + , len = toLength(tpl.length) + , aLen = arguments.length + , res = [] + , i = 0; while(len > i){ res.push(String(tpl[i++])); - if(i < $$len)res.push(String($$[i])); + if(i < aLen)res.push(String(arguments[i])); } return res.join(''); } }); \ No newline at end of file diff --git a/modules/es6.string.starts-with.js b/modules/es6.string.starts-with.js index 8e44eef1dcc5..017805f01994 100644 --- a/modules/es6.string.starts-with.js +++ b/modules/es6.string.starts-with.js @@ -9,8 +9,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', { startsWith: function startsWith(searchString /*, position = 0 */){ var that = context(this, searchString, STARTS_WITH) - , $$ = arguments - , index = toLength(Math.min($$.length > 1 ? $$[1] : undefined, that.length)) + , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length)) , search = String(searchString); return $startsWith ? $startsWith.call(that, search, index) diff --git a/modules/es6.symbol.js b/modules/es6.symbol.js index 79481a48b51e..615acc74e241 100644 --- a/modules/es6.symbol.js +++ b/modules/es6.symbol.js @@ -117,9 +117,8 @@ var $stringify = function stringify(it){ if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined var args = [it] , i = 1 - , $$ = arguments , replacer, $replacer; - while($$.length > i)args.push($$[i++]); + while(arguments.length > i)args.push(arguments[i++]); replacer = args[1]; if(typeof replacer == 'function')$replacer = replacer; if($replacer || !isArray(replacer))replacer = function(key, value){