Skip to content

Commit 1f20aee

Browse files
jftannerkarfau
authored andcommitted
fix: Backport PR-437 to 0.7.x branch
1 parent 03fcf98 commit 1f20aee

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

lib/dom.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ function arrayIncludes (list) {
6262

6363
function copy(src,dest){
6464
for(var p in src){
65-
dest[p] = src[p];
65+
if (Object.prototype.hasOwnProperty.call(src, p)) {
66+
dest[p] = src[p];
67+
}
6668
}
6769
}
6870

@@ -509,9 +511,9 @@ Node.prototype = {
509511
//console.dir(map)
510512
if(map){
511513
for(var n in map){
512-
if(map[n] == namespaceURI){
513-
return n;
514-
}
514+
if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
515+
return n;
516+
}
515517
}
516518
}
517519
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
@@ -526,7 +528,9 @@ Node.prototype = {
526528
//console.dir(map)
527529
if(map){
528530
if(prefix in map){
529-
return map[prefix] ;
531+
if(Object.prototype.hasOwnProperty.call(map, prefix)){
532+
return map[prefix] ;
533+
}
530534
}
531535
}
532536
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
@@ -1390,11 +1394,13 @@ function importNode(doc,node,deep){
13901394
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
13911395
function cloneNode(doc,node,deep){
13921396
var node2 = new node.constructor();
1393-
for(var n in node){
1394-
var v = node[n];
1395-
if(typeof v != 'object' ){
1396-
if(v != node2[n]){
1397-
node2[n] = v;
1397+
for (var n in node) {
1398+
if (Object.prototype.hasOwnProperty.call(node, n)) {
1399+
var v = node[n];
1400+
if (typeof v != "object") {
1401+
if (v != node2[n]) {
1402+
node2[n] = v;
1403+
}
13981404
}
13991405
}
14001406
}

lib/sax.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
135135
if(endIgnoreCaseMach){
136136
domBuilder.endElement(config.uri,config.localName,tagName);
137137
if(localNSMap){
138-
for(var prefix in localNSMap){
139-
domBuilder.endPrefixMapping(prefix) ;
138+
for(var prefix in localNSMap) {
139+
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
140+
domBuilder.endPrefixMapping(prefix);
141+
}
140142
}
141143
}
142144
if(!endMatch){
@@ -472,8 +474,10 @@ function appendElement(el,domBuilder,currentNSMap){
472474
if(el.closed){
473475
domBuilder.endElement(ns,localName,tagName);
474476
if(localNSMap){
475-
for(prefix in localNSMap){
476-
domBuilder.endPrefixMapping(prefix)
477+
for (prefix in localNSMap) {
478+
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
479+
domBuilder.endPrefixMapping(prefix);
480+
}
477481
}
478482
}
479483
}else{
@@ -519,9 +523,15 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
519523
return pos<elStartEnd;
520524
//}
521525
}
522-
function _copy(source,target){
523-
for(var n in source){target[n] = source[n]}
526+
527+
function _copy (source, target) {
528+
for (var n in source) {
529+
if (Object.prototype.hasOwnProperty.call(source, n)) {
530+
target[n] = source[n];
531+
}
532+
}
524533
}
534+
525535
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
526536
var next= source.charAt(start+2)
527537
switch(next){

0 commit comments

Comments
 (0)