jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.31k stars 455 forks source link

respect snake case for datasets #584

Closed elShiaLabeouf closed 2 years ago

elShiaLabeouf commented 2 years ago

Hey @jonobr1 :)

I've come up with a small fix for the data attributes that have 2+ hyphens. I didn't take into account that js .dataset property had data attributes in camelCase, which made it rendered like this: Screenshot from 2021-12-22 14-09-29

Found the proper way to copy dataset from an element to another here https://stackoverflow.com/a/20074111 Having this, data attributes are rendered accurately: Screenshot from 2021-12-22 14-09-52

jonobr1 commented 2 years ago

Thanks!

I'm curious why you changed from a for statement to an Object.assign. Do SVG elements not need to setAttribute?

elShiaLabeouf commented 2 years ago

Splendid!

I assume if an HTML element (not only SVG) has a dataset, its data attributes are rendered by javascript automatically via an under-the-hood magic Screenshot from 2021-12-23 11-03-20