Bug 16571 - Define order for named properties
Define order for named properties
Status: RESOLVED FIXED
Product: WebAppsWG
Classification: Unclassified
Component: DOM
unspecified
All Windows 3.1
: P2 normal
: ---
Assigned To: Anne
public-webapps-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-29 18:01 UTC by Ms2ger
Modified: 2012-12-14 15:58 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ms2ger 2012-03-29 18:01:34 UTC
<http://dev.w3.org/2006/webapi/WebIDL/#property-enumeration> has

| If the object supports named properties, then the object’s supported
| property names are enumerated next, in the order given in the
| definition of the set of supported property names.

We don't give such an order.
Comment 1 Ms2ger 2012-03-29 18:03:03 UTC
And I needed a place to stick this: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1438
Comment 3 Boris Zbarsky 2012-12-13 16:05:12 UTC
Sorry, what the spec says now is nonsense.  Apart from being very difficult to parse, it at best doesn't define the order in this simple case:

  <img id="foo" name="bar">

and similar in more complicated cases like:

  <img id="foo" name="bar">
  <img id="bar" name="foo">

and whatnot.
Comment 4 Anne 2012-12-14 08:21:05 UTC
How about this:

The supported property names are in the return value of these steps:

* Let /set/ be an empty list.
* For each element represented by the collection, if any:
  * If the element is a a, applet, area, embed, form, frame, frameset, iframe, img, or object element in the HTML namespace and has a name attribute whose value is not in /set/, append its value to /set/.
  * If the element has an ID and its ID is not in /set/, append ID to /set/.
* Return /set/.

And my apologies for yesterday's commit.
Comment 5 Boris Zbarsky 2012-12-14 08:32:49 UTC
That's much better, yeah (and no need to apologize!).

On a slightly unrelated note, the exact set of tagnames involved makes me sad, especially because it doesn't match the set of things that show up as named properties on the document.  For what it's worth, Gecko just exposes all names here, and I believe Opera may as well, based on some quick testing.  Is there really a reason to not do that?
Comment 6 Anne 2012-12-14 09:47:49 UTC
Okay, widened to include all elements in the HTML namespace (quick test showed that <svg name=svg> didn't do anything in either Gecko or Opera).

https://github.com/whatwg/dom/commit/1400a64aff1f2155f9cfa935624b4bfbc4f7c66b
Comment 7 Boris Zbarsky 2012-12-14 15:58:53 UTC
Thanks.  I think Gecko is inconsistent about the SVG case: it exposes it as a supported name but does not enumerate it.  The former is probably a bug, though.