Created
December 10, 2016 13:16
-
-
Save robozevel/20d4a92b5f0db2cdef5132713b9a89e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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