String.prototype.search has a breaking change from ES5
# Allen Wirfs-Brock (10 years ago)
On Apr 18, 2015, at 12:46 PM, Yusuke SUZUKI wrote:
Hi forks,
Seeing ES6 String.prototype.search, there's a breaking change from ES5.
When executing
"gnulluna".search(null)
,In ES5, RegExp(null) => /null/ is generated, so the result becomes 1.
ecma-international.org/ecma-262/5.1/#sec-15.5.4.12
In ES6, we fall down to the 21.1.3.15 step 3 (because null is not undefined). And then reaching step 3.a,
Let searcher be GetMethod(regexp, @@search).
Then TypeError is thrown by GetV's ToObject.
Is it intentional behavior?
Appears to be a bug. Probably also for similar code for match, replace, and split.
Please file a bug ticket.
Seeing ES6 String.prototype.search, there's a breaking change from ES5.
When executing
"gnulluna".search(null)
,In ES5, RegExp(null) => /null/ is generated, so the result becomes 1.
ecma-international.org/ecma-262/5.1/#sec-15.5.4.12
In ES6, we fall down to the 21.1.3.15 step 3 (because null is not undefined). And then reaching step 3.a,
Let searcher be GetMethod(regexp, @@search).
Then TypeError is thrown by GetV's ToObject.
Is it intentional behavior?
Best , Yusuke Suzuki