On 11/8/20 1:24 AM, Gavin Smith wrote:
On Sat, Nov 07, 2020 at 03:43:30PM -0800, Per Bothner wrote:

My suggestion is to flatten the config structure:

   var config = {
     EXT: ".html",
     INDEX_NAME: "index.html",
     INDEX_ID: "index",
     MAIN_ANCHORS: ["Top", "SEC_Contents"],
     WARNING_TIMEOUT: 3000,
     SCREEN_MIN_WIDTH: 700,

     // hooks:
     /** Define a function called after 'DOMContentLoaded' event in
         the INDEX_NAME context.
         @type {function (): void}*/
     on_main_load: null,
     /** Define a function called after 'DOMContentLoaded' event in
         the iframe context.
         @type {(function (): void)} */
     on_iframe_load: null
   };

Alternatively, we can replace the Object.assign call with something
that will also merge the hooks field.

Either option is fine with me; please go ahead and make the change
for whatever you make work.

See attachment.
--
        --Per Bothner
[email protected]   http://per.bothner.com/
diff --git a/js/info.js b/js/info.js
index c7c97df118..31936346ae 100644
--- a/js/info.js
+++ b/js/info.js
@@ -32,16 +32,16 @@
     MAIN_ANCHORS: ["Top", "SEC_Contents"],
     WARNING_TIMEOUT: 3000,
     SCREEN_MIN_WIDTH: 700,
-    hooks: {
-      /** Define a function called after 'DOMContentLoaded' event in
-          the INDEX_NAME context.
-          @type {function (): void}*/
-      on_main_load: null,
-      /** Define a function called after 'DOMContentLoaded' event in
-          the iframe context.
-          @type {(function (): void)} */
-      on_iframe_load: null
-    }
+
+    // hooks:
+    /** Define a function called after 'DOMContentLoaded' event in
+        the INDEX_NAME context.
+        @type {function (): void}*/
+    on_main_load: null,
+    /** Define a function called after 'DOMContentLoaded' event in
+        the iframe context.
+        @type {(function (): void)} */
+    on_iframe_load: null
   };
 
   /*-------------------.
@@ -1055,8 +1055,8 @@
       });
 
       /* Call user hook.  */
-      if (config.hooks.on_main_load)
-        config.hooks.on_main_load ();
+      if (config.on_main_load)
+        config.on_main_load ();
     }
 
     /* Handle messages received via the Message API.
@@ -1328,8 +1328,8 @@
       add_icons ();
 
       /* Call user hook.  */
-      if (config.hooks.on_iframe_load)
-        config.hooks.on_iframe_load ();
+      if (config.on_iframe_load)
+        config.on_iframe_load ();
     }
 
     /* Handle messages received via the Message API.  */

Reply via email to