Add a <dialog> polyfill for the generic-legacy build

Please note that this patch is purposely quite basic, e.g. it doesn't add the polyfill-CSS in order to simplify the build process, and things such as `::backdrop` thus isn't working.
However, this patch does ensure that older browsers can at least still *access* all of the previous overlays and that things like e.g. opening of password-protected documents respectively printing still works.
This commit is contained in:
Jonas Jenwald 2022-03-25 14:10:33 +01:00
parent b3d58e1000
commit c9f262c480
3 changed files with 23 additions and 0 deletions

13
package-lock.json generated
View File

@ -21,6 +21,7 @@
"canvas": "^2.9.1", "canvas": "^2.9.1",
"core-js": "^3.21.1", "core-js": "^3.21.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dialog-polyfill": "^0.5.6",
"dommatrix": "^0.0.24", "dommatrix": "^0.0.24",
"es-module-shims": "1.4.7", "es-module-shims": "1.4.7",
"eslint": "^8.11.0", "eslint": "^8.11.0",
@ -4350,6 +4351,12 @@
"kuler": "1.0.x" "kuler": "1.0.x"
} }
}, },
"node_modules/dialog-polyfill": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/dialog-polyfill/-/dialog-polyfill-0.5.6.tgz",
"integrity": "sha512-ZbVDJI9uvxPAKze6z146rmfUZjBqNEwcnFTVamQzXH+svluiV7swmVIGr7miwADgfgt1G2JQIytypM9fbyhX4w==",
"dev": true
},
"node_modules/dir-glob": { "node_modules/dir-glob": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -21951,6 +21958,12 @@
"kuler": "1.0.x" "kuler": "1.0.x"
} }
}, },
"dialog-polyfill": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/dialog-polyfill/-/dialog-polyfill-0.5.6.tgz",
"integrity": "sha512-ZbVDJI9uvxPAKze6z146rmfUZjBqNEwcnFTVamQzXH+svluiV7swmVIGr7miwADgfgt1G2JQIytypM9fbyhX4w==",
"dev": true
},
"dir-glob": { "dir-glob": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",

View File

@ -14,6 +14,7 @@
"canvas": "^2.9.1", "canvas": "^2.9.1",
"core-js": "^3.21.1", "core-js": "^3.21.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dialog-polyfill": "^0.5.6",
"dommatrix": "^0.0.24", "dommatrix": "^0.0.24",
"es-module-shims": "1.4.7", "es-module-shims": "1.4.7",
"eslint": "^8.11.0", "eslint": "^8.11.0",

View File

@ -37,6 +37,15 @@ class OverlayManager {
} }
this.#overlays.set(dialog, { canForceClose }); this.#overlays.set(dialog, { canForceClose });
if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("GENERIC && !SKIP_BABEL") &&
!dialog.showModal
) {
const dialogPolyfill = require("dialog-polyfill/dist/dialog-polyfill.js");
dialogPolyfill.registerDialog(dialog);
}
dialog.addEventListener("cancel", evt => { dialog.addEventListener("cancel", evt => {
this.#active = null; this.#active = null;
}); });