Better emulation of SVG events.
This commit is contained in:
parent
d672267286
commit
826d85274d
|
@ -44,7 +44,7 @@
|
||||||
debug("Soft reload", ev); // DEV_ONLY
|
debug("Soft reload", ev); // DEV_ONLY
|
||||||
try {
|
try {
|
||||||
let doc = window.wrappedJSObject.document;
|
let doc = window.wrappedJSObject.document;
|
||||||
removeEventListener("DOMContentLoaded", softReload, true);
|
if (ev) ev.currentTarget.removeEventListener(ev.type, softReload, true);
|
||||||
|
|
||||||
let isDir = document.querySelector("link[rel=stylesheet][href^='chrome:']")
|
let isDir = document.querySelector("link[rel=stylesheet][href^='chrome:']")
|
||||||
&& document.querySelector(`base[href^="${url}"]`);
|
&& document.querySelector(`base[href^="${url}"]`);
|
||||||
|
@ -61,6 +61,19 @@
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debug("Can't use document.write(), XML document?", e);
|
debug("Can't use document.write(), XML document?", e);
|
||||||
try {
|
try {
|
||||||
|
let eventSuppressor = ev => {
|
||||||
|
if (ev.isTrusted) {
|
||||||
|
debug("Suppressing natural event", ev);
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopImmediatePropagation();
|
||||||
|
ev.currentTarget.removeEventListener(ev.type, eventSuppressor, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let svg = document.documentElement instanceof SVGElement;
|
||||||
|
if (svg) {
|
||||||
|
document.addEventListener("SVGLoad", eventSuppressor, true);
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", eventSuppressor, true);
|
||||||
DocumentFreezer.unfreeze();
|
DocumentFreezer.unfreeze();
|
||||||
let scripts = [], deferred = [];
|
let scripts = [], deferred = [];
|
||||||
// push deferred scripts, if any, to the end
|
// push deferred scripts, if any, to the end
|
||||||
|
@ -94,9 +107,9 @@
|
||||||
debug("Replaced", clone);
|
debug("Replaced", clone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
debug("ALl scripts done, firing completion events.");
|
debug("All scripts done, firing completion events.");
|
||||||
document.dispatchEvent(new Event("readystatechange"));
|
document.dispatchEvent(new Event("readystatechange"));
|
||||||
if (document.documentElement instanceof SVGElement) {
|
if (svg) {
|
||||||
document.documentElement.dispatchEvent(new Event("SVGLoad"));
|
document.documentElement.dispatchEvent(new Event("SVGLoad"));
|
||||||
}
|
}
|
||||||
document.dispatchEvent(new Event("DOMContentLoaded", {
|
document.dispatchEvent(new Event("DOMContentLoaded", {
|
||||||
|
|
Loading…
Reference in New Issue