dataset
v0.3.2
Published
Shim for DOM dataset
Readme
dataset
Shim for DOM dataset
Installation
$ npm install datasetAPI
To set data-xxx attribute on node to 5:
dataset(node, 'xxx', 5);To retrieve data-xxx attribute value:
dataset(node, 'xxx');To remove data-xxx attribute:
dataset(node).del('xxx');You can chain your sets:
dataset(node)
.set('xxx', 5)
.set('foo', 'bongo');Caveats
- You might not need it: dataset is supported by all modern browsers
- Do not use on SVG/MathML elements: most browsers only support
datasetproperty on HTML elements and - for performance reasons - this shim only checks fordatasetsupport once per load usingdocument.headelement to verify the support.
License
MIT
