Implement Element.dataset #45

Open
termi opened this Issue Feb 3, 2012 · 5 comments

Comments

Projects
None yet
3 participants
@termi
Collaborator

termi commented Feb 3, 2012

I began to collect information on the possible IE8 shim.
A workaround can be found here http://eligrey.com/blog/post/html-5-dataset-support

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Feb 3, 2012

Owner

The problem with dataset is this.

el.dataset.foo = "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.

Owner

Raynos commented Feb 3, 2012

The problem with dataset is this.

el.dataset.foo = "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.

@termi

This comment has been minimized.

Show comment
Hide comment
@termi

termi Feb 3, 2012

Collaborator

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

el.dataset.foo = "bar";

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

I mean we need more stronger solution.

Collaborator

termi commented Feb 3, 2012

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

el.dataset.foo = "bar";

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

I mean we need more stronger solution.

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Feb 3, 2012

Owner

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
Owner

Raynos commented Feb 3, 2012

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
@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Feb 3, 2012

Owner

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

var e = document.createElement("div");
e.dataset.foo = "bar";
console.log(e.outerHTML);
Owner

Raynos commented Feb 3, 2012

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

var e = document.createElement("div");
e.dataset.foo = "bar";
console.log(e.outerHTML);
@brettz9

This comment has been minimized.

Show comment
Hide comment
@brettz9

brettz9 Dec 13, 2012

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): https://gist.github.com/4093766#file_html5_dataset.js

brettz9 commented Dec 13, 2012

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): https://gist.github.com/4093766#file_html5_dataset.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment