From 28c1e77b60158d58e3d6d136ba3fb02936109fb4 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 24 Jan 2025 11:15:27 +0000 Subject: [PATCH] Make sure rootwidget is available before background actions start --- core/modules/startup/load-modules.js | 10 ++++++++++ core/modules/startup/startup.js | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/modules/startup/load-modules.js b/core/modules/startup/load-modules.js index deb6493c6..37e4c7825 100644 --- a/core/modules/startup/load-modules.js +++ b/core/modules/startup/load-modules.js @@ -19,6 +19,8 @@ exports.synchronous = true; // Set to `true` to enable performance instrumentation var PERFORMANCE_INSTRUMENTATION_CONFIG_TITLE = "$:/config/Performance/Instrumentation"; +var widget = require("$:/core/modules/widgets/widget.js"); + exports.startup = function() { // Load modules $tw.modules.applyMethods("utils",$tw.utils); @@ -42,6 +44,14 @@ exports.startup = function() { // The rest of the startup process here is not strictly to do with loading modules, but are needed before other startup // modules are executed. It is easier to put them here than to introduce a new startup module // -------------------------- + // Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers + $tw.rootWidget = new widget.widget({ + type: "widget", + children: [] + },{ + wiki: $tw.wiki, + document: $tw.browser ? document : $tw.fakeDocument + }); // Set up the performance framework $tw.perf = new $tw.Performance($tw.wiki.getTiddlerText(PERFORMANCE_INSTRUMENTATION_CONFIG_TITLE,"no") === "yes"); // Kick off the filter tracker diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index 9092c5026..21e756b30 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -17,8 +17,6 @@ exports.name = "startup"; exports.after = ["load-modules"]; exports.synchronous = true; -var widget = require("$:/core/modules/widgets/widget.js"); - exports.startup = function() { // Minimal browser detection if($tw.browser) { @@ -54,14 +52,6 @@ exports.startup = function() { } // Initialise version $tw.version = $tw.utils.extractVersionInfo(); - // Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers - $tw.rootWidget = new widget.widget({ - type: "widget", - children: [] - },{ - wiki: $tw.wiki, - document: $tw.browser ? document : $tw.fakeDocument - }); // Execute any startup actions $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction"); if($tw.browser) {