Skip to content

Instantly share code, notes, and snippets.

@Trindaz
Last active August 29, 2015 14:07
Show Gist options
  • Save Trindaz/5d2298b18a85cb6e49d0 to your computer and use it in GitHub Desktop.
Save Trindaz/5d2298b18a85cb6e49d0 to your computer and use it in GitHub Desktop.
DOM Ancestry of non-standard HTML4 attributes
var ancestryOfAttributes = function(targetNode){
result = [];
while(targetNode.parentNode){
var attrs = [];
for(var i=0; i<targetNode.attributes.length; i++){ attrs.push(targetNode.attributes[i].nodeName); }
result.unshift(attrs.join(","));
targetNode = targetNode.parentNode
}
return JSON.stringify(result, undefined, 4);
};
if($0){ ancestryOfAttributes($0); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment