This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Reading http://dev.w3.org/2006/webapi/WebIDL/#es-sequence Where the algorithm goes: " Let n be the result of calling ToUint32(length). Initialize S0..n−1 to be an IDL sequence with elements of type T, where each element is uninitialized. While i < n: Let P be the result of calling ToString(i). Let E be the result of calling [[Get]] on V with property name P. " P will just be "1", "2", "3", and so on, but not the actual property name. And hence E will just be undefined.
What do you mean by "actual property name"? In ECMAScript, all property names are strings. So for example the array [ "a", "b" ] has properties named "0" and "1" (as well as "length").
You are correct, but how does this work if the object passed is: {foo: "x", bar: "y"}
Then it doesn't have indexed properties, right? And no length, either. So in terms of conversion to a sequence it's exactly the same as passing in the empty array [].
(In reply to comment #3) > Then it doesn't have indexed properties, right? And no length, either. So > in terms of conversion to a sequence it's exactly the same as passing in the > empty array []. ah, ok. In the case of [[Get]] length being ``undefined`` calling `ToUint32(length)` converts it to a +0. Thanks for clarifying, Boris. Closing as invalid.
Just one more minor thing (which may be JS implementation specific)... calling new Array(-1) causes Array to throw a "RangeError: Invalid array length", as happens in the following case: length = undefined; //Let n be the result of calling ToUint32(length). n = ToUint32(length); //0 //Initialize S[0..n−1] to be an IDL sequence with elements of type T, //where each element is uninitialized. S = new Array(n - 1); Does that matter?
> S = new Array(n - 1); That line of code is just wrong, no?
(In reply to comment #6) > > S = new Array(n - 1); > > That line of code is just wrong, no? Dunno. I'm just doing what the spec says.
No, you're not. You're passing in the wrong length. The correct thing to pass in is "n".
(In reply to comment #8) > No, you're not. You're passing in the wrong length. The correct thing to > pass in is "n". ah, got thrown by the "..n−1" bit.
Right, the indices range from 0 to n-1.