Do not search for elements if no previews have been registered

The findNearestEligibleTarget method is now being called with an
empty array and thus an empty string as a selector

Follow up to
I5f293a134521f086c9f62babb9d06cd9c51d7d47

Bug: T355933
Bug: T356186
Bug: T356193
Change-Id: I3af44ae65d5097fc44744838a4edb07552568b17
This commit is contained in:
Jon Robson 2024-01-30 08:33:51 -08:00 committed by Bartosz Dziewoński
parent 8e4996485f
commit 51059828bf
3 changed files with 5 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View file

@ -123,8 +123,11 @@ const elementMatchesSelector = ( element, selector ) => {
* @return {HTMLElement|null} * @return {HTMLElement|null}
*/ */
export function findNearestEligibleTarget( element ) { export function findNearestEligibleTarget( element ) {
const selector = selectors.join( ', ' ); if ( selectors.length ) {
return element.closest( selector ); const selector = selectors.join( ', ' );
return element.closest( selector );
}
return null;
} }
/** /**