JSFiddle - React, Tailwind, and code Playground
by jnbdz
HTML
<div>one</div>
<div data-foo="foo" title = "Chef!">two</div>
<div data-bar="bar" id="one" id="two">three</div>
<div data-foobar="foobar" title="Bobo!" id="bo">three</div>
JavaScript
Elements.implement({
getAllProperties: function() {
var attrs = {},
elements = {},
k = 0;
this.filter(function(element){
var attribs = element.attributes,
len,
i = 0;
elements[k] = element.get('tag');
for (len = attribs.length; i < len; ++i) {
var newValueObj = {};
newValueObj[k] = attribs[i].nodeValue;
var valuesObj = Object.merge(newValueObj, attrs[attribs[i].nodeName]);
attrs[attribs[i].nodeName] = valuesObj;
}
k++;
});
return {
'properties': attrs,
'elements': elements
};
}
});
console.log($$('body *').getAllProperties());