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
(cherry picked from commit 51059828bf)
This commit is contained in:
Jon Robson 2024-01-30 08:33:51 -08:00 committed by James D. Forrester
parent 8fc7222b26
commit 4fd7cc93b7
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}
*/
export function findNearestEligibleTarget( element ) {
const selector = selectors.join( ', ' );
return element.closest( selector );
if ( selectors.length ) {
const selector = selectors.join( ', ' );
return element.closest( selector );
}
return null;
}
/**