diff --git a/src/core/document.js b/src/core/document.js index 27cbede28..b67834c96 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -517,7 +517,6 @@ class Page { this.pageDict, PageActionEventType ); - return shadow(this, "jsActions", actions); } } diff --git a/src/core/obj.js b/src/core/obj.js index 717404fcb..c5b2c7b82 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -856,9 +856,6 @@ class Catalog { return shadow(this, "viewerPreferences", prefs); } - /** - * NOTE: "JavaScript" actions are, for now, handled by `get javaScript` below. - */ get openAction() { const obj = this._catDict.get("OpenAction"); const openAction = Object.create(null); @@ -923,9 +920,9 @@ class Catalog { } if (javaScript === null) { - javaScript = Object.create(null); + javaScript = new Map(); } - javaScript[name] = stringToPDFString(js); + javaScript.set(name, stringToPDFString(js)); } if (obj && obj.has("JavaScript")) { @@ -955,23 +952,23 @@ class Catalog { return shadow( this, "javaScript", - javaScript ? Object.values(javaScript) : null + javaScript ? [...javaScript.values()] : null ); } get jsActions() { - const js = this._collectJavaScript(); + const javaScript = this._collectJavaScript(); let actions = collectActions( this.xref, this._catDict, DocumentActionEventType ); - if (!actions && js) { - actions = Object.create(null); - } - if (actions && js) { - for (const [key, val] of Object.entries(js)) { + if (javaScript) { + if (!actions) { + actions = Object.create(null); + } + for (const [key, val] of javaScript) { if (key in actions) { actions[key].push(val); } else { @@ -979,7 +976,6 @@ class Catalog { } } } - return shadow(this, "jsActions", actions); }