Merge pull request #15311 from Snuffleupagus/text-a11y-removed-element

Don't add `aria-owns` attributes for non-existent elements (PR 15237 follow-up)
This commit is contained in:
Jonas Jenwald 2022-08-14 09:31:29 +02:00 committed by GitHub
commit 2b66ed5fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,6 +97,13 @@ class TextAccessibilityManager {
// we restore them.
const textChildren = this.#textChildren;
for (const [id, nodeIndex] of this.#textNodes) {
const element = document.getElementById(id);
if (!element) {
// If the page was *fully* reset the element no longer exists, and it
// will be re-inserted later (i.e. when the annotationLayer renders).
this.#textNodes.delete(id);
continue;
}
this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
}
}