Skip to content

Commit

Permalink
Merge pull request #5 from MartijnR/fix/var-scope
Browse files Browse the repository at this point in the history
Fix minor variable scope issues
  • Loading branch information
hareko committed Jun 10, 2015
2 parents 378a229 + 83b38ca commit f8f4b38
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mergexml.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,14 @@
*/
var Merge = function(src, pth) {
for (var i = 0; i < src.childNodes.length; i++) {
var tmp;
var node = src.childNodes[i]; //$node->getNodePath()
var path = GetNodePath(src.childNodes, node, pth, i);
var obj = that.Query(path);
if (node.nodeType === XML_ELEMENT_NODE) {
var flg = true; /* replace existing node by default */
if (obj === null || obj.namespaceURI !== node.namespaceURI) {
var tmp = node.cloneNode(true); /* take existing node */
tmp = node.cloneNode(true); /* take existing node */
obj = that.Query(pth); /* destination parent */
obj.appendChild(tmp); /* add a node */
} else {
Expand Down Expand Up @@ -266,10 +267,10 @@
* @return {string} query path
*/
var GetNodePath = function(nodes, node, pth, eln) {
var p;
var p, i;
var j = 0;
if (node.nodeType === XML_ELEMENT_NODE) {
for (var i = 0; i <= eln; i++) {
for (i = 0; i <= eln; i++) {
if ((updn && nodes[i].nodeType === node.nodeType && nodes[i].nodeName === node.nodeName) ||
(!updn && nodes[i].nodeType !== XML_PI_NODE)) {
j++;
Expand Down Expand Up @@ -299,7 +300,7 @@
p = 'node()';
}
} else if (node.nodeType === XML_TEXT_NODE || node.nodeType === XML_COMMENT_NODE) {
for (var i = 0; i <= eln; i++) {
for (i = 0; i <= eln; i++) {
if (nodes[i].nodeType === node.nodeType) {
j++;
}
Expand Down Expand Up @@ -479,7 +480,7 @@
break; /* xPath supported */
}
} catch (e) {
/* skip */;
/* skip */
}
}
if (f) {
Expand Down

0 comments on commit f8f4b38

Please sign in to comment.