Skip to content

Commit

Permalink
Merge pull request #292 from srowhani/fix/contains
Browse files Browse the repository at this point in the history
fix(node): add guard around node.contains
  • Loading branch information
tonyganch authored Oct 18, 2018
2 parents 75d5010 + 9218c26 commit 7c9ba83
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/node/basic-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Node {
* @return {Boolean} Whether there is a child node of given type
*/
contains(type) {
if (!Array.isArray(this.content)) {
return false;
}

return this.content.some(function(node) {
return node.type === type;
});
Expand Down

0 comments on commit 7c9ba83

Please sign in to comment.