Skip to content


Implement Element.dataset #45

termi opened this Issue · 5 comments

3 participants


I began to collect information on the possible IE8 shim.
A workaround can be found here


The problem with dataset is this. = "bar";
assert(el.getAttribute("data-foo") === "bar");

This basically means we need to hook getAttribute, setAttribute and hasAttribute up so that it reads from the dataset.


And what about for(var i in element.dataset){ } and Array.from(element.dataset)? = "bar";

means that we need getter/setter, witch IE8 supported only for DOM Element :(

I mean we need more stronger solution.


You don't need getter/setters on .foo you need an ES6 proxy

In theory this should work.

  • dataset when got is pre populated with all the data- attributes
  • You can set/get on the dataset and it will store it internally somewhere.
  • Calls to getAttributes/setAttribute/attributes etc will reflect our internal dataset.
  • We may want to periodically put all the changed attributes of the internal dataset on the actual DOM node through the real APIs

Note things like this will never work. (not without proxies)

var e = document.createElement("div"); = "bar";

Doesn't address the issues mentioned here, but I have updated the original from Eli Grey with some improvements (including some changes taking advantage of his subsequent Xccessors shim):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.