Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created December 10, 2016 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robozevel/20d4a92b5f0db2cdef5132713b9a89e6 to your computer and use it in GitHub Desktop.
Save robozevel/20d4a92b5f0db2cdef5132713b9a89e6 to your computer and use it in GitHub Desktop.
(function() {
let props = $$('*')
.filter(x => Object.keys(x.dataset).length)
.reduce((o,x) => {
Object.keys(x.dataset).forEach(key => {
o[key] = key.replace(/[A-Z]/g, y => '-' + y.toLowerCase());
});
return o;
}, {});
return Object.keys(props)
.reduce((o, x) => {
let attr = 'data-' + props[x];
o[attr] = $$('[' + attr + ']')
return o;
}, {});
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment