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: Thu, 15 Dec 2011 06:04:40 +0000
To: public-script-coord@w3.org
Message-Id: <E1Rb4Qq-0002gt-Dc@jessica.w3.org>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=14877

--- Comment #21 from Cameron McCormack <cam@mcc.id.au> 2011-12-15 06:04:36 UTC ---
Here's a test expanding on Aryeh's comment 0 tests for
Object.prototype.toString() and String() on Node, Node.prototype, NodeList,
NodeList.prototype and Image:

http://people.mozilla.org/~cmccormack/tests/constructor-class.html

I agree with Aryeh that choosing ({}).toString.call(Node.prototype) == "[object
Node]" is best, since that allows for the debugging that Travis wants as well
as being consistent with ES builtins as Garrett points out.

Do people think there's much advantage to having String(Node) == "function
Node() { ... }", now that interface objects are function objects?  It would be
consistent with the builtin constructors like Object, String, etc.  OTOH 
"[object Node]" is a slight winner from the results.

So my preferred proposal is to make:

1. ({}).toString.call(Node) == "[object Node]"
2. String(Node) == "[object Node]"
3. ({}).toString.call(Node.prototype) == "[object Node]"
4. String(Node.prototype) == "[object Node]"
5. ({}).toString.call(Image) == "[object Image]"
6. String(Image) == "[object Image]"

but I would also be OK with this, if there are no compat issues:

1. ({}).toString.call(Node) == "[object Node]"
2. String(Node) == "function Node() { ... }"
3. ({}).toString.call(Node.prototype) == "[object Node]"
4. String(Node.prototype) == "[object Node]"
5. ({}).toString.call(Image) == "[object Image]"
6. String(Image) == "function Image() { ... }"

For (2), (4) and (6), we'd need to have toString functions on interface objects
to override the one from Function.prototype.


Results from the test:

Node
====

      {}.toString.call()        String()
  -----------------------------------------------------------------
  Fx  [object DOMPrototype]     [object Node]
  Cr  [object Function]         function Node() { [native code] }
  Sa  [object NodeConstructor]  [object NodeConstructor]
  Op  [object Node]             [object Node]
  IE  [object Node]             [object Node]

Node.prototype
==============

      {}.toString.call()                  String()
  -----------------------------------------------------------------
  Fx  [object DOM Constructor.prototype]  [object Node]
  Cr  [object Object]                     [object Object]
  Sa  [object NodePrototype]              [object NodePrototype]
  Op  [object NodePrototype]              [object NodePrototype]
  IE  [object NodePrototype]              [object NodePrototype]

NodeList
========

      {}.toString.call()        String()
  -----------------------------------------------------------------
  Fx  [object NodeList]         [object NodeList]
  ... rest as for Node ...

NodeList.prototype
==================

      {}.toString.call()        String()
  -----------------------------------------------------------------
  Fx  [object Object]           [object Object]
  ... rest as for Node.prototype ...

Image
=====

      {}.toString.call()                  String()
  -----------------------------------------------------------------
  Fx  [object DOMConstructor]             [object Image]
  Cr  [object Function]                   [object Function]
  Sa  [object ImageConstructor]           [object ImageConstructor]
  Op  [object Image]                      function Image() { [native code] }
  IE  [object Function]                   function Image() { [native code] }


And this is what the spec currently says to do:

                  {}.toString.call()                  String()
  ----------------------------------------------------------------------------
  Node            [object Node]                       function Node() { ... }
  Node.prototype  [object Object]                     [object Object]
  Image           [object Function]                   function Image() { ... }

-- 
Configure bugmail: https://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 Thursday, 15 December 2011 06:04:45 UTC

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