From e05da6316590f7b355b2526c2da78d4a3682b65d Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 24 Feb 2024 18:33:47 -0500 Subject: static/js/forms: Early persistence --- static/js/forms.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/js/forms.ts b/static/js/forms.ts index 533623f..e35a4b2 100644 --- a/static/js/forms.ts +++ b/static/js/forms.ts @@ -69,7 +69,7 @@ }); }); - ["storage", "DOMContentLoaded"].forEach(function (event) { + ["storage"].forEach(function (event) { self.addEventListener(event, function () { let stylesheet; @@ -106,4 +106,18 @@ } }); }); + + const early = setInterval(persistence, 4); + + function persistence() { + if (document.styleSheets.length > 0) { + self.dispatchEvent(new Event("storage")); + clearInterval(early); + } + } + + self.addEventListener("DOMContentLoaded", function () { + self.dispatchEvent(new Event("storage")); + clearInterval(early); + }); })(); -- cgit v1.2.3