Created attachment 16949 [details]
Maybe I'm missing something about this method, as I don't see any use for it - but tests do pass :)
Comment on attachment 16949 [details]
Seems fine. r=me
We should figure out what good this is! And make tests that cover its value.
(In reply to comment #1)
> Maybe I'm missing something about this method, as I don't see any use for it -
> but tests do pass :)
(In reply to comment #2)
> We should figure out what good this is! And make tests that cover its value.
AFAICT, any RegExp construction compiles it anyway - (new RegExp).compile(...) is the same as new RegExp(...) in this regard.
Level 4 (of 7) Haxz0r:
...Knows that properties of the global RegExp object and the compile() method are deprecated.
Sure, I'm familiar with the broad general notion of compiling a regular expression.
(In reply to comment #5)
> what additional value [does] the compile function provide
If there are existing websites that use it, we probably should put the implementation in.
Leaving it out of Safari, if it's in IE and Firefox, will more likely make them think Safari is broken rather than encouraging them to remove it.
Yeah, I know that makes sense, but I hate to see meaningless cruft like this used by people who come from programming languages where compiling a regex can actually have significant performance impact.
Actually, I can think of one thing that is different between using compile and just creating a new RegExp object. AFAIK, using compile on an existing regex will not discard custom properties on the object. However, I hope no one is relying on this feature (if I am in fact correct) since compile() has been deprecated for nearly a decade.
Committed revision 27303.
I don't know any sites that use RegExp.compile, but given that it is widely documented and implemented, I'm sure there are quite a few.
> AFAIK, using compile on an existing regex will not discard
> custom properties on the object.
This is correct. Also, I can imagine situations where modifying an object leads to slightly nicer looking code than re-creating it. After all, compile() doesn't cause any architectural problems for anyone AFAICT, so I don't think we need to actively discourage it.
To add to what ap said above, his patch fixed an oft-duped compatibility problem with bmwusa.com.