Re: QSA, the problem with ":scope", and naming

On 10/31/11 9:32 PM, Charles Pritchard wrote:
> Structured cloning fails for NodeList, same as postMessage, because of
> circular structure.

What circular structure?  Structured clone can handle that.

It fails because it's a host object (based on its [[Class]]) that's not 
whitelisted in the structured clone algorithm.

> With .join, you get the .toString of the DOM Nodes.

Yes, as you would for an array of DOM nodes.

A quick skim through the ES spec shows that Array.prototype.concat also 
considers the [[Class]] of its arguments, by the way.  And indeed, this 
testcase:

   <script>
     var l = document.getElementsByTagName("html");
     var a = Array.prototype.slice.call(l);
     l.__proto__.__proto__ = Array.prototype;
     var test1 = [].concat(l);
     var test2 = [].concat(a);
     alert(test1[0] instanceof HTMLHtmlElement);
     alert(test2[0] instanceof HTMLHtmlElement);
   </script>

alerts "false" followed by "true" in UAs.

So we really do need to decide what it means for a return value to "be 
an Array".  For example, how does it behave with concat()?

-Boris

Received on Tuesday, 1 November 2011 01:52:03 UTC