- From: Cameron McCormack <cam@mcc.id.au>
- Date: Sat, 18 Jun 2011 17:26:18 +1200
- To: David Flanagan <dflanagan@mozilla.com>
- Cc: public-script-coord@w3.org
Hi David. David Flanagan: > I've just read your new (from 5/25) section on property enumeration order: … > > 3. No further own properties or properties from the object's > > prototype chain are enumerated. > > Is point 3 for real? If I get a NodeList like document.childNodes > and use it in a for/in loop, I'll just get the index elements and > not the enumerable inherited length and item? And if I add an > enumerable expando property to that NodeList, it won't be enumerated > either? > > Is there any precedent for this? What other objects behave this way? No, that seems to be totally bogus. I think I must have been misinterpreting some tests I did earlier. I did some more tests: http://people.mozilla.org/~cmccormack/tests/enumeration-indexed-named.html Results: Fx Sa Cr Op IE HTMLCollection indexed properties enumerated? y y y y n named properties enumerated? n n n n y own expando property enumerated? y y y y y prototype properties enumerated? y y y y y HTMLFormControlsCollection indexed properties enumerated? y y y y n named properties enumerated? n n n y y own expando property enumerated? y x x y y prototype properties enumerated? y y y y y [OverrideBuiltins] HTMLFormElement indexed properties enumerated? n y y y n named properties enumerated? y n n n y own expando property enumerated? n x y y y prototype properties enumerated? y y y y y Window indexed properties enumerated? n n n y n named properties enumerated? N n n y y own expando properties enumerated? y y y y y prototype properties enumerated? y y y y y NodeList indexed properties enumerated? y y y y y own expando property enumerated? y x x y y prototype properties enumerated? y y y y y DOMStringMap named properties enumerated? y y y y - prototype properties enumerated? y y y y y [OverrideBuiltins] HTMLDocument named properties enumerated? n n y y y own expando property enumerated? y y y y y prototype properties enumerated? y y y y y (-) interface not implemented (x) couldn’t set expando property (N) named properties don’t exist on this object So, clearly we should be enumerating properties from the prototype chain. Also, I think own expando properties should be enumerated: there’s only one case where they’re not, which is Firefox on HTMLFormElement. If the object has indexed properties only, or named properties only, then we definitely should enumerate them. But there’s not uniform behaviour when there are both indexed and named properties on the one object. Just going by the numbers, I think we should make indexed and named properties all be enumerated, unless we have compatibility reasons for doing otherwise: if someone knows that we definitely can’t enumerate everything on certain objects (indexed properties on Window looks like a candidate), then I can invent an extended attribute to use to disable that. -- Cameron McCormack ≝ http://mcc.id.au/
Received on Saturday, 18 June 2011 05:26:55 UTC