@yannosay/sinth 0.14.4 → 0.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "description": "A declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
@@ -783,7 +783,9 @@ export function renderCompUse(
783
783
  const rhs = (varDecl && varDecl.varType === "int")
784
784
  ? `Number(e.target.value) || 0`
785
785
  : `e.target.value`;
786
+ const initialVal = varDecl?.value ? litToString(varDecl.value).replace(/"/g, '"') : "";
786
787
  attrParts.push(`oninput="(function(e){ ${vName} = ${rhs}; sinthRender(); })(event)"`);
788
+ attrParts.push(`value="${escAttr(initialVal)}"`);
787
789
  attrParts.push(`data-sinth-value="${escAttr(vName)}"`);
788
790
  }
789
791
  }
@@ -984,20 +986,20 @@ export function buildRuntime(opts: {
984
986
  );
985
987
  }
986
988
  const defaults: Record<string, string> = { str: '""', int: "0", bool: "false", "str[]": "[]" };
987
- return `var ${v.name} = ${defaults[v.varType] ?? "undefined"};`;
989
+ return `let ${v.name} = ${defaults[v.varType] ?? "undefined"};`;
988
990
  }
989
991
  const val = litToString(v.value);
990
- if (val.startsWith("__VAR__")) return `var ${v.name} = ${val.slice(7)};`;
991
- if (val.startsWith("__ARR__")) return `var ${v.name} = ${val.slice(7)};`;
992
- if (v.varType === "obj") return `var ${v.name} = ${val};`;
993
- if (v.varType === "str") return `var ${v.name} = ${JSON.stringify(val)};`;
992
+ if (val.startsWith("__VAR__")) return `let ${v.name} = ${val.slice(7)};`;
993
+ if (val.startsWith("__ARR__")) return `let ${v.name} = ${val.slice(7)};`;
994
+ if (v.varType === "obj") return `let ${v.name} = ${val};`;
995
+ if (v.varType === "str") return `let ${v.name} = ${JSON.stringify(val)};`;
994
996
  if (v.varType === "str[]" && typeof val === 'string' && val.startsWith("__ARR__")) {
995
997
  try {
996
998
  const arr = JSON.parse(val.slice(7));
997
- return `var ${v.name} = ${JSON.stringify(arr)};`;
998
- } catch { return `var ${v.name} = ${val.slice(7)};`; }
999
+ return `let ${v.name} = ${JSON.stringify(arr)};`;
1000
+ } catch { return `let ${v.name} = ${val.slice(7)};`; }
999
1001
  }
1000
- return `var ${v.name} = ${val};`;
1002
+ return `let ${v.name} = ${val};`;
1001
1003
  }).join("\n");
1002
1004
 
1003
1005
  if (!needsRender && !needsDelay) {
@@ -1013,7 +1015,7 @@ export function buildRuntime(opts: {
1013
1015
  });
1014
1016
 
1015
1017
  const exprArrayJS = exprRegistry.length > 0
1016
- ? `var __X = [${exprRegistry.map((js) => `function(_ctx){ return ${js}; }`).join(",")}];\n`
1018
+ ? `let __X = [${exprRegistry.map((js) => `function(_ctx){ return ${js}; }`).join(",")}];\n`
1017
1019
  : "";
1018
1020
 
1019
1021
  let renderFunc = needsRender ? `function sinthRender() {\n${renderBody}}\nsinthRender();` : "";
@@ -1021,9 +1023,9 @@ export function buildRuntime(opts: {
1021
1023
  if (needsFullscreenSync) {
1022
1024
  renderFunc += `
1023
1025
  (function() {
1024
- var syncedEls = document.querySelectorAll('[data-sinth-fullscreen-sync]');
1026
+ let syncedEls = document.querySelectorAll('[data-sinth-fullscreen-sync]');
1025
1027
  if (syncedEls.length > 0) {
1026
- var vars = [];
1028
+ let vars = [];
1027
1029
  syncedEls.forEach(function(el) { vars.push(el.dataset.sinthFullscreenSync); });
1028
1030
  document.addEventListener('fullscreenchange', function() {
1029
1031
  if (!document.fullscreenElement) {
@@ -1035,7 +1037,7 @@ export function buildRuntime(opts: {
1035
1037
  })();`;
1036
1038
  }
1037
1039
 
1038
- const pageCode = `// Sinth page runtime
1040
+ const pageCode = `// Sinth Page Runtime
1039
1041
  ${varLines}
1040
1042
  ${exprArrayJS}
1041
1043
  ${renderFunc}`;
@@ -1227,7 +1229,7 @@ export function compileFile(filePath: string, opts: CompileOptions): { html: str
1227
1229
  const extra = Object.entries(s.attrs)
1228
1230
  .map(([k, v]) => v === "true" ? k : `${k}="${escAttr(v)}"`)
1229
1231
  .join(" ");
1230
- const globalised = s.raw.replace(/\b(let|const)\b/g, "var");
1232
+ const globalised = s.raw.replace(/\b(let|const)\b/g, "let");
1231
1233
  scriptTags.push(`<script${extra ? " " + extra : ""}>\n${globalised}\n</script>`);
1232
1234
  }
1233
1235
 
@@ -12,7 +12,7 @@ export function generateHelpers(opts: {
12
12
  helpers += `
13
13
  function sinthExpr(el) {
14
14
  try {
15
- var exprFn = __X[el.dataset.exprId];
15
+ let exprFn = __X[el.dataset.exprId];
16
16
  if (exprFn) el.textContent = exprFn({});
17
17
  } catch(e) {}
18
18
  }
@@ -23,15 +23,15 @@ function sinthExpr(el) {
23
23
  helpers += `
24
24
  function sinthReplaceInsert(t, anchor, ifId, replaceId) {
25
25
  if (anchor) {
26
- var cur = anchor.nextSibling;
27
- while (cur && cur !== t) { var nx = cur.nextSibling; cur.remove(); cur = nx; }
26
+ let cur = anchor.nextSibling;
27
+ while (cur && cur !== t) { let nx = cur.nextSibling; cur.remove(); cur = nx; }
28
28
  } else {
29
29
  anchor = document.createElement('span');
30
30
  anchor.style.display = 'none';
31
31
  anchor.dataset.sinthIfAnchor = ifId;
32
32
  t.parentNode.insertBefore(anchor, t);
33
33
  }
34
- var _rp = null, _rpParent = null, _rpNext = null;
34
+ let _rp = null, _rpParent = null, _rpNext = null;
35
35
  if (replaceId) {
36
36
  _rp = document.getElementById(replaceId);
37
37
  if (_rp) {
@@ -43,14 +43,14 @@ function sinthReplaceInsert(t, anchor, ifId, replaceId) {
43
43
  anchor._sinthReplacedNext = _rpNext;
44
44
  }
45
45
  }
46
- var frag = document.createRange().createContextualFragment(t.innerHTML);
46
+ let frag = document.createRange().createContextualFragment(t.innerHTML);
47
47
  frag.querySelectorAll('.sinth-expr').forEach(sinthExpr);
48
48
  if (${needsDelay}) {
49
49
  frag.querySelectorAll('[data-sinth-delay]').forEach(sinthDelay);
50
50
  frag.querySelectorAll('[data-sinth-delay-expr-id]').forEach(function(el) { sinthDelayExpr(el, {}); });
51
51
  }
52
- var fragFirst = frag.firstChild;
53
- var fragLast = frag.lastChild;
52
+ let fragFirst = frag.firstChild;
53
+ let fragLast = frag.lastChild;
54
54
  if (_rpParent && _rpNext) {
55
55
  _rpParent.insertBefore(frag, _rpNext);
56
56
  } else if (_rpParent) {
@@ -72,9 +72,9 @@ function sinthReplaceInsert(t, anchor, ifId, replaceId) {
72
72
  function sinthDelay(el) {
73
73
  if (el.dataset.sinthDelayDone) { return; }
74
74
  el.dataset.sinthDelayDone = '1';
75
- var ms = parseInt(el.dataset.sinthDelay) || 0;
76
- var hideEl = el.dataset.sinthDelayHide !== 'false';
77
- var show = function() {
75
+ let ms = parseInt(el.dataset.sinthDelay) || 0;
76
+ let hideEl = el.dataset.sinthDelayHide !== 'false';
77
+ let show = function() {
78
78
  if (hideEl) el.style.display = '';
79
79
  el.querySelectorAll('.sinth-expr').forEach(sinthExpr);
80
80
  };
@@ -90,9 +90,9 @@ function sinthDelay(el) {
90
90
  function sinthDelayExpr(el, _ctx) {
91
91
  _ctx = _ctx || {};
92
92
  try {
93
- var fn = __X[el.dataset.sinthDelayExprId];
94
- var ms = fn ? parseInt(fn(_ctx)) || 0 : 0;
95
- var show = function() {
93
+ let fn = __X[el.dataset.sinthDelayExprId];
94
+ let ms = fn ? parseInt(fn(_ctx)) || 0 : 0;
95
+ let show = function() {
96
96
  el.style.display = '';
97
97
  el.querySelectorAll('.sinth-expr').forEach(sinthExpr);
98
98
  };
@@ -106,21 +106,21 @@ function sinthDelayExpr(el, _ctx) {
106
106
  if (needsIf) {
107
107
  helpers += `
108
108
  function sinthIfBlock(t) {
109
- var ifId = t.dataset.sinthIfId;
110
- var anchor = t.parentNode.querySelector('[data-sinth-if-anchor="' + ifId + '"]');
111
- var condFn = __X[t.dataset.sinthIfExpr];
112
- var cond = condFn ? condFn() : false;
109
+ let ifId = t.dataset.sinthIfId;
110
+ let anchor = t.parentNode.querySelector('[data-sinth-if-anchor="' + ifId + '"]');
111
+ let condFn = __X[t.dataset.sinthIfExpr];
112
+ let cond = condFn ? condFn() : false;
113
113
  if (cond) {
114
- var elseA = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
114
+ let elseA = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
115
115
  if (elseA) {
116
- var c = elseA.nextSibling;
117
- while (c && c !== t) { var n = c.nextSibling; c.remove(); c = n; }
116
+ let c = elseA.nextSibling;
117
+ while (c && c !== t) { let n = c.nextSibling; c.remove(); c = n; }
118
118
  elseA.remove();
119
119
  }
120
120
  if (t.dataset.sinthIfPersist === "true" && anchor) return;
121
- var _hasContent = anchor || t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
121
+ let _hasContent = anchor || t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
122
122
  if (t.dataset.sinthIfDelayHide === 'false' && t.dataset.sinthIfDelay && _hasContent) {
123
- var dms = parseInt(t.dataset.sinthIfDelay) || 0;
123
+ let dms = parseInt(t.dataset.sinthIfDelay) || 0;
124
124
  setTimeout(function() {
125
125
  sinthReplaceInsert(t, anchor, ifId, t.dataset.sinthIfReplace);
126
126
  }, dms);
@@ -128,18 +128,18 @@ function sinthIfBlock(t) {
128
128
  anchor = sinthReplaceInsert(t, anchor, ifId, t.dataset.sinthIfReplace);
129
129
  }
130
130
  } else {
131
- var runElse = function() {
131
+ let runElse = function() {
132
132
  if (t.dataset.sinthIfPersist === "true") return;
133
133
  if (anchor) {
134
134
  if (anchor._sinthReplaced) {
135
- var insFirst = anchor._sinthInsertedFirst;
136
- var insLast = anchor._sinthInsertedLast;
137
- var rpParent = anchor._sinthReplacedParent;
138
- var rpNext = anchor._sinthReplacedNext;
135
+ let insFirst = anchor._sinthInsertedFirst;
136
+ let insLast = anchor._sinthInsertedLast;
137
+ let rpParent = anchor._sinthReplacedParent;
138
+ let rpNext = anchor._sinthReplacedNext;
139
139
  if (insFirst && insLast) {
140
- var cur = insFirst;
140
+ let cur = insFirst;
141
141
  while (cur && cur !== insLast) {
142
- var next = cur.nextSibling;
142
+ let next = cur.nextSibling;
143
143
  cur.remove();
144
144
  cur = next;
145
145
  }
@@ -155,53 +155,53 @@ function sinthIfBlock(t) {
155
155
  sinthDelay(anchor._sinthReplaced);
156
156
  }
157
157
  } else {
158
- var cur2 = anchor.nextSibling;
159
- while (cur2 && cur2 !== t) { var nx2 = cur2.nextSibling; cur2.remove(); cur2 = nx2; }
158
+ let cur2 = anchor.nextSibling;
159
+ while (cur2 && cur2 !== t) { let nx2 = cur2.nextSibling; cur2.remove(); cur2 = nx2; }
160
160
  }
161
161
  anchor.remove();
162
162
  }
163
- var elseT = t.nextElementSibling;
163
+ let elseT = t.nextElementSibling;
164
164
  if (elseT && elseT.hasAttribute('data-sinth-else')) {
165
- var elseIfId = elseT.dataset.sinthIfId;
166
- var ea = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + elseIfId + '"]');
165
+ let elseIfId = elseT.dataset.sinthIfId;
166
+ let ea = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + elseIfId + '"]');
167
167
  if (ea) {
168
- var cur3 = ea.nextSibling;
169
- while (cur3 && cur3 !== t) { var nx3 = cur3.nextSibling; cur3.remove(); cur3 = nx3; }
168
+ let cur3 = ea.nextSibling;
169
+ while (cur3 && cur3 !== t) { let nx3 = cur3.nextSibling; cur3.remove(); cur3 = nx3; }
170
170
  } else {
171
171
  ea = document.createElement('span');
172
172
  ea.style.display = 'none';
173
173
  ea.dataset.sinthIfAnchor = '__else__' + elseIfId;
174
174
  t.parentNode.insertBefore(ea, t);
175
175
  }
176
- var ef = document.createRange().createContextualFragment(elseT.innerHTML);
176
+ let ef = document.createRange().createContextualFragment(elseT.innerHTML);
177
177
  ef.querySelectorAll('.sinth-expr').forEach(sinthExpr);
178
178
  if (${needsDelay}) {
179
179
  ef.querySelectorAll('[data-sinth-delay]').forEach(sinthDelay);
180
180
  ef.querySelectorAll('[data-sinth-delay-expr-id]').forEach(function(el) { sinthDelayExpr(el, {}); });
181
181
  }
182
- var innerTemplates = ef.querySelectorAll('template[data-sinth-if-expr]');
182
+ let innerTemplates = ef.querySelectorAll('template[data-sinth-if-expr]');
183
183
  t.parentNode.insertBefore(ef, t);
184
- for (var i = 0; i < innerTemplates.length; i++) sinthIfBlock(innerTemplates[i]);
184
+ for (let i = 0; i < innerTemplates.length; i++) sinthIfBlock(innerTemplates[i]);
185
185
  ef.querySelectorAll('[data-sinth-delay]').forEach(function(el) {
186
186
  delete el.dataset.sinthDelayDone;
187
187
  sinthDelay(el);
188
188
  });
189
189
  } else {
190
- var ea2 = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
190
+ let ea2 = t.parentNode.querySelector('[data-sinth-if-anchor="__else__' + ifId + '"]');
191
191
  if (ea2) {
192
- var ec = ea2.nextSibling;
193
- while (ec && ec !== t) { var en = ec.nextSibling; ec.remove(); ec = en; }
192
+ let ec = ea2.nextSibling;
193
+ while (ec && ec !== t) { let en = ec.nextSibling; ec.remove(); ec = en; }
194
194
  ea2.remove();
195
195
  }
196
196
  if (anchor) {
197
- var ac = anchor.nextSibling;
198
- while (ac && ac !== t) { var an = ac.nextSibling; ac.remove(); ac = an; }
197
+ let ac = anchor.nextSibling;
198
+ while (ac && ac !== t) { let an = ac.nextSibling; ac.remove(); ac = an; }
199
199
  }
200
200
  }
201
201
  };
202
- var elseT = t.nextElementSibling;
202
+ let elseT = t.nextElementSibling;
203
203
  if (elseT && elseT.hasAttribute('data-sinth-else') && elseT.dataset.sinthIfDelayHide === 'false' && elseT.dataset.sinthIfDelay && anchor) {
204
- var edms = parseInt(elseT.dataset.sinthIfDelay) || 0;
204
+ let edms = parseInt(elseT.dataset.sinthIfDelay) || 0;
205
205
  setTimeout(runElse, edms);
206
206
  } else {
207
207
  runElse();
@@ -214,7 +214,7 @@ function sinthIfBlock(t) {
214
214
  if (needsFor) {
215
215
  helpers += `
216
216
  function hashString(str) {
217
- var hash = 0, i, chr;
217
+ let hash = 0, i, chr;
218
218
  for (i = 0; i < str.length; i++) {
219
219
  chr = str.charCodeAt(i);
220
220
  hash = ((hash << 5) - hash) + chr;
@@ -223,76 +223,76 @@ function hashString(str) {
223
223
  return String(hash);
224
224
  }
225
225
  function sinthForBlock(t) {
226
- var source = window[t.dataset.sinthFor];
226
+ let source = window[t.dataset.sinthFor];
227
227
  if (source === undefined) source = [];
228
- var newHash = '';
228
+ let newHash = '';
229
229
  try { newHash = hashString(JSON.stringify(source)); } catch(e) { newHash = ''; }
230
230
  if (t.dataset.sinthForHash && t.dataset.sinthForHash === newHash) {
231
231
  return;
232
232
  }
233
233
  t.dataset.sinthForHash = newHash;
234
- var isObj = (typeof source === 'object' && source !== null && !Array.isArray(source));
235
- var entries;
234
+ let isObj = (typeof source === 'object' && source !== null && !Array.isArray(source));
235
+ let entries;
236
236
  if (isObj) {
237
237
  entries = Object.entries(source);
238
238
  } else {
239
239
  if (!Array.isArray(source)) source = [];
240
240
  entries = source.map(function(item, index) { return [index, item]; });
241
241
  }
242
- var anchor = t.parentNode ? t.parentNode.querySelector('[data-sinth-for-anchor="' + t.dataset.sinthFor + '"]') : null;
242
+ let anchor = t.parentNode ? t.parentNode.querySelector('[data-sinth-for-anchor="' + t.dataset.sinthFor + '"]') : null;
243
243
  if (anchor) {
244
- var cur2 = anchor.nextSibling;
245
- while (cur2 && cur2 !== t) { var nx2 = cur2.nextSibling; cur2.remove(); cur2 = nx2; }
244
+ let cur2 = anchor.nextSibling;
245
+ while (cur2 && cur2 !== t) { let nx2 = cur2.nextSibling; cur2.remove(); cur2 = nx2; }
246
246
  anchor.remove();
247
247
  }
248
- var fa = document.createElement('span');
248
+ let fa = document.createElement('span');
249
249
  fa.style.display = 'none';
250
250
  fa.dataset.sinthForAnchor = t.dataset.sinthFor;
251
251
  t.parentNode && t.parentNode.insertBefore(fa, t);
252
- var _loopIdx = 0;
252
+ let _loopIdx = 0;
253
253
  entries.forEach(function(entry) {
254
- var _k = entry[0];
255
- var _v = entry[1];
256
- var _item = (t.dataset && t.dataset.sinthItem) ? t.dataset.sinthItem : '__item__';
257
- var _key = t.dataset && t.dataset.sinthKey ? t.dataset.sinthKey : null;
258
- var _idx = t.dataset && t.dataset.sinthIndex ? t.dataset.sinthIndex : null;
254
+ let _k = entry[0];
255
+ let _v = entry[1];
256
+ let _item = (t.dataset && t.dataset.sinthItem) ? t.dataset.sinthItem : '__item__';
257
+ let _key = t.dataset && t.dataset.sinthKey ? t.dataset.sinthKey : null;
258
+ let _idx = t.dataset && t.dataset.sinthIndex ? t.dataset.sinthIndex : null;
259
259
  _loopIdx++;
260
260
  if (t.dataset.sinthIfReplace) {
261
- var _rp = document.getElementById(t.dataset.sinthIfReplace);
261
+ let _rp = document.getElementById(t.dataset.sinthIfReplace);
262
262
  if (_rp) _rp.parentNode.removeChild(_rp);
263
263
  }
264
- var loopCtx = {};
264
+ let loopCtx = {};
265
265
  if (_item) loopCtx[_item] = _v;
266
266
  if (_key) loopCtx[_key] = _k;
267
267
  if (_idx) loopCtx[_idx] = _loopIdx - 1;
268
- var frag = document.createRange().createContextualFragment(t.innerHTML);
268
+ let frag = document.createRange().createContextualFragment(t.innerHTML);
269
269
  frag.querySelectorAll('.sinth-expr').forEach(function(el) {
270
270
  try {
271
- var exprFn = __X[el.dataset.exprId];
271
+ let exprFn = __X[el.dataset.exprId];
272
272
  if (exprFn) el.textContent = exprFn(loopCtx);
273
273
  } catch(e) {}
274
274
  el.classList.remove('sinth-expr');
275
275
  });
276
276
  frag.querySelectorAll('template[data-sinth-if-expr]').forEach(function(ifT) {
277
- var condFn = __X[ifT.dataset.sinthIfExpr];
278
- var cond = false;
277
+ let condFn = __X[ifT.dataset.sinthIfExpr];
278
+ let cond = false;
279
279
  try { if (condFn) cond = condFn(loopCtx); } catch(e) {}
280
280
  if (cond) {
281
- var ifContent = document.createRange().createContextualFragment(ifT.innerHTML);
281
+ let ifContent = document.createRange().createContextualFragment(ifT.innerHTML);
282
282
  ifContent.querySelectorAll('.sinth-expr').forEach(function(el2) {
283
283
  try {
284
- var exprFn2 = __X[el2.dataset.exprId];
284
+ let exprFn2 = __X[el2.dataset.exprId];
285
285
  if (exprFn2) el2.textContent = exprFn2(loopCtx);
286
286
  } catch(e) {}
287
287
  });
288
288
  ifT.parentNode.insertBefore(ifContent, ifT);
289
289
  } else {
290
- var elseT = ifT.nextElementSibling;
290
+ let elseT = ifT.nextElementSibling;
291
291
  if (elseT && elseT.hasAttribute('data-sinth-else')) {
292
- var elseContent = document.createRange().createContextualFragment(elseT.innerHTML);
292
+ let elseContent = document.createRange().createContextualFragment(elseT.innerHTML);
293
293
  elseContent.querySelectorAll('.sinth-expr').forEach(function(el2) {
294
294
  try {
295
- var exprFn2 = __X[el2.dataset.exprId];
295
+ let exprFn2 = __X[el2.dataset.exprId];
296
296
  if (exprFn2) el2.textContent = exprFn2(loopCtx);
297
297
  } catch(e) {}
298
298
  });
@@ -13,7 +13,7 @@ export function buildRenderBody(opts: {
13
13
  }): string {
14
14
  const { bodyHTML, logicBlocks, mixedBlocks, needsLogic, needsMixed, needsIf, needsFor, needsExpr, needsDelay } = opts;
15
15
  let renderBody = "";
16
- renderBody += ` var _sx = window.scrollX, _sy = window.scrollY;\n`;
16
+ renderBody += ` let _sx = window.scrollX, _sy = window.scrollY;\n`;
17
17
 
18
18
  if (needsLogic) {
19
19
  renderBody += logicBlocks.map(b => b.replace(/^/gm, " ")).join("\n") + "\n";
@@ -24,9 +24,9 @@ export function buildRenderBody(opts: {
24
24
  const ifJS = mb.ifJS ? mb.ifJS.trim() : "";
25
25
  const elseJS = mb.elseJS ? mb.elseJS.trim() : "";
26
26
  renderBody += ` (function() {
27
- var __el = document.getElementById(${JSON.stringify(mb.replaceId || mb.id)});
27
+ let __el = document.getElementById(${JSON.stringify(mb.replaceId || mb.id)});
28
28
  if (__el) {
29
- var __condFn = __X[${mb.conditionJS}];
29
+ let __condFn = __X[${mb.conditionJS}];
30
30
  if (__condFn ? __condFn() : false) {
31
31
  ${ifJS}
32
32
  __el.innerHTML = ${JSON.stringify(mb.ifHTML)};
@@ -47,14 +47,14 @@ export function buildRenderBody(opts: {
47
47
  renderBody += ` document.querySelectorAll('template[data-sinth-if-expr]').forEach(sinthIfBlock);\n`;
48
48
  }
49
49
  renderBody += ` document.querySelectorAll('[data-sinth-remove]').forEach(function(el) {
50
- var target = document.getElementById(el.dataset.sinthRemove);
50
+ let target = document.getElementById(el.dataset.sinthRemove);
51
51
  if (target) target.remove();
52
52
  });\n`;
53
53
  if (needsFor) {
54
54
  renderBody += ` document.querySelectorAll('template[data-sinth-for]').forEach(sinthForBlock);\n`;
55
55
  }
56
56
  renderBody += ` document.querySelectorAll('[data-sinth-value]').forEach(function(el) {
57
- try { if (document.activeElement !== el) el.value = window[el.dataset.sinthValue] || ''; } catch(e) {}
57
+ try { if (document.activeElement !== el) { el.value = Function('"use strict"; return (' + el.dataset.sinthValue + ')')(); } } catch(e) {}
58
58
  });\n`;
59
59
  renderBody += ` document.querySelectorAll('[data-sinth-step]').forEach(function(el) {
60
60
  try { el.step = window[el.dataset.sinthStep] || 1; } catch(e) {}
@@ -65,16 +65,16 @@ export function buildRenderBody(opts: {
65
65
  if (bodyHTML.includes("data-sinth-checked-expr")) {
66
66
  renderBody += ` document.querySelectorAll('[data-sinth-checked-expr]').forEach(function(el) {
67
67
  try {
68
- var exprFn = __X[el.dataset.sinthCheckedExpr];
68
+ let exprFn = __X[el.dataset.sinthCheckedExpr];
69
69
  if (exprFn) el.checked = !!exprFn({});
70
70
  } catch(e) {}
71
71
  });\n`;
72
72
  }
73
73
  if (needsDelay) {
74
74
  renderBody += ` document.querySelectorAll('[data-sinth-delay]').forEach(function(el) {
75
- var newContent = '';
75
+ let newContent = '';
76
76
  el.querySelectorAll('.sinth-expr').forEach(function(exprEl) {
77
- var exprFn = __X[exprEl.dataset.exprId];
77
+ let exprFn = __X[exprEl.dataset.exprId];
78
78
  if (exprFn) newContent += exprFn({});
79
79
  });
80
80
  if (el._sinthLastContent === undefined) {
@@ -87,17 +87,17 @@ export function buildRenderBody(opts: {
87
87
  }
88
88
  if (needsExpr) {
89
89
  renderBody += ` document.querySelectorAll('.sinth-expr').forEach(function(el) {
90
- var delayParent = el.closest('[data-sinth-delay]');
90
+ let delayParent = el.closest('[data-sinth-delay]');
91
91
  if (!delayParent || delayParent.dataset.sinthDelayDone) {
92
92
  sinthExpr(el);
93
93
  }
94
94
  });\n`;
95
95
  }
96
96
  renderBody += ` document.querySelectorAll('[data-sinth-hide]').forEach(function(el) {
97
- var exprId = el.dataset.sinthHide;
97
+ let exprId = el.dataset.sinthHide;
98
98
  if (exprId) {
99
99
  try {
100
- var exprFn = __X[exprId];
100
+ let exprFn = __X[exprId];
101
101
  if (exprFn) el.style.display = exprFn({}) ? 'none' : '';
102
102
  } catch(e) {}
103
103
  } else {
@@ -105,10 +105,10 @@ export function buildRenderBody(opts: {
105
105
  }
106
106
  });\n`;
107
107
  renderBody += ` document.querySelectorAll('[data-sinth-fullscreen]').forEach(function(el) {
108
- var exprId = el.dataset.sinthFullscreen;
108
+ let exprId = el.dataset.sinthFullscreen;
109
109
  if (exprId) {
110
110
  try {
111
- var exprFn = __X[exprId];
111
+ let exprFn = __X[exprId];
112
112
  if (exprFn) {
113
113
  if (exprFn({})) {
114
114
  if (document.documentElement.requestFullscreen) document.documentElement.requestFullscreen();