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.
This commit is contained in:
gholk 2024-07-23 10:08:21 +08:00
parent eb1141b8c8
commit 0cda170f4d

View file

@ -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])
}