Re: ECMA TC 39 / W3C HTML and WebApps WG coordination

On Fri, Sep 25, 2009 at 12:35 PM, Brendan Eich <brendan@mozilla.com> wrote:
> On Sep 25, 2009, at 12:08 PM, Jonas Sicking wrote:
>
>> On Fri, Sep 25, 2009 at 9:56 AM, Brendan Eich <brendan@mozilla.com> wrote:
>>>
>>> My positions are:
>>>
>>> 1. WebIDL, the bird in the hand (I agree with Sam: go invent something
>>> better, come back when you're done).
>>>
>>> 2. Don't keep perpetuating catchall patterns, they are confusing for
>>> developers and costly for implementors and static analysis tools, even if
>>> implementable in some future ES edition.
>>>
>>> 3. Don't care.
>>
>> Regarding 2. How do you feel about index accessors? I.e. for example you
>> can do:
>>
>> myNode.children[5]
>>
>> which returns the same as
>>
>> myNode.children.item(5)
>>
>> This seems equally impossible to implement in ECMAScript, but is
>> something that I think is helpful to authors so not something that I
>> want to stop adding to new interfaces.
>
> Good point. I have mixed feelings, to be honest. See the ArrayLike thread on
> es-discuss:
>
> https://mail.mozilla.org/pipermail/es-discuss/2009-May/009300.html
>
> and followups. The one from Travis Leithead of Microsoft at:
>
> https://mail.mozilla.org/pipermail/es-discuss/2009-May/009363.html
>
> links to http://dev.w3.org/2006/webapi/WebIDL/#es-sequence, which has words
> about an "Array host object":
>
> http://dev.w3.org/2006/webapi/WebIDL/#dfn-array-host-object
>
> This is new and different from the legacy collection/nodelist stuff, which
> we can't change. Is it the new-model solution for index accessors, or are
> you still wanting to make live "tree cursors" with indexed getter and setter
> catchalls?

This isn't just related to the Node tree. Two examples of new objects
that are "Array like" are:

FileList[1]. Returned from HTMLInputElement.files [2] and allows you
to access the File objects for reading file data etc without
roundtripping to the server. Since default behavior for input elements
is to allow only one file to be picked, lots of code do: file =
myInputElement.files[0]

DOMTokenList[3]. Returned from HTMLElement.classList and allows access
to the parsed class list for an element. Lets you iterate over the
classes using myDivElement.classList[0].

> The live tree cursors always seemed like a mixed bag at best. Folks want to
> use Array generic methods on them, and sometimes find the liveness a
> problem. I've not heard anyone saying the liveness was a crucial win.

Array accessors are now used even for non-live objects, such as the
NodeList returned from querySelectorAll[5]. So this applies even for
APIs where we're moving away from the liveness misstakes of the past.

[1] http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html#FileList-if
[2] http://www.whatwg.org/specs/web-apps/current-work/?slow-browser#htmlinputelement
[3] http://www.whatwg.org/specs/web-apps/current-work/?slow-browser#domtokenlist
[4] http://www.whatwg.org/specs/web-apps/current-work/?slow-browser#htmlelement
[5] http://www.w3.org/TR/selectors-api/#nodeselector

/ Jonas

Received on Friday, 25 September 2009 20:05:47 UTC