Closed Bug 807001 Opened 12 years ago Closed 12 years ago

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

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

This is a breaking change for any code using .size() on Map or Set objects. The patch includes fixes for in-tree uses.
Attached patch v1Splinter Review
I considered changing JS_DefineProperty with JSPROP_NATIVE_ACCESSORS so as to make the getter function objects have getter.name == "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]
v1

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+
https://hg.mozilla.org/mozilla-central/rev/47711ed9454d
Status: NEW → RESOLVED
Closed: 12 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
Looking at this diff from v8 http://code.google.com/p/v8/source/detail?r=12875, they seem to set the getter name to "size".
See comment 6 - I updates the docs on MDN (https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Map and https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Set) 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
> https://developer.mozilla.org/en-US/docs/Firefox_19_for_developers too.

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

Attachment

General

Created:
Updated:
Size: