Le 12 août 2014 à 18:44, Garrett Smith <dhtmlkitc...@gmail.com> a écrit :

> What's the explanation and reason for this strange characteristic of
> the OBJECT element in Firefox?
> 
> Firefox 31:
> typeof document.createElement("object")
> "function"
> Function.prototype.toString.call(document.createElement("object"));
> TypeError: Function.prototype.toString called on incompatible object
> 
> If the typeof OBJECT results "function" then it either:
> a) implements [[Call]] or
> b) is exotic
> 
> Since calling `Function.prototype.toString` with OBJECT as the this
> value results in a TypeError, it appears that the OBJECT does not
> implement [[Call]] and thus the only explanation is that the OBJECT is
> exotic. Did I get that right? Or is there another explanation?
> 
> What's the explanation and reason for this strange characteristic of
> the OBJECT element in Firefox?

According to comments 10-18 in 
https://bugzilla.mozilla.org/show_bug.cgi?id=268945 , object and embed elements 
do implement [[Call]] for some obscure reason. Hence `typeof` yielding 
"function".

Maybe I'm splitting hairs, but the spec doesn't say explicitly that all objects 
implementing [[Call]] must support `Function.prototype.toString`, although I'm 
not sure that that omission was intentional. Anyway, if you want to test if an 
object implements [[Call]], the best method is simply to try to call it:

        document.createElement("object")()

(which produces an interesting result in Firefox).

—Claude
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to