-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
redefine
by hide
because of Chrome 38 bug with symbols co…
…nversion
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1 @@ | ||
'use strict'; | ||
|
||
var classof = require('./_classof'); | ||
var builtinExec = RegExp.prototype.exec; | ||
|
||
// `RegExpExec` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-regexpexec | ||
module.exports = function (R, S) { | ||
var exec = R.exec; | ||
if (typeof exec === 'function') { | ||
var result = exec.call(R, S); | ||
if (typeof result !== 'object') { | ||
throw new TypeError('RegExp exec method returned something other than an Object or null'); | ||
} | ||
return result; | ||
} | ||
if (classof(R) !== 'RegExp') { | ||
throw new TypeError('RegExp#exec called on incompatible receiver'); | ||
} | ||
return builtinExec.call(R, S); | ||
}; | ||
// empty |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1 @@ | ||
'use strict'; | ||
|
||
var regexpFlags = require('./_flags'); | ||
|
||
var nativeExec = RegExp.prototype.exec; | ||
// This always refers to the native implementation, because the | ||
// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, | ||
// which loads this file before patching the method. | ||
var nativeReplace = String.prototype.replace; | ||
|
||
var patchedExec = nativeExec; | ||
|
||
var LAST_INDEX = 'lastIndex'; | ||
|
||
var UPDATES_LAST_INDEX_WRONG = (function () { | ||
var re1 = /a/, | ||
re2 = /b*/g; | ||
nativeExec.call(re1, 'a'); | ||
nativeExec.call(re2, 'a'); | ||
return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0; | ||
})(); | ||
|
||
// nonparticipating capturing group, copied from es5-shim's String#split patch. | ||
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; | ||
|
||
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED; | ||
|
||
if (PATCH) { | ||
patchedExec = function exec(str) { | ||
var re = this; | ||
var lastIndex, reCopy, match, i; | ||
|
||
if (NPCG_INCLUDED) { | ||
reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re)); | ||
} | ||
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX]; | ||
|
||
match = nativeExec.call(re, str); | ||
|
||
if (UPDATES_LAST_INDEX_WRONG && match) { | ||
re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex; | ||
} | ||
if (NPCG_INCLUDED && match && match.length > 1) { | ||
// Fix browsers whose `exec` methods don't consistently return `undefined` | ||
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ | ||
// eslint-disable-next-line no-loop-func | ||
nativeReplace.call(match[0], reCopy, function () { | ||
for (i = 1; i < arguments.length - 2; i++) { | ||
if (arguments[i] === undefined) match[i] = undefined; | ||
} | ||
}); | ||
} | ||
|
||
return match; | ||
}; | ||
} | ||
|
||
module.exports = patchedExec; | ||
// empty |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
'use strict'; | ||
var regexpExec = require('./_regexp-exec'); | ||
require('./_export')({ | ||
target: 'RegExp', | ||
proto: true, | ||
forced: regexpExec !== /./.exec | ||
}, { | ||
exec: regexpExec | ||
}); | ||
// empty |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.