W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

RE: Elements (extends Array)

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Thu, 8 Aug 2013 04:05:44 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <B4AE8F4E86E26C47AC407D49872F6F9F878A875C@BY2PRD0510MB354.namprd05.prod.outlook.com>
From: Boris Zbarsky [mailto:bzbarsky@MIT.EDU]

> On 8/7/13 11:48 PM, Domenic Denicola wrote:
> > I believe the intent here is to allocate an object that acts exactly like the
> one that you get when doing `class Elements extends Array { ... }` in ES6.
> I guess the question is whether that object would have any special Elements-
> associated magic, right?
> Put another way, would methods off of Elements.prototype be generic or
> only work on "Elements" objects?

They should be generic, I think. In particular, I believe `Elements.prototype.selectAll.call(normalArrayOfElements, "selector")` should work, at least assuming `selectAll`s implementation is anything like it is in the Gist. (It may not be, e.g. because it's easier to optimize something that behaves less generically. But the general idea of getting all the elements that match an absolutized version of `selector`, then stuffing them into the object created via `this.constructor`—for whichever `this` you're being called with now—seems sensible.)
Received on Thursday, 8 August 2013 04:06:18 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:17 UTC