diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-01-16 18:31:17 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-01-16 18:31:17 +0100 |
commit | c39799d24b7610f3dd0f5c718ac4fce77f25db25 (patch) | |
tree | 2e4253fcf0e628f1c0688dfb0a85203f0a3aaaf2 /js/vendor/es6-shim | |
parent | f7d566c54c8cb80dc5425eb8d7d48ea02196bf7e (diff) |
udpate js client deps
Diffstat (limited to 'js/vendor/es6-shim')
-rw-r--r-- | js/vendor/es6-shim/.bower.json | 8 | ||||
-rw-r--r-- | js/vendor/es6-shim/CHANGELOG.md | 52 | ||||
-rw-r--r-- | js/vendor/es6-shim/README.md | 25 | ||||
-rw-r--r-- | js/vendor/es6-shim/component.json | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.js | 8 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.min.js | 4 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.js | 890 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.map | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.min.js | 8 | ||||
-rw-r--r-- | js/vendor/es6-shim/package.json | 54 | ||||
-rw-r--r-- | js/vendor/es6-shim/testling.html | 3 |
11 files changed, 741 insertions, 315 deletions
diff --git a/js/vendor/es6-shim/.bower.json b/js/vendor/es6-shim/.bower.json index 00499dbf6..64bfdaef8 100644 --- a/js/vendor/es6-shim/.bower.json +++ b/js/vendor/es6-shim/.bower.json @@ -27,12 +27,12 @@ "test" ], "homepage": "https://github.com/paulmillr/es6-shim", - "version": "0.33.12", - "_release": "0.33.12", + "version": "0.34.1", + "_release": "0.34.1", "_resolution": { "type": "version", - "tag": "0.33.12", - "commit": "2fc76e7c759cbc1643722bc21132e246f935d4e1" + "tag": "0.34.1", + "commit": "2ab34d846693b4853205873e31cdc961281cb477" }, "_source": "git://github.com/paulmillr/es6-shim.git", "_target": "~0.*", diff --git a/js/vendor/es6-shim/CHANGELOG.md b/js/vendor/es6-shim/CHANGELOG.md index 244cd55d0..5a5768257 100644 --- a/js/vendor/es6-shim/CHANGELOG.md +++ b/js/vendor/es6-shim/CHANGELOG.md @@ -1,5 +1,57 @@ # es6-shim x.x.x (not yet released) +# es6-shim 0.34.1 (5 Jan 2016) +* [Fix] `RegExp#[Symbol.search]` was broken with a regex argument (#394) +* [Fix] ensure that Set#clear works with both primitive and object values +* [Fix] static Promise methods have the wrong length in Firefox +* [Robustness] Cache `Object.keys` +* [Performance] Avoid accessing arguments array without length check +* [Performance] Optimize ES.TypeIsObject (#388) +* [Performance] Promises: lots of improvements (#383) +* [Performance] Only use slow implementation of IsCallable where necessary (old browsers) +* [Performance] Promises: remove unnecessary `.bind` on `setImmediate` +* [Refactor] extract “decode fast Map key” logic +* [Dev Deps] update `s5-shim`, `@ljharb/eslint-config` +* Don’t npmignore tests +* [Tests] Fix a bug with “deep equal” wrt NaN +* [Tests] split up Map and Set test files +* [Tests] up to `node` `v5.3` + +# es6-shim 0.34.0 (14 Dec 2015) +* [Breaking] Remove `Symbol.species` from `Promise.all` and `Promise.race` (#34) +* [Fix] Firefox has enumerable Promise static methods +* [Fix] prevent crashes in older Firefox when checking if Array methods ToLength correctly +* [Fix] `Reflect.enumerate`: ensure correct property ordering in Firefox 19 (and likely others) +* [Fix] Ensure that `toLengthsCorrectly` returns `true` when it passes, instead of `undefined` +* [Fix] Don't call `Reflect.construct` unless it's actually present +* [Fix] Ensure `Map` and `Set` do not have an own `constructor` property (#368) +* [Fix] Add missing checks to Promise.resolve and Promise.reject (#379) +* [Fix] `Map`: older v8s have a SameValueZero bug when a Map has a size > 4 (#378) +* [Fix] `Map`: when provided with an iterable that yields non-Object values, should throw +* [Fix] `Promise`: Make sure to shim broken implementations in Chrome 49 Canary +* [Fix] `Promise`: Chrome does not retrieve a thenable's .then synchronously (#372) +* [New] Add `RegExp.prototype[Symbol.{match,search,split,replace}]` +* [New] support `Symbol.match` in `RegExp` constructor +* [New] add `Symbol.match` and ensure `String#{match, startsWith, endsWith, includes}` support it +* [New] add `Symbol.split` and ensure `String#split` supports it +* [New] add `Symbol.replace` and ensure `String#replace` supports it +* [New] add `Symbol.search` and ensure `String#search` supports it +* [Robustness] Add and use `ES.ToString` so as not to rely on the global `String` +* [Dev Deps] update `eslint`, `jscs`, `mocha`, `uglify-js`, `es5-shim`, `grunt-saucelabs` +* [Tests] bailing out of some tests when the feature isn't present, to clean up native test failure output +* [Tests] up to `node` `v5.2` +* [Tests] fix `npm run test:native` +* [Tests] Ensure `Promise.{reject,resolve}` throws when the receiver is a primitive (#379) +* [Tests] Further ensure that Promise.resolve/reject work with a non-promise receiver (#379) +* [Docs] update README URLs (#375) +* [Docs] fix some typos (#380) + +# es6-shim 0.33.13 (12 Nov 2015) +* [Fix] `Number`: when no arguments are passed, return `+0`. +* [Fix] `Number`: Make sure string values are trimmed before attempting to parse. +* [Tests] cleaning up `Number` tests) +* [Dev Deps] update `uglify-js` + # es6-shim 0.33.12 (11 Nov 2015) * [Fix] IE 8: more NFE madness. * [Dev Deps] update `es5-shim` diff --git a/js/vendor/es6-shim/README.md b/js/vendor/es6-shim/README.md index 5a0955674..6d37667ba 100644 --- a/js/vendor/es6-shim/README.md +++ b/js/vendor/es6-shim/README.md @@ -21,7 +21,7 @@ For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended m npm install es6-shim Alternative methods: -* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/component/component). +* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/componentjs/component). * `bower install es6-shim` if you’re using [Bower](http://bower.io/). In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details. @@ -43,20 +43,24 @@ In both browser and node you may also want to include `unorm`; see the [`String. * `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5) * `RegExp.prototype`: * `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags)) + * `[Symbol.match]` (requires native `Symbol`s) + * `[Symbol.replace]` (requires native `Symbol`s) + * `[Symbol.search]` (requires native `Symbol`s) + * `[Symbol.split]` (requires native `Symbol`s) * `Number`: * binary and octal literals: `Number('0b1')` and `Number('0o7')` * `EPSILON` * `MAX_SAFE_INTEGER` * `MIN_SAFE_INTEGER` - * `isNaN()`([a standalone shim is also available](https://npmjs.org/package/is-nan)) + * `isNaN()`([a standalone shim is also available](https://www.npmjs.com/package/is-nan)) * `isInteger()` * `isSafeInteger()` * `isFinite()` * `parseInt()` * `parseFloat()` * `Array`: - * `from()` ([a standalone shim is also available](https://npmjs.org/package/array.from)) - * `of()` ([a standalone shim is also available](https://npmjs.org/package/array.of)) + * `from()` ([a standalone shim is also available](https://www.npmjs.com/package/array.from)) + * `of()` ([a standalone shim is also available](https://www.npmjs.com/package/array.of)) * `Array.prototype`: * `copyWithin()` * `entries()` @@ -107,8 +111,15 @@ Math functions’ accuracy is 1e-11. * `set()` * `setPrototypeOf()` +* `Symbol` (only if it already exists) + * `match` (and corresponding `String#match`, `String#startsWith`, `String#endsWith`, `String#includes`, `RegExp` support) + * `replace` (and corresponding `String#replace` support) + * `search` (and corresponding `String#search` support) + * `split` (and corresponding `String#split` support) + +Well-known symbols will only be provided if the engine already has `Symbol` support. + * `String.prototype` Annex B HTML methods -These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them: * `anchor()` * `big()` * `blink()` @@ -123,6 +134,8 @@ These methods are part of "Annex B", which means that although they are a defact * `sub()` * `sup()` +These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them and normalizes their behavior across browsers. + ## Subclassing The `Map`, `Set`, and `Promise` implementations are subclassable. You should use the following pattern to create a subclass in ES5 which will continue to work in ES6: @@ -237,6 +250,8 @@ Promise.resolve(5).then(function (value) { - `Object.setPrototypeOf` / `Reflect.setPrototypeOf` - Note that null objects (`Object.create(null)`, eg, an object with `null` as its `[[Prototype]]`) can not have their `[[Prototype]]` changed except via a native `Object.setPrototypeOf`. + - Well-known `Symbol`s + - In order to make them work cross-realm, these are created with the global `Symbol` registry via `Symbol.for`. This does not violate the spec, but it does mean that `Symbol.for('Symbol.search') === Symbol.search` will be `true`, which it would not by default in a fresh compliant realm. ## [License][license-url] diff --git a/js/vendor/es6-shim/component.json b/js/vendor/es6-shim/component.json index c0f5fbcd0..c971adf1d 100644 --- a/js/vendor/es6-shim/component.json +++ b/js/vendor/es6-shim/component.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.33.12", + "version": "0.34.1", "repo": "paulmillr/es6-shim", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ diff --git a/js/vendor/es6-shim/es6-sham.js b/js/vendor/es6-shim/es6-sham.js index 65f0f5cc6..7e49121ae 100644 --- a/js/vendor/es6-shim/es6-sham.js +++ b/js/vendor/es6-shim/es6-sham.js @@ -2,8 +2,8 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-sham: v0.33.12 - * see https://github.com/paulmillr/es6-shim/blob/0.33.12/LICENSE + * es6-sham: v0.34.1 + * see https://github.com/paulmillr/es6-shim/blob/0.34.1/LICENSE * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ @@ -17,7 +17,7 @@ define(factory); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but - // only CommonJS-like enviroments that support module.exports, + // only CommonJS-like environments that support module.exports, // like Node. module.exports = factory(); } else { @@ -37,7 +37,7 @@ var Object = globals.Object; // NOTE: This versions needs object ownership - // beacuse every promoted object needs to be reassigned + // because every promoted object needs to be reassigned // otherwise uncompatible browsers cannot work as expected // // NOTE: This might need es5-shim or polyfills upfront diff --git a/js/vendor/es6-shim/es6-sham.min.js b/js/vendor/es6-shim/es6-sham.min.js index a0f862efe..1dda0d0ec 100644 --- a/js/vendor/es6-shim/es6-sham.min.js +++ b/js/vendor/es6-shim/es6-sham.min.js @@ -2,8 +2,8 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-sham: v0.33.12 - * see https://github.com/paulmillr/es6-shim/blob/0.33.12/LICENSE + * es6-sham: v0.34.1 + * see https://github.com/paulmillr/es6-shim/blob/0.34.1/LICENSE * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ diff --git a/js/vendor/es6-shim/es6-shim.js b/js/vendor/es6-shim/es6-shim.js index d1d052fe3..f6058ae2d 100644 --- a/js/vendor/es6-shim/es6-shim.js +++ b/js/vendor/es6-shim/es6-shim.js @@ -2,8 +2,8 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-shim: v0.33.12 - * see https://github.com/paulmillr/es6-shim/blob/0.33.12/LICENSE + * es6-shim: v0.34.1 + * see https://github.com/paulmillr/es6-shim/blob/0.34.1/LICENSE * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ @@ -17,7 +17,7 @@ define(factory); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but - // only CommonJS-like enviroments that support module.exports, + // only CommonJS-like environments that support module.exports, // like Node. module.exports = factory(); } else { @@ -30,6 +30,7 @@ var _apply = Function.call.bind(Function.apply); var _call = Function.call.bind(Function.call); var isArray = Array.isArray; + var keys = Object.keys; var not = function notThunker(func) { return function notThunk() { return !_apply(func, this, arguments); }; @@ -79,13 +80,65 @@ // Define configurable, writable and non-enumerable props // if they don’t exist. - var defineProperties = function (object, map) { - _forEach(Object.keys(map), function (name) { + var defineProperties = function (object, map, forceOverride) { + _forEach(keys(map), function (name) { var method = map[name]; - defineProperty(object, name, method, false); + defineProperty(object, name, method, !!forceOverride); }); }; + var _toString = Function.call.bind(Object.prototype.toString); + var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) { + // Some old browsers (IE, FF) say that typeof /abc/ === 'function' + return typeof x === 'function' && _toString(x) === '[object Function]'; + } : function IsCallableFast(x) { return typeof x === 'function'; }; + + var Value = { + getter: function (object, name, getter) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + get: getter + }); + }, + proxy: function (originalObject, key, targetObject) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); + Object.defineProperty(targetObject, key, { + configurable: originalDescriptor.configurable, + enumerable: originalDescriptor.enumerable, + get: function getKey() { return originalObject[key]; }, + set: function setKey(value) { originalObject[key] = value; } + }); + }, + redefine: function (object, property, newValue) { + if (supportsDescriptors) { + var descriptor = Object.getOwnPropertyDescriptor(object, property); + descriptor.value = newValue; + Object.defineProperty(object, property, descriptor); + } else { + object[property] = newValue; + } + }, + defineByDescriptor: function (object, property, descriptor) { + if (supportsDescriptors) { + Object.defineProperty(object, property, descriptor); + } else if ('value' in descriptor) { + object[property] = descriptor.value; + } + }, + preserveToString: function (target, source) { + if (source && isCallable(source.toString)) { + defineProperty(target, 'toString', source.toString.bind(source), true); + } + } + }; + // Simple shim for Object.create on ES3 browsers // (unlike real shim, no attempt to support `prototype === null`) var create = Object.create || function (prototype, properties) { @@ -93,7 +146,7 @@ Prototype.prototype = prototype; var object = new Prototype(); if (typeof properties !== 'undefined') { - Object.keys(properties).forEach(function (key) { + keys(properties).forEach(function (key) { Value.defineByDescriptor(object, key, properties[key]); }); } @@ -130,8 +183,8 @@ var globals = getGlobal(); var globalIsFinite = globals.isFinite; var _indexOf = Function.call.bind(String.prototype.indexOf); - var _toString = Function.call.bind(Object.prototype.toString); var _concat = Function.call.bind(Array.prototype.concat); + var _sort = Function.call.bind(Array.prototype.sort); var _strSlice = Function.call.bind(String.prototype.slice); var _push = Function.call.bind(Array.prototype.push); var _pushApply = Function.apply.bind(Array.prototype.push); @@ -186,6 +239,14 @@ } }; + var overrideNative = function overrideNative(object, property, replacement) { + var original = object[property]; + defineProperty(object, property, replacement, true); + Value.preserveToString(object[property], original); + }; + + var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol()); + // This is a private name in the es6 spec, equal to '[Symbol.iterator]' // we're going to use an arbitrary _-prefixed name to make our shims // work properly with each other, even though we don't have full Iterator @@ -205,6 +266,8 @@ } var Reflect = globals.Reflect; + var $String = String; + var ES = { // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args Call: function Call(F, V) { @@ -220,24 +283,30 @@ if (x == null) { throw new TypeError(optMessage || 'Cannot call method on ' + x); } + return x; }, + // This might miss the "(non-standard exotic and does not implement + // [[Call]])" case from + // http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation + // but we can't find any evidence these objects exist in practice. + // If we find some in the future, you could test `Object(x) === x`, + // which is reliable according to + // http://www.ecma-international.org/ecma-262/6.0/#sec-toobject + // but is not well optimized by runtimes and creates an object + // whenever it returns false, and thus is very slow. TypeIsObject: function (x) { - /* jshint eqnull:true */ - // this is expensive when it returns false; use this function - // when you expect it to return true in the common case. - return x != null && Object(x) === x; + if (x === void 0 || x === null || x === true || x === false) { + return false; + } + return typeof x === 'function' || typeof x === 'object'; }, ToObject: function (o, optMessage) { - ES.RequireObjectCoercible(o, optMessage); - return Object(o); + return Object(ES.RequireObjectCoercible(o, optMessage)); }, - IsCallable: function (x) { - // some versions of IE say that typeof /abc/ === 'function' - return typeof x === 'function' && _toString(x) === '[object Function]'; - }, + IsCallable: isCallable, IsConstructor: function (x) { // We can't tell callables from constructors in ES5 @@ -301,7 +370,7 @@ // Better diagnostics if itFn is null or undefined throw new TypeError('value is not an iterable'); } - var it = _call(itFn, o); + var it = ES.Call(itFn, o); if (!ES.TypeIsObject(it)) { throw new TypeError('bad iterator'); } @@ -330,7 +399,7 @@ } var innerResult, innerException; try { - innerResult = _call(returnMethod, iterator); + innerResult = ES.Call(returnMethod, iterator); } catch (e) { innerException = e; } @@ -362,7 +431,7 @@ Construct: function (C, args, newTarget, isES6internal) { var target = typeof newTarget === 'undefined' ? C : newTarget; - if (!isES6internal) { + if (!isES6internal && Reflect.construct) { // Try to use Reflect.construct if available return Reflect.construct(C, args, target); } @@ -400,64 +469,132 @@ }, CreateHTML: function (string, tag, attribute, value) { - var S = String(string); + var S = ES.ToString(string); var p1 = '<' + tag; if (attribute !== '') { - var V = String(value); + var V = ES.ToString(value); var escapedV = V.replace(/"/g, '"'); p1 += ' ' + attribute + '="' + escapedV + '"'; } var p2 = p1 + '>'; var p3 = p2 + S; return p3 + '</' + tag + '>'; + }, + + IsRegExp: function IsRegExp(argument) { + if (!ES.TypeIsObject(argument)) { + return false; + } + var isRegExp = argument[Symbol.match]; + if (typeof isRegExp !== 'undefined') { + return !!isRegExp; + } + return Type.regex(argument); + }, + + ToString: function ToString(string) { + return $String(string); } }; - var Value = { - getter: function (object, name, getter) { - if (!supportsDescriptors) { - throw new TypeError('getters require true ES5 support'); + // Well-known Symbol shims + if (supportsDescriptors && hasSymbols) { + var defineWellKnownSymbol = function defineWellKnownSymbol(name) { + if (Type.symbol(Symbol[name])) { + return Symbol[name]; } - Object.defineProperty(object, name, { - configurable: true, + var sym = Symbol['for']('Symbol.' + name); + Object.defineProperty(Symbol, name, { + configurable: false, enumerable: false, - get: getter + writable: false, + value: sym }); - }, - proxy: function (originalObject, key, targetObject) { - if (!supportsDescriptors) { - throw new TypeError('getters require true ES5 support'); - } - var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); - Object.defineProperty(targetObject, key, { - configurable: originalDescriptor.configurable, - enumerable: originalDescriptor.enumerable, - get: function getKey() { return originalObject[key]; }, - set: function setKey(value) { originalObject[key] = value; } + return sym; + }; + if (!Type.symbol(Symbol.search)) { + var symbolSearch = defineWellKnownSymbol('search'); + var originalSearch = String.prototype.search; + defineProperty(RegExp.prototype, symbolSearch, function search(string) { + return ES.Call(originalSearch, string, [this]); }); - }, - redefine: function (object, property, newValue) { - if (supportsDescriptors) { - var descriptor = Object.getOwnPropertyDescriptor(object, property); - descriptor.value = newValue; - Object.defineProperty(object, property, descriptor); - } else { - object[property] = newValue; - } - }, - defineByDescriptor: function (object, property, descriptor) { - if (supportsDescriptors) { - Object.defineProperty(object, property, descriptor); - } else if ('value' in descriptor) { - object[property] = descriptor.value; - } - }, - preserveToString: function (target, source) { - if (source && ES.IsCallable(source.toString)) { - defineProperty(target, 'toString', source.toString.bind(source), true); - } + var searchShim = function search(regexp) { + var O = ES.RequireObjectCoercible(this); + if (regexp !== null && typeof regexp !== 'undefined') { + var searcher = ES.GetMethod(regexp, symbolSearch); + if (typeof searcher !== 'undefined') { + return ES.Call(searcher, regexp, [O]); + } + } + return ES.Call(originalSearch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'search', searchShim); } - }; + if (!Type.symbol(Symbol.replace)) { + var symbolReplace = defineWellKnownSymbol('replace'); + var originalReplace = String.prototype.replace; + defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) { + return ES.Call(originalReplace, string, [this, replaceValue]); + }); + var replaceShim = function replace(searchValue, replaceValue) { + var O = ES.RequireObjectCoercible(this); + if (searchValue !== null && typeof searchValue !== 'undefined') { + var replacer = ES.GetMethod(searchValue, symbolReplace); + if (typeof replacer !== 'undefined') { + return ES.Call(replacer, searchValue, [O, replaceValue]); + } + } + return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]); + }; + overrideNative(String.prototype, 'replace', replaceShim); + } + if (!Type.symbol(Symbol.split)) { + var symbolSplit = defineWellKnownSymbol('split'); + var originalSplit = String.prototype.split; + defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) { + return ES.Call(originalSplit, string, [this, limit]); + }); + var splitShim = function split(separator, limit) { + var O = ES.RequireObjectCoercible(this); + if (separator !== null && typeof separator !== 'undefined') { + var splitter = ES.GetMethod(separator, symbolSplit); + if (typeof splitter !== 'undefined') { + return ES.Call(splitter, separator, [O, limit]); + } + } + return ES.Call(originalSplit, O, [ES.ToString(separator), limit]); + }; + overrideNative(String.prototype, 'split', splitShim); + } + var symbolMatchExists = Type.symbol(Symbol.match); + var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () { + // Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it. + // Firefox 40 and below have Symbol.match but String#match works fine. + var o = {}; + o[Symbol.match] = function () { return 42; }; + return 'a'.match(o) !== 42; + }()); + if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) { + var symbolMatch = defineWellKnownSymbol('match'); + + var originalMatch = String.prototype.match; + defineProperty(RegExp.prototype, symbolMatch, function match(string) { + return ES.Call(originalMatch, string, [this]); + }); + + var matchShim = function match(regexp) { + var O = ES.RequireObjectCoercible(this); + if (regexp !== null && typeof regexp !== 'undefined') { + var matcher = ES.GetMethod(regexp, symbolMatch); + if (typeof matcher !== 'undefined') { + return ES.Call(matcher, regexp, [O]); + } + } + return ES.Call(originalMatch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'match', matchShim); + } + } var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) { Value.preserveToString(replacement, original); @@ -487,12 +624,6 @@ } }; - var overrideNative = function overrideNative(object, property, replacement) { - var original = object[property]; - defineProperty(object, property, replacement, true); - Value.preserveToString(object[property], original); - }; - var addIterator = function (prototype, impl) { var implementation = impl || function iterator() { return this; }; defineProperty(prototype, $iterator$, implementation); @@ -553,7 +684,7 @@ // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 if (String.fromCodePoint && String.fromCodePoint.length !== 1) { var originalFromCodePoint = String.fromCodePoint; - overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { return _apply(originalFromCodePoint, this, arguments); }); + overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { return ES.Call(originalFromCodePoint, this, arguments); }); } var StringShims = { @@ -590,14 +721,14 @@ var nextIndex = 0; var nextKey, next, nextSeg, nextSub; while (nextIndex < literalsegments) { - nextKey = String(nextIndex); - nextSeg = String(rawString[nextKey]); + nextKey = ES.ToString(nextIndex); + nextSeg = ES.ToString(rawString[nextKey]); _push(stringElements, nextSeg); if (nextIndex + 1 >= literalsegments) { break; } next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : ''; - nextSub = String(next); + nextSub = ES.ToString(next); _push(stringElements, nextSub); nextIndex += 1; } @@ -622,8 +753,7 @@ var StringPrototypeShims = { repeat: function repeat(times) { - ES.RequireObjectCoercible(this); - var thisStr = String(this); + var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); var numTimes = ES.ToInteger(times); if (numTimes < 0 || numTimes >= stringMaxLength) { throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); @@ -632,46 +762,50 @@ }, startsWith: function startsWith(searchString) { - ES.RequireObjectCoercible(this); - var thisStr = String(this); - if (Type.regex(searchString)) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { throw new TypeError('Cannot call method "startsWith" with a regex'); } - var searchStr = String(searchString); - var startArg = arguments.length > 1 ? arguments[1] : void 0; - var start = _max(ES.ToInteger(startArg), 0); - return _strSlice(thisStr, start, start + searchStr.length) === searchStr; + var searchStr = ES.ToString(searchString); + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + var start = _max(ES.ToInteger(position), 0); + return _strSlice(S, start, start + searchStr.length) === searchStr; }, endsWith: function endsWith(searchString) { - ES.RequireObjectCoercible(this); - var thisStr = String(this); - if (Type.regex(searchString)) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { throw new TypeError('Cannot call method "endsWith" with a regex'); } - var searchStr = String(searchString); - var thisLen = thisStr.length; - var posArg = arguments.length > 1 ? arguments[1] : void 0; - var pos = typeof posArg === 'undefined' ? thisLen : ES.ToInteger(posArg); - var end = _min(_max(pos, 0), thisLen); - return _strSlice(thisStr, end - searchStr.length, end) === searchStr; + var searchStr = ES.ToString(searchString); + var len = S.length; + var endPosition; + if (arguments.length > 1) { + endPosition = arguments[1]; + } + var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition); + var end = _min(_max(pos, 0), len); + return _strSlice(S, end - searchStr.length, end) === searchStr; }, includes: function includes(searchString) { - if (Type.regex(searchString)) { + if (ES.IsReg |