This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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
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.
If it's the done thing, sure. Fine by me. heycam, any advice?
So what arussell would say here is that we should just use an ES Map for dataset, I bet.
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.
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)?
If you do that, then instanceof DOMStringMap would always return false... Might be ok, though.
So... what's the story here? Why would we use [OverrideBuiltins] at this point?
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.
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).
<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
For what it's worth, I plan to switch this object to [OverrideBuiltins] in Gecko sometime in the next few weeks.
Changing the Gecko behavior in https://bugzilla.mozilla.org/show_bug.cgi?id=874758
Checked in as WHATWG revision r7956. Check-in comment: Make DOMStringMap use [OverrideBuiltins] http://html5.org/tools/web-apps-tracker?from=7955&to=7956
https://github.com/w3c/web-platform-tests/pull/318