naive-ui/packages/utils/dom/getParentNode.js

13 lines
305 B
JavaScript

/**
* Returns the parentNode or the host of the element until document
* @method
* @param {Element} element
* @returns {Element} parent
*/
export default function getParentNode (element) {
if (element.nodeName === '#document') {
return element
}
return element.parentNode || element.host
}