Bugzilla – Bug 16832
Don't get the length property off platform objects with indexed properties
Last modified: 2012-06-20 05:36:46 UTC
See discussion starting at <http://krijnhoetmer.nl/irc-logs/developers/20120424#l-1470>. In particular, those objects need not have a length property
OK, so two things to fix here:
1. We shouldn't look up a "length" property on a platform object that has
indexed properties when we want to know how many there are, since that property
from the prototype could be changed. Instead, we should just know internally
how many indexed properties there are.
2. We should always expose a "length" property on objects that have indexed
properties, and not have to define an IDL attribute for it. If we do this,
then we should require indexed properties not to be sparse (which I think
they currently can be).
Boris mentioned that it might be better to have "length" exposed as a data property rather than an accessor property (and if we do that, then it'll need to be on the object itself rather than on the prototype). Is anyone opposed to doing that?
I'm no longer entirely sure it's a good idea, for what it's worth...
One disadvantage to having "length" automatically be on the prototype is that there's no way in the IDL to indicate whether this is writable. It's clear if you have to explicitly include:
attribute unsigned long length;
Oh, #2 is bug 16833 actually. I did #1:
so I'll mark this bug fixed.