21 lines
383 B
JavaScript
21 lines
383 B
JavaScript
|
|
/**
|
|
* Check if `parent` is a parent of `child`.
|
|
*
|
|
* @param {Type} parent
|
|
* @param {Type} child
|
|
* @return {Boolean} Whether `parent` is a parent of `child`.
|
|
*
|
|
* @public
|
|
*/
|
|
export default function isParentOf (parent, child) {
|
|
child = child._parent
|
|
while (child !== null) {
|
|
if (child === parent) {
|
|
return true
|
|
}
|
|
child = child._parent
|
|
}
|
|
return false
|
|
}
|