Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getParentUIElement( domNode ) {
const ancestors = getAncestors( domNode );
// Remove domNode from the list.
ancestors.pop();
while ( ancestors.length ) {
const domNode = ancestors.pop();
const viewNode = this._domToViewMapping.get( domNode );
if ( viewNode && viewNode.is( 'uiElement' ) ) {
return viewNode;
}
}
return null;
}
function _hasDomParentOfType( node, types, boundaryParent ) {
let parents = getAncestors( node );
if ( boundaryParent ) {
parents = parents.slice( parents.indexOf( boundaryParent ) + 1 );
}
return parents.some( parent => parent.tagName && types.includes( parent.tagName.toLowerCase() ) );
}
_getTouchingInlineDomNode( node, getNext ) {
if ( !node.parentNode ) {
return null;
}
const direction = getNext ? 'nextNode' : 'previousNode';
const document = node.ownerDocument;
const topmostParent = getAncestors( node )[ 0 ];
const treeWalker = document.createTreeWalker( topmostParent, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, {
acceptNode( node ) {
if ( isText( node ) ) {
return NodeFilter.FILTER_ACCEPT;
}
if ( node.tagName == 'BR' ) {
return NodeFilter.FILTER_ACCEPT;
}
return NodeFilter.FILTER_SKIP;
}
} );
treeWalker.currentNode = node;