Skip to content

Commit

Permalink
TooTallNate#66 - fixed empty key
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Goldis committed Jan 26, 2016
1 parent 6952057 commit 421c7f2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ function shouldIgnoreNode (node) {
|| node.nodeType === 4; // cdata
}

/**
* Check if the node is empty. Some plist file has such node:
* <key />
* this node shoud be ignored.
*
* @see https://github.com/TooTallNate/plist.js/issues/66
* @param {Element} node
* @returns {Boolean}
* @api private
*/
function isEmptyNode(node){
if(!node.childNodes || node.childNodes.length == 0) {
return true;
} else {
return false;
}
}

/**
* Parses a Plist XML string. Returns an Object.
Expand Down Expand Up @@ -118,7 +135,7 @@ function parsePlistXML (node) {
new_arr = [];
for (i=0; i < node.childNodes.length; i++) {
// ignore comment nodes (text)
if (!shouldIgnoreNode(node.childNodes[i])) {
if (!shouldIgnoreNode(node.childNodes[i]) && !isEmptyNode(node)) {
new_arr.push( parsePlistXML(node.childNodes[i]));
}
}
Expand Down

0 comments on commit 421c7f2

Please sign in to comment.