Re: [DOM4] NodeList should be deprecated

2012-03-16 Thread Ojan Vafai
On Wed, Mar 14, 2012 at 5:32 AM, Anne van Kesteren ann...@opera.com wrote:

 On Wed, 14 Mar 2012 09:03:23 +0100, Cameron McCormack c...@mcc.id.au
 wrote:

 Anne van Kesteren:

 Wasn't there a compatibility constrain with doing that?


 I don't remember -- the only difference it would make is that
 Object.getPrototypeOf(**NodeList.prototype) == Array.prototype.


 Okay, annotated NodeList with [ArrayClass]. What about HTMLCollection?
 Should I add it there too? Could you take a look at NodeList and
 HTMLCollection for accuracy?


Should HTMLCollection inherit from NodeList? All the APIs I can think of
that you'd want to add to NodeList you'd want on HTMLCollection as well.

To be clear, array methods that modify the array in-place would silently do
nothing because the properties on NodeLists/HTMLCollections are read-only.
But you'd be able to use things like forEach and filter.


Re: [DOM4] NodeList should be deprecated

2012-03-16 Thread Cameron McCormack
Anne van Kesteren:  Okay, annotated NodeList with [ArrayClass]. What 
about HTMLCollection?

Should I add it there too? Could you take a look at NodeList and
HTMLCollection for accuracy?


It is probably not feasible to add to HTMLCollection, because it has a 
named property getter which is not [OverrideBuiltins].  That means that 
all the new properties on the prototype like concat, push, etc. 
would begin to shadow any named elements on the collection.




Re: [DOM4] NodeList should be deprecated

2012-03-16 Thread Cameron McCormack
Cameron McCormack:  It is probably not feasible to add to 
HTMLCollection, because it has a

named property getter which is not [OverrideBuiltins].  That means that
all the new properties on the prototype like concat, push, etc.
would begin to shadow any named elements on the collection.


On the other hand it would be great to be able to do things like:

  document.getElementsByTagName(span)
  .map(function(x) { return x.clientWidth });

:(

I am a bit reluctant to special case the visibility of named properties 
on HTMLCollection to be something other than the current 
[OverrideBuiltins] or non-[OverrideBuiltins] behaviour.




Re: [DOM4] NodeList should be deprecated

2012-03-14 Thread Anne van Kesteren
On Wed, 14 Mar 2012 03:44:16 +0100, Cameron McCormack c...@mcc.id.au  
wrote:

Ojan Vafai:

We should make static NodeList inherit from Array though so that you can
do regular array operations on it.


Web IDL has the means to make (all) NodeList objects inherit from Array  
by annotating them with [ArrayClass], if we want to do that.


Wasn't there a compatibility constrain with doing that?


--
Anne van Kesteren
http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-14 Thread Cameron McCormack

Anne van Kesteren:

Wasn't there a compatibility constrain with doing that?


I don't remember -- the only difference it would make is that 
Object.getPrototypeOf(NodeList.prototype) == Array.prototype.




Re: [DOM4] NodeList should be deprecated

2012-03-14 Thread Anne van Kesteren
On Wed, 14 Mar 2012 09:03:23 +0100, Cameron McCormack c...@mcc.id.au  
wrote:

Anne van Kesteren:

Wasn't there a compatibility constrain with doing that?


I don't remember -- the only difference it would make is that  
Object.getPrototypeOf(NodeList.prototype) == Array.prototype.


Okay, annotated NodeList with [ArrayClass]. What about HTMLCollection?  
Should I add it there too? Could you take a look at NodeList and  
HTMLCollection for accuracy?


Cheers,


--
Anne van Kesteren
http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-13 Thread Anne van Kesteren
On Mon, 12 Mar 2012 21:06:00 +0100, Rick Waldron waldron.r...@gmail.com  
wrote:
On Mar 12, 2012, at 3:06 PM, Anne van Kesteren ann...@opera.com  
wrote:
On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron  
waldron.r...@gmail.com wrote:

The NodeList item() method is a blocker.


Blocker in what way?


As I've always understood it - the item() method is what differentiates  
NodeList from Array and blocks it from being just an array.


Is this incorrect?


I think there is more, such as arrays being mutable, but the suggestion  
was to change two accessors from mutation observers to return platform  
array objects rather than NodeLists, which is a change we can still make  
given that mutation observers is not widely deployed yet.



--
Anne van Kesteren
http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-13 Thread Rick Waldron

On Mar 13, 2012, at 4:29 AM, Anne van Kesteren ann...@opera.com wrote:

 On Mon, 12 Mar 2012 21:06:00 +0100, Rick Waldron waldron.r...@gmail.com 
 wrote:
 On Mar 12, 2012, at 3:06 PM, Anne van Kesteren ann...@opera.com wrote:
 On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron waldron.r...@gmail.com 
 wrote:
 The NodeList item() method is a blocker.
 
 Blocker in what way?
 
 As I've always understood it - the item() method is what differentiates 
 NodeList from Array and blocks it from being just an array.
 
 Is this incorrect?
 
 I think there is more, such as arrays being mutable, but the suggestion was 
 to change two accessors from mutation observers to return platform array 
 objects rather than NodeLists, which is a change we can still make given that 
 mutation observers is not widely deployed yet.

I that case, very cool. Thanks for the clarification.

 
 
 -- 
 Anne van Kesteren
 http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-13 Thread Ojan Vafai
Upon further thought, I take this suggestion back. Static NodeList as it
currently exists is just an underpowered array, but that doesn't mean
that's what it always has to be. In the future, we should add methods to
NodeList that operate on Nodes, e.g. add a remove method to NodeList that
call remove on all the Nodes in the NodeList. Also, in theory, browser may
be able to optimize common cases of NodeLists (e.g. cache frequently
accessed NodeLists).

We should make static NodeList inherit from Array though so that you can do
regular array operations on it.

On Tue, Mar 13, 2012 at 5:59 AM, Rick Waldron waldron.r...@gmail.comwrote:


 On Mar 13, 2012, at 4:29 AM, Anne van Kesteren ann...@opera.com wrote:

  On Mon, 12 Mar 2012 21:06:00 +0100, Rick Waldron waldron.r...@gmail.com
 wrote:
  On Mar 12, 2012, at 3:06 PM, Anne van Kesteren ann...@opera.com
 wrote:
  On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron 
 waldron.r...@gmail.com wrote:
  The NodeList item() method is a blocker.
 
  Blocker in what way?
 
  As I've always understood it - the item() method is what differentiates
 NodeList from Array and blocks it from being just an array.
 
  Is this incorrect?
 
  I think there is more, such as arrays being mutable, but the suggestion
 was to change two accessors from mutation observers to return platform
 array objects rather than NodeLists, which is a change we can still make
 given that mutation observers is not widely deployed yet.

 I that case, very cool. Thanks for the clarification.

 
 
  --
  Anne van Kesteren
  http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-13 Thread Rick Waldron
On Tue, Mar 13, 2012 at 10:24 PM, Ojan Vafai o...@chromium.org wrote:

 Upon further thought, I take this suggestion back. Static NodeList as it
 currently exists is just an underpowered array, but that doesn't mean
 that's what it always has to be. In the future, we should add methods to
 NodeList that operate on Nodes, e.g. add a remove method to NodeList that
 call remove on all the Nodes in the NodeList. Also, in theory, browser may
 be able to optimize common cases of NodeLists (e.g. cache frequently
 accessed NodeLists).

 We should make static NodeList inherit from Array though so that you can
 do regular array operations on it.


In the future, it will be incredibly easy to make a NodeList into an Array
with the spread operator:

[ ...NodeList ]

// [ node, node, node ]

Rick





 On Tue, Mar 13, 2012 at 5:59 AM, Rick Waldron waldron.r...@gmail.comwrote:


 On Mar 13, 2012, at 4:29 AM, Anne van Kesteren ann...@opera.com
 wrote:

  On Mon, 12 Mar 2012 21:06:00 +0100, Rick Waldron 
 waldron.r...@gmail.com wrote:
  On Mar 12, 2012, at 3:06 PM, Anne van Kesteren ann...@opera.com
 wrote:
  On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron 
 waldron.r...@gmail.com wrote:
  The NodeList item() method is a blocker.
 
  Blocker in what way?
 
  As I've always understood it - the item() method is what
 differentiates NodeList from Array and blocks it from being just an array.
 
  Is this incorrect?
 
  I think there is more, such as arrays being mutable, but the suggestion
 was to change two accessors from mutation observers to return platform
 array objects rather than NodeLists, which is a change we can still make
 given that mutation observers is not widely deployed yet.

 I that case, very cool. Thanks for the clarification.

 
 
  --
  Anne van Kesteren
  http://annevankesteren.nl/





Re: [DOM4] NodeList should be deprecated

2012-03-13 Thread Cameron McCormack

Ojan Vafai:

We should make static NodeList inherit from Array though so that you can
do regular array operations on it.


Web IDL has the means to make (all) NodeList objects inherit from Array 
by annotating them with [ArrayClass], if we want to do that.




Re: [DOM4] NodeList should be deprecated

2012-03-12 Thread Adam Klein
On Thu, Mar 8, 2012 at 11:57 PM, Anne van Kesteren ann...@opera.com wrote:

 On Thu, 08 Mar 2012 23:24:45 +0100, Ojan Vafai o...@chromium.org wrote:

 Dynamic NodeLists have a significant memory and performance cost. Static
 NodeLists are basically just under-powered arrays. We should just return
 Node arrays from any new APIs that return a list of Nodes. I'd like to
 see NodeList get similar treatment to hasFeature, i.e. a note that it not be
 used for new APIs and possibly even the explicitly list the APIs allowed
 to return them.

 I don't see the Dynamic/Static distinction in DOM4 or the HTML spec. Is
 this specified anywhere?


 We use the words live and static.



  For reference, this came up in WebKit with some new Regions APIs
 https://bugs.webkit.org/show_**bug.cgi?id=80638https://bugs.webkit.org/show_bug.cgi?id=80638
 .


 Mutation observers uses NodeList too.


Though there's no reason they couldn't use arrays instead (they're not
live). In fact, that would make the API more self-consistent, since arrays
(of MutationRecords) are already part of the interface.

- Adam


Re: [DOM4] NodeList should be deprecated

2012-03-12 Thread Rick Waldron
On Mon, Mar 12, 2012 at 2:00 PM, Adam Klein ad...@chromium.org wrote:

 On Thu, Mar 8, 2012 at 11:57 PM, Anne van Kesteren ann...@opera.comwrote:

 On Thu, 08 Mar 2012 23:24:45 +0100, Ojan Vafai o...@chromium.org wrote:

 Dynamic NodeLists have a significant memory and performance cost. Static
 NodeLists are basically just under-powered arrays. We should just return
 Node arrays from any new APIs that return a list of Nodes. I'd like to
 see NodeList get similar treatment to hasFeature, i.e. a note that it not be
 used for new APIs and possibly even the explicitly list the APIs allowed
 to return them.

 I don't see the Dynamic/Static distinction in DOM4 or the HTML spec. Is
 this specified anywhere?


 We use the words live and static.



  For reference, this came up in WebKit with some new Regions APIs
 https://bugs.webkit.org/show_**bug.cgi?id=80638https://bugs.webkit.org/show_bug.cgi?id=80638
 .


 Mutation observers uses NodeList too.


 Though there's no reason they couldn't use arrays instead (they're not
 live). In fact, that would make the API more self-consistent, since arrays
 (of MutationRecords) are already part of the interface.


The NodeList item() method is a blocker.


Rick




 - Adam



Re: [DOM4] NodeList should be deprecated

2012-03-12 Thread Anne van Kesteren
On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron waldron.r...@gmail.com  
wrote:

The NodeList item() method is a blocker.


Blocker in what way?


--
Anne van Kesteren
http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-12 Thread Rick Waldron
On Mar 12, 2012, at 3:06 PM, Anne van Kesteren ann...@opera.com wrote:

 On Mon, 12 Mar 2012 19:07:31 +0100, Rick Waldron waldron.r...@gmail.com 
 wrote:
 The NodeList item() method is a blocker.
 
 Blocker in what way?

As I've always understood it - the item() method is what differentiates 
NodeList from Array and blocks it from being just an array.

Is this incorrect?

Rick


 
 
 -- 
 Anne van Kesteren
 http://annevankesteren.nl/



Re: [DOM4] NodeList should be deprecated

2012-03-08 Thread Anne van Kesteren

On Thu, 08 Mar 2012 23:24:45 +0100, Ojan Vafai o...@chromium.org wrote:

Dynamic NodeLists have a significant memory and performance cost. Static
NodeLists are basically just under-powered arrays. We should just return
Node arrays from any new APIs that return a list of Nodes. I'd like to  
see NodeList get similar treatment to hasFeature, i.e. a note that it  
not be
used for new APIs and possibly even the explicitly list the APIs allowed  
to return them.


I don't see the Dynamic/Static distinction in DOM4 or the HTML spec. Is
this specified anywhere?


We use the words live and static.



For reference, this came up in WebKit with some new Regions APIs
https://bugs.webkit.org/show_bug.cgi?id=80638.


Mutation observers uses NodeList too.


--
Anne van Kesteren
http://annevankesteren.nl/