This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26179 - toString should be non enumerable
Summary: toString should be non enumerable
Status: RESOLVED WONTFIX
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
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-23 15:50 UTC by Erik Arvidsson
Modified: 2016-04-21 09:53 UTC (History)
7 users (show)

See Also:


Attachments

Description Erik Arvidsson 2014-06-23 15:50:43 UTC
The toString function should be non enumerable to match ES builtins.

http://heycam.github.io/webidl/#es-stringifier
Comment 1 Boris Zbarsky 2014-06-23 16:34:36 UTC
Does that match current UA behavior for HTMLAnchorElement and Location?
Comment 2 Erik Arvidsson 2014-06-23 16:54:06 UTC
Chrome, Firefox & IE:

window.location.propertyIsEnumerable('toString')
false

Chrome, Firefox & IE:

document.createElement('a').propertyIsEnumerable('toString')
false


However:

Chrome:

HTMLAnchorElement.prototype.propertyIsEnumerable('toString')
false

Firefox & IE:

HTMLAnchorElement.prototype.propertyIsEnumerable('toString')
true

This looks like a bug in IE's and Firefox's DOM bindings
Comment 3 Boris Zbarsky 2014-06-23 17:09:08 UTC
> document.createElement('a').propertyIsEnumerable('toString')

The property is not a property on the element itself.  It's a property on the prototype.  Nonexistent properties report "false" from propertyIsEnumerable (see ES6 19.1.3.4 step 7).  You'd get false for document.createElement('a').propertyIsEnumerable('oblongify') too.

So it sounds like in Firefox and IE this is an enumerable property on the prototype, as per current spec.  It's not clear what you think the bug in their binding implementations is, exactly unless it's "not matching the behavior I want for this property"...

Now maybe we can change browser behavior without breaking sites, given that the property is not enumerable in Chrome.  I checked, and it's not enumerable in Safari either.
Comment 4 Boris Zbarsky 2014-06-23 17:09:43 UTC
HTMLAnchorElement.prototype.toString is enumerable in Presto-based Opera, fwiw.
Comment 5 Erik Arvidsson 2014-06-23 20:35:17 UTC
(In reply to Boris Zbarsky from comment #3)
> > document.createElement('a').propertyIsEnumerable('toString')
> 
> The property is not a property on the element itself.  It's a property on
> the prototype.  Nonexistent properties report "false" from
> propertyIsEnumerable (see ES6 19.1.3.4 step 7).  You'd get false for
> document.createElement('a').propertyIsEnumerable('oblongify') too.

I forgot that propertyIsEnumerable is only for own properties. Then the IE and FF results are consistent.
Comment 6 sof 2016-04-20 13:56:57 UTC
Blink is phasing out the use of non-enumerable toString() and implementing 'stringifier' as spec'ed; see https://bugs.chromium.org/p/chromium/issues/detail?id=306606 and an initial set of these changes ( https://codereview.chromium.org/1905553002/ )
Comment 7 Anne 2016-04-20 14:05:32 UTC
Sigbjørn, does that mean we can close this?
Comment 8 sof 2016-04-20 14:47:53 UTC
How you handle long-opened bugs with no activity I will leave up to you :)

Moving Blink to be stringifier-compatible seems preferable by now; we'll try.
Comment 9 Philip Jägenstedt 2016-04-21 08:50:30 UTC
I think this should be closed, these changes will bring Blink in line with Edge and Firefox, so there's not much reason to think it would change again once interoperable.
Comment 10 Anne 2016-04-21 09:53:38 UTC
WONTFIXING since all implementations will seemingly align here with what was already required.