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

RESOLVED FIXED in mozilla19

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: jorendorff, Assigned: jorendorff)

Tracking

({dev-doc-complete})

Other Branch
mozilla19
dev-doc-complete
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

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

Comment 1

5 years ago
Created attachment 676658 [details] [diff] [review]
v1

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+
(Assignee)

Comment 3

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/47711ed9454d

Comment 4

5 years ago
Please update MDN:

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Map
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Set
Keywords: dev-doc-needed
https://hg.mozilla.org/mozilla-central/rev/47711ed9454d
Status: NEW → RESOLVED
Last Resolved: 5 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

Updated

5 years ago
Duplicate of this bug: 801393
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".

Updated

5 years ago
Keywords: dev-doc-needed
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
I think this should be mentioned in https://developer.mozilla.org/en-US/docs/Firefox_19_for_developers too.
(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!
Keywords: dev-doc-complete
You need to log in before you can comment on or make changes to this bug.