Skip to content

Commit

Permalink
convert attribute's value to string in setAttributeNS
Browse files Browse the repository at this point in the history
If setAttributeNS is used with non-string attribute values, we can be in trouble when we e.g. try to serialize the XML :

TypeError: Object 11900 has no method 'replace'
    at serializeToString ([...]/node_modules/xmldom/dom.js:952:49)
    at serializeToString ([...]/xmldom/dom.js:923:4)
    at serializeToString ([...]/node_modules/xmldom/dom.js:947:4)
    at XMLSerializer.serializeToString ([...]/node_modules/xmldom/dom.js:907:2)
    at Document.Node.toString ([...]/node_modules/xmldom/dom.js:911:33)
    [...]

This is already done in setAttribute.
  • Loading branch information
raphj committed May 4, 2014
1 parent c033b19 commit 73aebb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ Element.prototype = {
},
setAttributeNS : function(namespaceURI, qualifiedName, value){
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
attr.value = attr.nodeValue = value;
attr.value = attr.nodeValue = "" + value;
this.setAttributeNode(attr)
},
getAttributeNodeNS : function(namespaceURI, localName){
Expand Down

0 comments on commit 73aebb7

Please sign in to comment.