From 0cda170f4d22e9dab588d6d4f3603f0dfa48ecdb Mon Sep 17 00:00:00 2001 From: gholk Date: Tue, 23 Jul 2024 10:08:21 +0800 Subject: [PATCH] allow focusinput focus node in shadow-root It seem that document.contains is to check whether the node is removed, but not to consider about the shadow root. The isConnected property mean whether the node is connect to a document or a shadow root that connected to the root document. It is enough to check whether the document is removed. --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index 535f158a..5b87444e 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -2520,7 +2520,7 @@ export function focusinput(nth: number | string) { // either a number (not special) or we failed to find a special input when // asked and falling back is acceptable - if ((!inputToFocus || !document.contains(inputToFocus)) && fallbackToNumeric) { + if ((!inputToFocus || !inputToFocus.isConnected) && fallbackToNumeric) { const index = isNaN(nth as number) ? 0 : (nth as number) inputToFocus = DOM.getNthElement(INPUTTAGS_selectors, index, [DOM.isSubstantial]) }