Last active
August 29, 2015 14:07
-
-
Save Trindaz/5d2298b18a85cb6e49d0 to your computer and use it in GitHub Desktop.
DOM Ancestry of non-standard HTML4 attributes
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
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