From 386a7d64b0b34bef04d969aa555117cbcb31be0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Thu, 22 Apr 2021 21:28:03 +0300 Subject: [PATCH] Fix nav block e2e test --- packages/block-editor/src/utils/dom.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/utils/dom.js b/packages/block-editor/src/utils/dom.js index 248587311d1d2..23c66abf7ec02 100644 --- a/packages/block-editor/src/utils/dom.js +++ b/packages/block-editor/src/utils/dom.js @@ -1,3 +1,7 @@ +// Consider the block appender to be a child block of its own, which also has +// this class. +const BLOCK_SELECTOR = '.wp-block'; + /** * Given a block client ID, returns the corresponding DOM node for the block, * if exists. As much as possible, this helper should be avoided, and used only @@ -40,10 +44,7 @@ export function getBlockPreviewContainerDOMNode( clientId, doc ) { * @return {boolean} Whether elements are in the same block. */ export function isInSameBlock( a, b ) { - return ( - a.closest( '.block-editor-block-list__block' ) === - b.closest( '.block-editor-block-list__block' ) - ); + return a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR ); } /** @@ -57,7 +58,7 @@ export function isInSameBlock( a, b ) { * children. */ export function isInsideRootBlock( blockElement, element ) { - const parentBlock = element.closest( '.block-editor-block-list__block' ); + const parentBlock = element.closest( BLOCK_SELECTOR ); return parentBlock === blockElement; } @@ -79,7 +80,7 @@ export function getBlockClientId( node ) { } const elementNode = /** @type {Element} */ ( node ); - const blockNode = elementNode.closest( '.block-editor-block-list__block' ); + const blockNode = elementNode.closest( BLOCK_SELECTOR ); if ( ! blockNode ) { return;