Merge pull request #2677 from keepassxreboot/fix/check_element_in_treenode_walker

Fix using custom function with elements in TreeWalker
This commit is contained in:
Sami Vänttinen 2025-09-04 16:35:00 +03:00 committed by GitHub
commit 5f4133e8a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -330,7 +330,9 @@ const getShadowDOM = function(elem) {
const treeWalkerFilter = function(node) {
return !node ||
node?.disabled ||
(typeof node?.getAttribute !== 'undefined' && node?.getLowerCaseAttribute('type') === 'hidden')
(node instanceof Element
&& typeof node?.getAttribute === 'function'
&& node?.getLowerCaseAttribute('type') === 'hidden')
? NodeFilter.FILTER_REJECT
: NodeFilter.FILTER_ACCEPT;
};