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 19611 - Should DOMStringMap use [OverrideBuiltins]?
Summary: Should DOMStringMap use [OverrideBuiltins]?
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords: has-testcase
Depends on:
Blocks:
 
Reported: 2012-10-18 22:20 UTC by contributor
Modified: 2013-09-02 09:58 UTC (History)
6 users (show)

See Also:


Attachments

Description contributor 2012-10-18 22:20:47 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html
Multipage: http://www.whatwg.org/C#domstringmap-0
Complete: http://www.whatwg.org/c#domstringmap-0

Comment:
Should DOMStringMap use [OverrideBuiltins]?

Posted from: 173.48.30.113 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/19.0 Firefox/19.0
Comment 1 Boris Zbarsky 2012-10-18 22:21:31 UTC
It seems like there's not that much value in allowing through stuff from up the proto chain on DOMStringMap, in general.  Certainly not for the dataset use of it.
Comment 2 Ian 'Hixie' Hickson 2012-10-19 20:11:47 UTC
If it's the done thing, sure. Fine by me. heycam, any advice?
Comment 3 Boris Zbarsky 2012-11-26 04:49:25 UTC
So what arussell would say here is that we should just use an ES Map for dataset, I bet.
Comment 4 Boris Zbarsky 2012-11-26 04:50:14 UTC
And the problem then becomes one of implementing in a way that updates the Map lazily, because most of the time no one cares about it.
Comment 5 Anne 2013-01-02 15:50:52 UTC
Using ES Map at this point is not backwards compatible, but we should probably use something like it the next time we have such an API.

OverrideBuiltins makes sense to me, or maybe we should empty the prototype chain? Like Object.create(null)?
Comment 6 Boris Zbarsky 2013-01-02 16:04:14 UTC
If you do that, then instanceof DOMStringMap would always return false...  Might be ok, though.
Comment 7 Ian 'Hixie' Hickson 2013-03-06 20:50:43 UTC
So... what's the story here? Why would we use [OverrideBuiltins] at this point?
Comment 8 Boris Zbarsky 2013-03-06 22:14:44 UTC
Do we want to allow storing something with the key "toString" in the DOMStringMap?  What about the key "constructor"?  What about "toSource", "valueOf", "toLocaleString", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", and whatever else ES adds to Object.prototype in the future?

That's the real question here.

(Note also that here are other unsafe keys depending on what browser you're in: "watch", "__proto__", "__lookupGetter__", etc).

Note that as far as I can tell WebKit already implements this with [OverrideBuiltins] or something.  Try this in Chrome or Safari:

<script>
  var d = document.documentElement;
  alert(d.dataset.__proto__Z);
  d.dataset.__proto__ = 5;
  alert(d.dataset.__proto__);
</script>

or similar with valueOf or whatnot.
Comment 9 Boris Zbarsky 2013-03-06 22:17:17 UTC
Or even simpler:

<!DOCTYPE html>
<script>
  var d = document.documentElement;
  Object.prototype.foo = 7;
  alert(d.dataset.foo);
  d.dataset.foo = 5;
  alert(d.dataset.foo);
</script>

(and compare to the Gecko or Presto behavior, which follows the current spec).
Comment 10 Ian 'Hixie' Hickson 2013-04-13 15:12:06 UTC
<heycam> Hixie, so my opinion on the DOMStringMap thing is that it would be nicer if it were [OverrideBuiltins], so you don't get the other properties from Object.prototype shining through
Comment 11 Boris Zbarsky 2013-05-14 16:20:41 UTC
For what it's worth, I plan to switch this object to [OverrideBuiltins] in Gecko sometime in the next few weeks.
Comment 12 Boris Zbarsky 2013-05-22 04:41:24 UTC
Changing the Gecko behavior in https://bugzilla.mozilla.org/show_bug.cgi?id=874758
Comment 13 contributor 2013-06-11 22:09:12 UTC
Checked in as WHATWG revision r7956.
Check-in comment: Make DOMStringMap use [OverrideBuiltins]
http://html5.org/tools/web-apps-tracker?from=7955&to=7956