Skip to content

Instantly share code, notes, and snippets.

@jmmcduffie
Created April 8, 2015 19:06
Show Gist options
  • Save jmmcduffie/964f2a6069d642b22e2b to your computer and use it in GitHub Desktop.
Save jmmcduffie/964f2a6069d642b22e2b to your computer and use it in GitHub Desktop.
Data Attribute Object
function extractDataObjects(node) {
var objects = {},
attributes = [].slice.call(node.attributes);
attributes.forEach(function(attribute) {
if (/^data-/.test(attribute.nodeName)) {
objects[attribute.nodeName.slice(5)] = attribute.value;
}
});
return objects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment