Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#450@trivial: Continue on Range implementation.
- Loading branch information
1 parent
d3da6e2
commit ca7052d
Showing
12 changed files
with
310 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import INode from './INode'; | ||
|
||
/** | ||
* Node utility. | ||
*/ | ||
export default class NodeUtility { | ||
/** | ||
* Returns boolean indicating if nodeB is an inclusive ancestor of nodeA. | ||
* | ||
* @see https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor | ||
* @param nodeA Node A. | ||
* @param nodeB Node B. | ||
* @returns "true" if following. | ||
*/ | ||
public static isInclusiveAncestor(nodeA: INode, nodeB: INode): boolean { | ||
let parent: INode = nodeA; | ||
while (parent) { | ||
if (parent === nodeB) { | ||
return true; | ||
} | ||
parent = parent.parentNode; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns boolean indicating if nodeB is following nodeA in the document tree. | ||
* | ||
* @see https://dom.spec.whatwg.org/#concept-tree-following | ||
* @param nodeA Node A. | ||
* @param nodeB Node B. | ||
* @returns "true" if following. | ||
*/ | ||
public static isFollowing(nodeA: INode, nodeB: INode): boolean { | ||
let current: INode = nodeA.nextSibling; | ||
while (current) { | ||
if (current === nodeB) { | ||
return true; | ||
} | ||
const nextSibling = current.nextSibling; | ||
current = nextSibling ? nextSibling : current.parentNode; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.