Closed
Bug 1225009
Opened 9 years ago
Closed 9 years ago
String#match no longer respects Symbol.match
Categories
(Core :: JavaScript: Standard Library, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 887016
People
(Reporter: ljharb, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
Steps to reproduce:
In Firefox 40, the following code gives `true`:
`var o = {}; o[Symbol.match] = function () { return 42; }; ''.match(o) === 42`
In Firefox 41 and later (including latest nightly, it gives `false` - because it's returning `null` instead.
Actual results:
I got `null` instead of the value the Symbol.match matcher returned.
Expected results:
It should have returned `42`.
Comment 1•9 years ago
|
||
I can't reproduce the behavior described in comment 0 for Firefox 40.0.3. It seems to be similar for 40 and 42. Doesn't Symbol.match control use as regular expression and not the return value (and for that reason returns null and false)?
Component: Untriaged → JavaScript: Standard Library
Product: Firefox → Core
Comment 2•9 years ago
|
||
Symbol.match is implemented from Firefox 40 (bug 1054755), but ES6 compliant String.prototype.match/RegExp.prototype[@@match] are not yet implemented. see bug 887016.
In current implementation, o.toString() == "[object Object]" is parsed as RegExp pattern (so, single character class), and it's used in match, and the match fails. it won't return 42 anyways.
So, the question is that why/how it returns 42 and true on your Firefox 40.
Can you still reproduce it?
Flags: needinfo?(ljharb)
I can still reproduce it. I'm using Firefox 40.0 on Windows 8 and also 40.0 on any Mac OS on Browserstack.
Why was `Symbol.match` added in the first place if it wasn't meant to be fully compliant?
Flags: needinfo?(ljharb)
Ah wait - scratch that. It is indeed returning null for me in Firefox 40.
In that case, this may be a duplicate of bug 887016.
I'm still confused why a well-known symbol would be added that isn't compliant with the spec, but that's neither here nor there - I'll just have to patch it in the es6-shim until it's fixed :-)
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•