get-dataset

0.0.4 • Public • Published

get dataset

Get a DOM element's or an SVG Element's dataset. Works where .dataset isn't present such as in < IE11.

Installation

npm install get-dataset

How to use

Require get-dataset:

var getDataset = require("get-dataset");

Given this element:

<div class="myDiv" data-prop="value1" data-composed-prop="value2"></div>

To retrieve the dataset:

getDataset(document.querySelector(".myDiv"));

returns:

{
    prop: "value1",
    composedProp: "value2"
};

CHANGELOG

0.0.3 - 0.0.4

  • Fix doc

0.0.2

  • Fix bug where properties of the returned object weren't camelcased. Issue #1.

LICENSE

MIT

Package Sidebar

Install

npm i get-dataset

Weekly Downloads

6

Version

0.0.4

License

none

Last publish

Collaborators

  • podefr