deno-dom icon indicating copy to clipboard operation
deno-dom copied to clipboard

data-attributes -> dataset

Open caperaven opened this issue 2 years ago • 1 comments

I would like to use this library to help mocking out the dom for deno tests. It seems like dataset properties are not supported?

    const h1 = document.querySelector("h1");
    h1.setAttribute("data-test", "test");
    const result = h1.dataset.test;

dataset seems to be undefined in the element.

caperaven avatar Jul 07 '22 12:07 caperaven

Yeah. Dataset looks like it probably needs to be a Proxy... I'll get to work on it soon

b-fuze avatar Jul 09 '22 14:07 b-fuze

In the meantime, you can use element.attributes.getNamedItem('data-MYVALUE')?.value; to access data attributes.

jdoleary avatar Sep 04 '23 01:09 jdoleary

No rush (I really appreciate all the work done in this awesome library), but I would like to know if there are plans to implement this feature anytime soon.

This issue prevents to use the latest version of highlight.js, because it usesdataset to store some data and it fails.

oscarotero avatar Oct 25 '23 17:10 oscarotero

Yeah, I got an implementation ready

b-fuze avatar Oct 26 '23 04:10 b-fuze

thanks so much!

oscarotero avatar Oct 26 '23 09:10 oscarotero