Skip to content

Commit

Permalink
Fix nav block e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Apr 23, 2021
1 parent 1e119dc commit 386a7d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 );
}

/**
Expand All @@ -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;
}

Expand All @@ -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;
Expand Down

0 comments on commit 386a7d6

Please sign in to comment.