paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

`RegExp.input` test fails on Opera 12.15 #353

Open ljharb opened 9 years ago

ljharb commented 9 years ago

It seems like Opera 12.15 has RegExp.input, but it's always undefined, so the test for it is failing.

To fix this issue, either a) we need to discover how to fix the behavior, b) figure out how to feature-detect when the test isn't applicable, c) figure out if it's acceptable to detect this at runtime and not copy over the "input" property when it doesn't work.

Yaffle commented 9 years ago

both RegExp.input and RegExp.$_ have value undefined

ljharb commented 9 years ago

In that particular browser, yes. However, not in most browsers, where it is equal to the last string that was used to exec against a regex.

Yaffle commented 9 years ago

RegExp.input is not standard and should not be used anyway, you can use "input" property of an object returned by "exec" instead

ljharb commented 9 years ago

The spec allows for nonstandard extensions, and by wrapping RegExp, I don't want to break a browsers's builtin extensions.

The difficulty here is that input/$_ in Opera is the only one of these properties that actually exists but doesn't function.

If in fact I can detect this at runtime by running a regex exec, then I can simply skip the test.