PhpGt/Dom

Element.dataset

g105b opened this issue · 0 comments

g105b commented

The HTMLElement.dataset property allows access, both in reading and writing mode, to all the custom data attributes (data-*) set on the element.

Note also that an HTML data-attribute and its corresponding DOM dataset.property do not share the same name, but they are always similar:

  • The name of a custom data attribute in HTML begins with data-. It must contain only letters, numbers and the following characters: dash (-), dot (.), colon (:), underscore (_) -- but NOT any ASCII capital letters (A to Z).
  • The name of a custom data attribute in DOM is the name of the same HTML attribute but in camelCase and with no dashes, dots, etc.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset