Skip to content

Commit

Permalink
fix: Prototype fields conflict with dom attributes
Browse files Browse the repository at this point in the history
As noted in issue xmldom#252 some attributes conflict with prototype fields (such as an attribute `constructor`) thus we must remove the `in` operator and replace with `Object.prototype.hasOwnProperty()`.
  • Loading branch information
dsimpsonOMF committed Sep 1, 2021
1 parent d8e8d3e commit 5c9bf42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sax.js
Expand Up @@ -230,7 +230,7 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
* @param {number} startIndex
*/
function addAttribute(qname, value, startIndex) {
if (qname in el.attributeNames) errorHandler.fatalError('Attribute ' + qname + ' redefined')
if (el.attributeNames.hasOwnProperty(qname)) errorHandler.fatalError('Attribute ' + qname + ' redefined')
el.addValue(qname, value, startIndex)
}
var attrName;
Expand Down

0 comments on commit 5c9bf42

Please sign in to comment.