Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: src/js/harmony-regexp.js

Issue 1543723002: Add web compat workarounds for ES2015 RegExp semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test expectations for new workaround Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/js/regexp.js » ('j') | src/js/regexp.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-regexp.js
diff --git a/src/js/harmony-regexp.js b/src/js/harmony-regexp.js
index 2e3bd06707965a0aaa1a4fa86fe16f644af998db..e080cda29b34e274a0b294dd8428276539645cba 100644
--- a/src/js/harmony-regexp.js
+++ b/src/js/harmony-regexp.js
@@ -12,6 +12,7 @@
// Imports
var GlobalRegExp = global.RegExp;
+var GlobalRegExpPrototype = GlobalRegExp.prototype;
var MakeTypeError;
var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol");
@@ -37,10 +38,17 @@ function RegExpGetFlags() {
return result;
}
+const kRegExpPrototypeStickyGetter = 11;
// ES6 21.2.5.12.
function RegExpGetSticky() {
if (!IS_REGEXP(this)) {
+ // Compat fix: RegExp.prototype.sticky == undefined; UseCounter tracks it
+ // TODO(littledan): Remove this workaround or standardize it
+ if (this === GlobalRegExpPrototype) {
+ %IncrementUseCounter(kRegExpPrototypeStickyGetter);
+ return UNDEFINED;
+ }
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky");
}
return !!REGEXP_STICKY(this);
« no previous file with comments | « include/v8.h ('k') | src/js/regexp.js » ('j') | src/js/regexp.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698