Socket
Socket
Sign inDemoInstall

dataset

Package Overview
Dependencies
0
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dataset

Shim for DOM dataset


Version published
Weekly downloads
576
increased by1.95%
Maintainers
3
Install size
6.57 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 20 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc