You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/node.js
+12
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,18 @@ class Node {
11
11
12
12
this.children=this.children||[];
13
13
}
14
+
// Returns a boolean value indicating whether a node is a descendant of a given node or not.
15
+
// @param {object} node Specifies the node that may be contained by (a descendant of) a specified node.
16
+
// @return {boolean} Returns true if a node is a descendant of a specified node, otherwise false. A descendant can be a child, grandchild, great-grandchild, and so on.
17
+
contains(node){
18
+
while((nodeinstanceofNode)&&(node!==this)){
19
+
if(node.parent===this){
20
+
returntrue;
21
+
}
22
+
node=node.parent;
23
+
}
24
+
returnfalse;
25
+
}
14
26
// Gets a child node at the specified index.
15
27
// @param {number} The index of the child node.
16
28
// @return {object} Returns an object that defines the node, null otherwise.
0 commit comments