From 532406427b207b01d605ebfcd3d7d9b866cc0647 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 25 Mar 2025 10:03:15 +0100 Subject: [PATCH] Simplify the `StructElementNode.prototype.role` getter a tiny bit Given that the `roleMap` only contains `Name`-strings, the lookup can be simplified thanks to modern JavaScript features. --- src/core/struct_tree.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/struct_tree.js b/src/core/struct_tree.js index a83ad813f..a8766e92e 100644 --- a/src/core/struct_tree.js +++ b/src/core/struct_tree.js @@ -551,10 +551,7 @@ class StructElementNode { const nameObj = this.dict.get("S"); const name = nameObj instanceof Name ? nameObj.name : ""; const { root } = this.tree; - if (root.roleMap.has(name)) { - return root.roleMap.get(name); - } - return name; + return root.roleMap.get(name) ?? name; } parseKids() {