Map.prototype.size and Set.prototype.size should be accessor properties

RESOLVED FIXED in mozilla19



7 years ago
7 years ago


(Reporter: jorendorff, Assigned: jorendorff)



Other Branch
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)



(1 attachment)

This is a breaking change for any code using .size() on Map or Set objects. The patch includes fixes for in-tree uses.

Comment 1

7 years ago
Posted patch v1Splinter Review
I considered changing JS_DefineProperty with JSPROP_NATIVE_ACCESSORS so as to make the getter function objects have == "size", but function object .name properties are totally unspecified. Some other time perhaps.
Assignee: general → jorendorff
Attachment #676658 - Flags: review?(jwalden+bmo)
Comment on attachment 676658 [details] [diff] [review]

Review of attachment 676658 [details] [diff] [review]:

Given that the accessors in { get foo() { } } have no name, and perhaps we might want to self-host this or something at some point, it seems best to not have a name, definitely.

I completely agree with the logical argument for .size over .size(), as made in the es-discuss thread; it's totally rational and correct, and we should have .size, not .size().  But when I look at this, this irrationally looks weird and wrong to me.  Maybe it's just because I'm seeing both cases next to each other and there's cross-pollination of smell.  I dunno.  Forward!
Attachment #676658 - Flags: review?(jwalden+bmo) → review+
Last Resolved: 7 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
I just updated the Map and Set documentation, including a note that it changed in FF19
Keywords: dev-doc-needed
Duplicate of this bug: 801393
Looking at this diff from v8, they seem to set the getter name to "size".
See comment 6 - I updates the docs on MDN ( and and cleared dev-doc-needed based on that.  If something else is necessary, please indicate it.
Keywords: dev-doc-needed
(In reply to Kohei Yoshino from comment #10)
> I think this should be mentioned in
> too.

Done :)
You need to log in before you can comment on or make changes to this bug.