Created
July 30, 2013 20:20
-
-
Save bgrins/6116556 to your computer and use it in GitHub Desktop.
Given a string convert it into an array of name/value objects
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
| function escapeAttributeValues(attr, aAttrNode) { | |
| let div = aAttrNode.ownerDocument.createElement("div"); | |
| div.innerHTML = "<div " + attr + "></div>"; | |
| var attributes=[]; | |
| var el = div.childNodes[0]; | |
| for (var i=0, l=el.attributes.length; i<l; i++){ | |
| let attr = el.attributes.item(i) | |
| attributes.push({name:attr.nodeName, value: attr.nodeValue}); | |
| } | |
| return attributes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment