W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

[Bug 14877] Define [[Class]] of interface prototype objects, exception interface objects, and exception interface prototype objects

From: <bugzilla@jessica.w3.org>
Date: Mon, 21 Nov 2011 02:50:31 +0000
To: public-script-coord@w3.org
Message-Id: <E1RSJxn-0007Gf-0j@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=14877

--- Comment #8 from Garrett <dhtmlkitchen@gmail.com> 2011-11-21 02:50:26 UTC ---
(In reply to comment #7)
> I just discovered that exception interface objects and exception interface
> prototype objects also don't have [[Class]] defined.  Browser behavior for
> DOMException:
> 
> * IE9: DOMException and DOMExceptionPrototype, like regular interfaces
> * Firefox 11a1: ???
>   * {}.toString.call(DOMException) == "[object DOMPrototype]"
>   * String(DOMException) == "[object DOMException]"
>   * {}.toString.call(DOMException.prototype) == "[object
> XPC_WN_ModsAllowed_NoCall_Proto_JSClass]"
> * Chrome 17 dev: Function for the exception interface object, Object for the
> exception interface prototype object
> * Opera 12.00: DOMException for both objects
> 
> (Of course, String(DOMException.prototype) throws in all browsers because it
> invokes Error.prototype.toString.)
> 
> I'd go with IE9 here, unless it has compat issues.

If DOMException is spec changed to be a function then the Interface
Object's prototype -- DOMException.prototype -- can then be defined to be
an instance of DOMException. This is how all the built-ins work, e.g.

 Function.prototype instance of Function; // true
 String.prototype == ""; // true
 Error.prototype instanceof Error; // true

And with host objects I am suggesting a standardized behavior like this:

 DOMException.prototype intanceof DOMException;

 - with a standardized result of `true`. The concept might be applied here, but
probably would be complicated for Interface Objects that can't by any rational
means be constructed, e.g.
  Element.prototype instanceof Element;
  Node.prototype instanceof Node;

Those Interface Objects can't be new'd. What type of Element would
Element.prototype be? What of its ownerDocument? 

An Object's toString() doesn't indicate what the object can do so programs
shouldn't rely on information from that. 

However programs should be able to expect a toString method on host objects. By
spec'ing Object.prototype as a base, Object.prototype.toString would be
guaranteed available, instead of an error or some strange host object behavior
(Asen raises some issues on "Updated FAQ" thread:
http://groups.google.com/group/comp.lang.javascript/msg/fe387847c719119a?hl=en&dmode=source
)

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Monday, 21 November 2011 02:50:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC