W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2010

[whatwg] Adding ECMAScript 5 array extras to HTMLCollection

From: David Bruant <bruant@enseirb-matmeca.fr>
Date: Fri, 23 Apr 2010 19:30:09 -0700
Message-ID: <4BD257B1.6040500@enseirb-matmeca.fr>
Hi,

In the HTML5 "status of this document" section, one can read : "This 
specification is intended to replace (be the new version of) what was 
previously the [...] DOM2 HTML specifications."
This spec can be found here : http://www.w3.org/TR/DOM-Level-2-HTML/

It defines ECMAScript language Binding 
(http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html). This 
document explains how to implement the DOM HTML interfaces in an 
ECMAScript-compliant environment.

Because HTML5 is intended to replace DOM2 HTML, it can "freely" change 
ECMAScript bindings. My suggestion is the following :
Make that HTMLCollection (and all HTML*Collection, as a consequence of 
inheritence of HTMLCollection) inherit from the ECMAScript Array 
prototype. This way, it will make available all Array extra methods 
(forEach, map, filter...) added in ECMAScript5 (and next versions which 
should go in the same direction).

As far as I know, adding this won't break any existing code. The 
semantics of a Collection and the way it is used is very close from 
ECMAScript Arrays.
I don't think that the notion of "live object" and ECMAScript Array are 
incompatible either.
Once again, I am talking about ECMAScript binding. I have no intention 
to touch the HTMLCollection interface or other languages bindings.

Would the WHATWG have the power to decide something similar regarding 
NodeList ?

Any thoughts ?

Thanks,

David
Received on Friday, 23 April 2010 19:30:09 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:22 UTC