Skip to content

Commit

Permalink
ui-global, glue-global, glue-extend script attrs to support js bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
capr committed Mar 26, 2024
1 parent 7cc3603 commit f2417f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions www/glue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion www/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2417f8

Please sign in to comment.