Bug 16832 - Don't get the length property off platform objects with indexed properties
Summary: Don't get the length property off platform objects with indexed properties
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2012-04-24 07:56 UTC by Ms2ger
Modified: 2012-06-20 05:36 UTC (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ms2ger 2012-04-24 07:56:31 UTC
See discussion starting at <http://krijnhoetmer.nl/irc-logs/developers/20120424#l-1470>. In particular, those objects need not have a length property
Comment 2 Cameron McCormack 2012-06-20 04:20:08 UTC
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?
Comment 3 Boris Zbarsky 2012-06-20 04:30:19 UTC
I'm no longer entirely sure it's a good idea, for what it's worth...
Comment 4 Cameron McCormack 2012-06-20 05:18:18 UTC
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;
Comment 5 Cameron McCormack 2012-06-20 05:36:46 UTC
Oh, #2 is bug 16833 actually.  I did #1:


so I'll mark this bug fixed.