dataset

0.3.2 • Public • Published

dataset

Shim for DOM dataset

Installation

$ npm install dataset

API

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 dataset property on HTML elements and - for performance reasons - this shim only checks for dataset support once per load using document.head element to verify the support.

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.2
    598
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.2
    598
  • 0.3.1
    13
  • 0.3.0
    0
  • 0.0.0
    0

Package Sidebar

Install

npm i dataset

Weekly Downloads

611

Version

0.3.2

License

MIT

Last publish

Collaborators

  • tbranyen
  • tootallnate
  • pirxpilot