Skip to content

Instantly share code, notes, and snippets.

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 adamgen/71f95a29f28041aed28925b4c855e8f7 to your computer and use it in GitHub Desktop.
Save adamgen/71f95a29f28041aed28925b4c855e8f7 to your computer and use it in GitHub Desktop.
getAtts = (elem) => {
const attrs = {};
Object.values(elem.attributes).forEach(attr => {
attrs[attr.name] = attr.value;
});
return attrs
}
atts = getAtts($0);
d3Str = '';
d3Str += `.append('${$0.tagName}')\n`
Object.entries(atts).forEach((touple)=>{
key = touple[0];
value = touple[1];
d3Str += `.attr('${key}', '${value}')\n`;
});
copy(d3Str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment