1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #16891 from Snuffleupagus/structElement-removeNullCharacters

Ignore null-chars when using structTree-data in the viewer
This commit is contained in:
Jonas Jenwald 2023-08-31 18:09:04 +02:00 committed by GitHub
commit 9190445a21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -13,6 +13,8 @@
* limitations under the License.
*/
import { removeNullCharacters } from "./ui_utils.js";
const PDF_ROLE_TO_HTML_ROLE = {
// Document level structure types
Document: null, // There's a "document" role, but it doesn't make sense here.
@ -102,13 +104,16 @@ class StructTreeLayerBuilder {
#setAttributes(structElement, htmlElement) {
const { alt, id, lang } = structElement;
if (alt !== undefined) {
htmlElement.setAttribute("aria-label", alt);
htmlElement.setAttribute("aria-label", removeNullCharacters(alt));
}
if (id !== undefined) {
htmlElement.setAttribute("aria-owns", id);
}
if (lang !== undefined) {
htmlElement.setAttribute("lang", lang);
htmlElement.setAttribute(
"lang",
removeNullCharacters(lang, /* replaceInvisible = */ true)
);
}
}