Disabling nonstandard RegExp functionalities for proper subclasses of RegExp

Claude Pache claude.pache at gmail.com
Wed Apr 27 15:42:53 UTC 2016


> Le 27 avr. 2016 à 15:46, Andrea Giammarchi <andrea.giammarchi at gmail.com> a écrit :
> 
> What I am saying is that `class MyRE extends RegExp {}` should *not* inherit any magic property from global `RegExp` but *also* should *not* pollute the global `RegExp` when used.
> 
> Right now, the code I've tested on Chrome, suffers pollution either ways: `MyRE.$1` is `RegExp.$1` and vice versa, even if I'm using `new MyRE()` when testing or matching my own regular expressions.
> 
> Having same features improved on the global pollution side looks like a better win than removing features one might or not like.
> 
> Best Regards

Right. I have just amended my proposal so that MyRE.$1 is undefined by default.

In the same time, I have simplified the semantics: more precisely, I have removed attempts to be smart that resulted in being more risky w.r.t backward compatibility. It is more important to have something that is agreed to be implemented.

—Claude


More information about the es-discuss mailing list