Function.prototype.toString should print set / get for accessor properties
Categories
(Core :: JavaScript: Standard Library, defect, P3)
Tracking
()
People
(Reporter: twisniewski, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: parity-chrome, parity-safari)
Attachments
(1 file)
WebKit just addressed this in this commit, citing https://tc39.es/ecma262/#sec-function.prototype.tostring
For instance, try Object.getOwnPropertyDescriptor(Map.prototype, "size").get.toString().
In Firefox:
function size() {
[native code]
}
In WebKit 193:
function get size() {
[native code]
}
| Reporter | ||
Updated•1 year ago
|
Comment 1•1 year ago
|
||
https://github.com/tc39/ecma262/pull/1948
We currently skip the get or set prefix explicitly. Just not doing that seems to be sufficient to fix this?
Comment 2•1 year ago
|
||
Comment 3•1 year ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #1)
https://github.com/tc39/ecma262/pull/1948
We currently skip the
getorsetprefix explicitly. Just not doing that seems to be sufficient to fix this?
The spec doesn't actually require that the accessor prefix is part of the output:
- Per Function.prototype.toString the output must contain
func.[[InitialName]]. - Per SetFunctionName,
[[InitialName]]of built-in functions can optionally include the accessor prefix:
Optionally, set F.[[InitialName]] to name.
Updated•1 year ago
|
Comment 4•6 months ago
|
||
It looks Safari ran into repeated web compat problems by shipping this change: https://github.com/tc39/ecma262/issues/3652.
Comment 5•5 months ago
|
||
It seems like we're currently compatible with the spec (setting the prefix is optional), but it sounds like the spec may change to require setting the prefix (possibly with the exception of a list of accessors provided in Annex B).
Given the problems Safari encountered, we should be careful about making changes here. On the TC39 call, Safari indicated it took 6 months for them to get broken site reports.
Description
•