From f2417f84adfa6d076446d291f8222219555238ae Mon Sep 17 00:00:00 2001 From: Cosmin Apreutesei Date: Tue, 26 Mar 2024 16:52:50 +0200 Subject: [PATCH] ui-global, glue-global, glue-extend script attrs to support js bundling --- www/glue.js | 5 +++-- www/ui.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/www/glue.js b/www/glue.js index 4f01ca4..31e2870 100644 --- a/www/glue.js +++ b/www/glue.js @@ -2450,14 +2450,15 @@ ajax, get, post, G.glue = glue -if (document.currentScript.hasAttribute('global')) { +let script_attr = k => document.currentScript.hasAttribute(k) +if (script_attr('global') || script_attr('glue-global')) { for (let k in glue) { assert(!(k in G), k, ' global already exists') G[k] = glue[k] } } -if (document.currentScript.hasAttribute('extend')) { +if (script_attr('extend') || script_attr('glue-extend')) { function m(f) { return function(...args) { diff --git a/www/ui.js b/www/ui.js index 8c170a6..66b8b2a 100644 --- a/www/ui.js +++ b/www/ui.js @@ -318,7 +318,8 @@ TODO "use strict" const G = window -let ui = document.currentScript.hasAttribute('global') ? window : {} +let script_attr = k => document.currentScript.hasAttribute(k) +let ui = script_attr('global') || script_attr('ui-global') ? window : {} G.ui = ui ui.VERSION = 1