Comment #5 on issue 2218 by [email protected]: HTML extensions to String.prototype must throw an error if the `this` object is not coercible (i.e. `null` or `undefined`)
http://code.google.com/p/v8/issues/detail?id=2218

However, the change that is being proposed here are not part of the ecma spec and not yet mature.

FWIW, http://mathias.html5.org/specs/javascript/ includes it, and so does the latest ES6 spec draft (see http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) — see step 1 of the abstract operation `CreateHTML`.

I haven't checked this yet, but other browsers might not even comply with the suggested behavior either.

Safari/JavaScriptCore, Chrome/V8, and IE/Chakra don’t perform the CheckObjectCoercible step:

* Safari/JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=64677
* IE/Chakra: https://connect.microsoft.com/IE/feedback/details/752807

Firefox and Opera do. As errors are thrown in these browsers, it’s unsafe to use these methods with `null` or `undefined` anyway, so it makes sense to do the same for all browsers/engines.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to