Created
April 1, 2014 09:00
-
-
Save Skateside/9910539 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Creates a string of an element, showing the node name and all attributes. | |
* This is mainly useful for debugging in Internet Explorer where a DOM node | |
* representation isn't shown in the console. | |
* | |
* @param {Element} elem Element to stringify. | |
* @return {string} String representation of the element. | |
*/ | |
function stringifyElem(elem) { | |
var str = '<' + elem.nodeName.toLowerCase(), | |
attrs = elem.attributes, | |
i = 0, | |
il = attrs.length, | |
attr = null; | |
while (i < il) { | |
attr = attrs.item(i); | |
str += ' ' + attr.nodeName + '="' + attr.nodeValue + '"'; | |
i += 1; | |
} | |
return str + '>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment