mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-10-11 06:41:29 +00:00
Implement invoker commands for older browsers like Firefox ESR
Fixes #773
This commit is contained in:
1 parent
16deaaf4eb
commit
3321387d4f
1 file changed
+27
@@ -1,6 +1,33 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// Implement invoker commands for older browsers like Firefox ESR
|
||||
// This can likely be removed in April 2027 when ESR 115 ends
|
||||
if (!("command" in HTMLButtonElement.prototype &&
|
||||
"commandForElement" in HTMLButtonElement.prototype)) {
|
||||
// Delegate so buttons parsed after this script (including dialog close buttons) work.
|
||||
document.addEventListener("click", function (event) {
|
||||
var button = event.target.closest("button[command][commandfor]");
|
||||
if (!button || button.matches(":disabled") || event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = document.getElementById(button.getAttribute("commandfor"));
|
||||
if (!target || target.localName !== "dialog") {
|
||||
return;
|
||||
}
|
||||
|
||||
var command = button.getAttribute("command").toLowerCase();
|
||||
if (command === "show-modal" && typeof target.showModal === "function") {
|
||||
event.preventDefault();
|
||||
target.showModal();
|
||||
} else if (command === "close" && typeof target.close === "function") {
|
||||
event.preventDefault();
|
||||
target.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
var topbarToggle = event.target.closest(".top-bar .toggle-topbar a");
|
||||
if (topbarToggle) {
|
||||
|
||||
Reference in new issue
Block a user