mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Fixed keydown event handling problem with shadow DOM.
Editable elements in shadow DOMs can not be detected in old version.
This commit is contained in:
parent
139c8a8cb5
commit
252e258a59
2 changed files with 25 additions and 1 deletions
|
@ -985,6 +985,28 @@ function moveToEndOfArray(arr, condition) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active or focused element in current DOM.
|
||||
*
|
||||
* Recursively search for the truly active or focused element in case there are
|
||||
* shadow DOMs.
|
||||
*
|
||||
* @returns {Element} the truly active or focused element.
|
||||
*/
|
||||
function getActiveOrFocusedElement() {
|
||||
let curRoot = document;
|
||||
let curActiveOrFocused =
|
||||
curRoot.activeElement || curRoot.querySelector(":focus");
|
||||
|
||||
while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
|
||||
curRoot = curActiveOrFocused.shadowRoot;
|
||||
curActiveOrFocused =
|
||||
curRoot.activeElement || curRoot.querySelector(":focus");
|
||||
}
|
||||
|
||||
return curActiveOrFocused;
|
||||
}
|
||||
|
||||
export {
|
||||
AutoPrintRegExp,
|
||||
CSS_UNITS,
|
||||
|
@ -1026,4 +1048,5 @@ export {
|
|||
WaitOnType,
|
||||
waitOnEventOrTimeout,
|
||||
moveToEndOfArray,
|
||||
getActiveOrFocusedElement,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue