This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27688 - Odd comment in DOM spec about the new "Elements" class
Summary: Odd comment in DOM spec about the new "Elements" class
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-23 21:53 UTC by John Atkins
Modified: 2015-07-15 06:49 UTC (History)
4 users (show)

See Also:


Attachments

Description John Atkins 2014-12-23 21:53:26 UTC
https://dom.spec.whatwg.org/#collections:-elements

[[
Elements is an ES6-style subclass of Array with two additional methods. It's the new NodeList / HTMLCollection. 
]]

How can a class named "Elements" legitimately replace the NodeList interface, when, in additions to Elements, a NodeList can also contain Text nodes and Comments etc?

There are comments throughout the spec about "historical artifacts" that "we cannot rid the web of" and yet this seems like another one in the making...
Comment 1 Tab Atkins Jr. 2014-12-23 22:55:11 UTC
The Elements class is for those functions that actually return only elements, like querySelectorAll and .childElements, etc.
Comment 2 Anne 2015-05-08 09:19:19 UTC
It's interesting to consider whether perhaps we should give it a different name so it can in the future also be used for cases where we want to represent more than elements. Or whether we should restrict it to elements as the name suggests now... (And add a distinct class for nodes.)
Comment 3 Anne 2015-07-15 06:49:15 UTC
If we need to represent nodes the methods don't make sense. We'd just use a simple Array for those cases.

I did clarify the statement a bit to make that more clear:

https://github.com/whatwg/dom/commit/96ef454f2f3326cf95b878b783a16a2dee16d4d3

Thanks for your input!