fix invalid css query on linked elements (#372)

This commit is contained in:
LawyZheng 2024-05-27 15:18:22 +08:00 committed by GitHub
parent 59fa78e642
commit 20f6fd2a10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -830,9 +830,13 @@ function buildTreeFromBody() {
let linkedElements = new Array();
const elementId = currentEle.getAttribute("id");
if (elementId) {
linkedElements = [
...document.querySelectorAll(`label[for="${elementId}"]`),
];
try {
linkedElements = [
...document.querySelectorAll(`label[for="${elementId}"]`),
];
} catch (e) {
console.log("failed to query labels: ", e);
}
}
const labelled = currentEle.getAttribute("aria-labelledby");
if (labelled) {