dataset

Shim for DOM dataset

dataset

Shim for DOM dataset

Installation

$ npm install dataset

API

To set data-xxxattribute on nodeto 5:

dataset(node, 'xxx', 5);

To retrieve data-xxxattribute value:

dataset(node, 'xxx');

To remove data-xxxattribute:

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 notuse on SVG/MathML elements: most browsers only support datasetproperty on HTML elements and - for performance reasons - this shim only checks for datasetsupport once per load using document.headelement to verify the support.

License

MIT

HomePage

https://github.com/pirxpilot/dataset

Repository

https://github.com/pirxpilot/dataset


上一篇:fetchagent
下一篇:metalsmith-serve

相关推荐

官方社区

扫码加入 JavaScript 社区