archives

« Bugzilla Issues Index

#462 — String.prototype HTML methods in Annex B should probably call CheckObjectCoercible()


I’ve previously made an attempt at defining these methods here: http://mathias.html5.org/specs/javascript/#string

It would make sense to have these methods call the CheckObjectCoercible() abstract operation on the `this` object, so that they cannot be applied to `null` or `undefined`, just like the other String.prototype methods.

The majority of the engines I tested in implement it like this, with no compatibility issues: Firefox/Spidermonkey, Safari/JavaScriptCore, and Opera/Carakan.

Chrome/V8 and IE/Chakra are the only engines I tested that don’t currently perform the CheckObjectCoercible() step. Here are some relevant bugs:

* Safari/JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=64677 (old bug from last year)
* Chrome/V8: http://code.google.com/p/v8/issues/detail?id=2218
* IE/Chakra: https://connect.microsoft.com/IE/feedback/details/752807

It would improve interoperability and consistency within the spec if ES6 could define these methods with something like `CheckObjectCoercible(this)` as their first step. Please consider doing so.


Tests for these methods as defined on http://mathias.html5.org/specs/javascript/#string (i.e. including the CheckObjectCoercible step) can be found here: http://mathias.html5.org/tests/javascript/string/


That check is already there. It is step 1 of the abstract operation CreateHTML