-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow subclassing of RegExps #18
Conversation
👍 |
// 2. RegExp.make('gi')`....` to specify flags | ||
// 3. RegExp.make.bind(RegExpSubClass)`...` with a this value that specifies | ||
// a different constructor. | ||
const xType = typeof x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use typeof x
twice. Should be shorter and easier to read; also engines optimise this better when typeof
is a direct operand of ==
/===
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@bergus, are you ok with patch as it stands? |
@@ -306,7 +306,7 @@ RegExp.make = (function () { | |||
* a start context, and RegExp source, and returns an end context. | |||
*/ | |||
function parseRegExpSource(eventHandler) { | |||
const { | |||
var { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this changed to var
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not sure why this is changed to var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same limitation of closure compiler. It types const
s in a separate pass from var
s.
Allow subclassing of RegExps
@@ -1065,12 +1076,25 @@ RegExp.make = (function () { | |||
pattern += rawLiteralPart; | |||
addTemplateGroups(i+1); | |||
} | |||
const output = new RegExp(pattern, flags); | |||
var output = new ctor(pattern, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or this one
No description provided.