speed up extraction (#1617)

This commit is contained in:
Shuchang Zheng
2025-01-22 22:43:50 +08:00
committed by GitHub
parent b8e9ab85d7
commit ed4d0c59e7
3 changed files with 20 additions and 5 deletions

View File

@@ -703,9 +703,19 @@ function isInteractable(element, hoverStylesMap) {
// Check if element has hover styles that change cursor to pointer
// This is to handle the case where an element's cursor is "auto", but resolves to "pointer" on hover
if (elementCursor === "auto") {
// TODO: we need a better algorithm to match the selector with better performance
for (const [selector, styles] of hoverStylesMap) {
if (element.matches(selector) && styles.cursor === "pointer") {
return true;
let shouldMatch = false;
for (const className of element.classList) {
if (selector.includes(className)) {
shouldMatch = true;
break;
}
}
if (shouldMatch || selector.includes(tagName)) {
if (element.matches(selector) && styles.cursor === "pointer") {
return true;
}
}
}
}