Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Backport PR-437 to 0.7.x branch #441

Merged
merged 2 commits into from Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions lib/dom.js
Expand Up @@ -62,7 +62,9 @@ function arrayIncludes (list) {

function copy(src,dest){
for(var p in src){
dest[p] = src[p];
if (Object.prototype.hasOwnProperty.call(src, p)) {
dest[p] = src[p];
}
}
}

Expand Down Expand Up @@ -509,9 +511,9 @@ Node.prototype = {
//console.dir(map)
if(map){
for(var n in map){
if(map[n] == namespaceURI){
return n;
}
if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
return n;
}
}
}
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
Expand All @@ -526,7 +528,9 @@ Node.prototype = {
//console.dir(map)
if(map){
if(prefix in map){
return map[prefix] ;
if(Object.prototype.hasOwnProperty.call(map, prefix)){
return map[prefix] ;
}
}
}
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
Expand Down Expand Up @@ -1390,11 +1394,13 @@ function importNode(doc,node,deep){
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
function cloneNode(doc,node,deep){
var node2 = new node.constructor();
for(var n in node){
var v = node[n];
if(typeof v != 'object' ){
if(v != node2[n]){
node2[n] = v;
for (var n in node) {
if (Object.prototype.hasOwnProperty.call(node, n)) {
var v = node[n];
if (typeof v != "object") {
if (v != node2[n]) {
node2[n] = v;
}
}
}
}
Expand Down
22 changes: 16 additions & 6 deletions lib/sax.js
Expand Up @@ -135,8 +135,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
if(endIgnoreCaseMach){
domBuilder.endElement(config.uri,config.localName,tagName);
if(localNSMap){
for(var prefix in localNSMap){
domBuilder.endPrefixMapping(prefix) ;
for(var prefix in localNSMap) {
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
domBuilder.endPrefixMapping(prefix);
}
}
}
if(!endMatch){
Expand Down Expand Up @@ -472,8 +474,10 @@ function appendElement(el,domBuilder,currentNSMap){
if(el.closed){
domBuilder.endElement(ns,localName,tagName);
if(localNSMap){
for(prefix in localNSMap){
domBuilder.endPrefixMapping(prefix)
for (prefix in localNSMap) {
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
domBuilder.endPrefixMapping(prefix);
}
}
}
}else{
Expand Down Expand Up @@ -519,9 +523,15 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
return pos<elStartEnd;
//}
}
function _copy(source,target){
for(var n in source){target[n] = source[n]}

function _copy (source, target) {
for (var n in source) {
if (Object.prototype.hasOwnProperty.call(source, n)) {
target[n] = source[n];
}
}
}

function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
var next= source.charAt(start+2)
switch(next){
Expand Down