@stacksjs/stx 0.2.794 → 0.2.795
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/dist/chunk-027hdpgv.js +2 -0
- package/dist/chunk-054h7ktz.js +2 -0
- package/dist/chunk-09nyt9c5.js +2 -0
- package/dist/chunk-0d3ncyqh.js +2 -0
- package/dist/{chunk-2gqhfge6.js → chunk-12jjf2me.js} +2 -2
- package/dist/{chunk-jdj1358b.js → chunk-1hq3y7ss.js} +2 -2
- package/dist/{chunk-b4r7d6me.js → chunk-1q16p7t2.js} +5 -5
- package/dist/chunk-1yew6rw9.js +2 -0
- package/dist/chunk-211kxm18.js +2 -0
- package/dist/chunk-26y92p8r.js +2 -0
- package/dist/{chunk-ssh2gycr.js → chunk-2bvaakcv.js} +3 -3
- package/dist/{chunk-vav9ktgm.js → chunk-2e5tvryz.js} +1 -1
- package/dist/{chunk-15ckxpq7.js → chunk-2xprqx2v.js} +5 -5
- package/dist/{chunk-dhqp3z4w.js → chunk-3em44jbm.js} +2 -2
- package/dist/chunk-3ep9h16p.js +2 -0
- package/dist/{chunk-ne69yaak.js → chunk-3f8w1x6w.js} +10 -10
- package/dist/{chunk-14ft0zc7.js → chunk-3vpgr6nk.js} +6 -6
- package/dist/{chunk-8nb8b0nf.js → chunk-427mhgje.js} +1 -1
- package/dist/chunk-49tn6yst.js +2 -0
- package/dist/chunk-4b7dwwn6.js +2 -0
- package/dist/chunk-4ncbq4bx.js +2 -0
- package/dist/{chunk-985afhhy.js → chunk-4p5g7v9g.js} +2 -2
- package/dist/{chunk-7pk3t82j.js → chunk-4s0ye933.js} +2 -2
- package/dist/chunk-4srnxp3b.js +2 -0
- package/dist/chunk-538d185r.js +3 -0
- package/dist/{chunk-605b93pe.js → chunk-53v4cby3.js} +4 -4
- package/dist/{chunk-94gyfwpz.js → chunk-624xpap6.js} +12 -12
- package/dist/{chunk-kr8qdg0r.js → chunk-6s9bk98p.js} +2 -2
- package/dist/{chunk-q14d714d.js → chunk-6wpwpk3c.js} +4 -4
- package/dist/chunk-6z4bza9z.js +2 -0
- package/dist/chunk-75y9heas.js +2 -0
- package/dist/chunk-7ckdvsmj.js +3 -0
- package/dist/{chunk-rrb9m2q2.js → chunk-7k6hd10j.js} +5 -5
- package/dist/{chunk-1y9ez7nz.js → chunk-7s1kerhs.js} +2 -2
- package/dist/{chunk-k4bdf0dw.js → chunk-7xs45trj.js} +2 -2
- package/dist/{chunk-kce6pzmj.js → chunk-7y29q1ng.js} +3 -3
- package/dist/{chunk-t3ptzpfc.js → chunk-7y73txmp.js} +1 -1
- package/dist/{chunk-j6255z7f.js → chunk-88acqv2r.js} +4 -4
- package/dist/{chunk-efrc97by.js → chunk-8t8e75xm.js} +4 -4
- package/dist/chunk-8w1wxr96.js +2 -0
- package/dist/{chunk-7gdwvnwc.js → chunk-8zf87cc5.js} +2 -2
- package/dist/{chunk-gv3bfkdm.js → chunk-90zswh9v.js} +5 -5
- package/dist/chunk-98kjk52z.js +2 -0
- package/dist/{chunk-yyr7vb7k.js → chunk-9b9tvhmh.js} +5 -5
- package/dist/{chunk-66b56g2z.js → chunk-9jcqbgq9.js} +5 -5
- package/dist/chunk-9sea317f.js +2 -0
- package/dist/chunk-9tpv4cg7.js +2 -0
- package/dist/{chunk-qzb0v08n.js → chunk-ak10vygz.js} +1 -1
- package/dist/{chunk-wk6xsyv3.js → chunk-aksrh8je.js} +3 -3
- package/dist/{chunk-6v4b0xc1.js → chunk-ata5wp2m.js} +4 -4
- package/dist/{chunk-nwbq8qvb.js → chunk-axjfaere.js} +1214 -445
- package/dist/chunk-axq3c7cb.js +2 -0
- package/dist/{chunk-w6taxq7d.js → chunk-ayd635jf.js} +5 -5
- package/dist/{chunk-qv85c3qy.js → chunk-azqf0ps0.js} +2 -2
- package/dist/{chunk-gb65t4n1.js → chunk-b58n1kfe.js} +2 -2
- package/dist/{chunk-c0ejyxfj.js → chunk-baj6w8ja.js} +2 -2
- package/dist/{chunk-es006emk.js → chunk-bwf8b4e4.js} +3 -3
- package/dist/{chunk-h0jnatd4.js → chunk-bzhzp4f4.js} +2 -2
- package/dist/chunk-c5trhqpg.js +2 -0
- package/dist/{chunk-bmfk3b29.js → chunk-c5vzr1va.js} +2 -2
- package/dist/chunk-c692kj5v.js +2 -0
- package/dist/{chunk-8ztgy5y4.js → chunk-cepctq7e.js} +108 -108
- package/dist/{chunk-0r61tkfe.js → chunk-cfbpvm5e.js} +2 -2
- package/dist/chunk-cfr7cd88.js +2 -0
- package/dist/{chunk-bwcj9z19.js → chunk-d50vw81s.js} +4 -4
- package/dist/chunk-dsh5q9bg.js +2 -0
- package/dist/{chunk-e3wmnjz8.js → chunk-dstzvtvk.js} +3 -3
- package/dist/{chunk-2p4yad7w.js → chunk-dxe94pwy.js} +4 -4
- package/dist/{chunk-rgz797k3.js → chunk-ectx5ar9.js} +3 -3
- package/dist/chunk-emnphnz7.js +2 -0
- package/dist/chunk-ennzzth4.js +177 -0
- package/dist/chunk-epcdgn78.js +2 -0
- package/dist/chunk-etegf4zj.js +2 -0
- package/dist/chunk-ewzdsksb.js +2 -0
- package/dist/chunk-ey8bgg6x.js +2 -0
- package/dist/chunk-f03sg8b0.js +2 -0
- package/dist/{chunk-w5hhqjwr.js → chunk-f4j7nsj1.js} +1 -1
- package/dist/{chunk-fpn4dren.js → chunk-fcqxa38q.js} +1 -1
- package/dist/{chunk-enep9r03.js → chunk-g4n0bjfb.js} +52 -52
- package/dist/chunk-gf04pgaa.js +2 -0
- package/dist/chunk-ghn8vhet.js +2 -0
- package/dist/chunk-gywp6kd8.js +2 -0
- package/dist/{chunk-tnn0br4w.js → chunk-h656zg6k.js} +3 -3
- package/dist/{chunk-8e23zh2y.js → chunk-hnbx1t3t.js} +2 -2
- package/dist/{chunk-2m5h2mtr.js → chunk-hp10khyy.js} +41 -41
- package/dist/{chunk-d18xd9x5.js → chunk-hwcfgs3e.js} +3 -3
- package/dist/{chunk-5a92srn2.js → chunk-jmbh26gv.js} +1 -1
- package/dist/chunk-k6sjqb7g.js +2 -0
- package/dist/{chunk-vrbcdds3.js → chunk-ka8sk5qa.js} +1 -1
- package/dist/{chunk-1stvxcjv.js → chunk-m081078c.js} +2 -2
- package/dist/{chunk-hh9t97hr.js → chunk-mcj5qtpp.js} +1 -1
- package/dist/chunk-me71d5w5.js +2 -0
- package/dist/{chunk-e0wxcst7.js → chunk-njk5db1q.js} +4 -4
- package/dist/chunk-nvytej81.js +2 -0
- package/dist/{chunk-488kx8j5.js → chunk-nyer6v3y.js} +5 -5
- package/dist/chunk-p1txw41y.js +2 -0
- package/dist/{chunk-agtvdtx4.js → chunk-p3ej3954.js} +2 -2
- package/dist/chunk-p8gekf4b.js +2 -0
- package/dist/{chunk-nps2whkz.js → chunk-pm8a4kdf.js} +6 -6
- package/dist/{chunk-y0pqpch2.js → chunk-pnddmgjf.js} +7 -7
- package/dist/chunk-px0qsd38.js +2 -0
- package/dist/{chunk-27rzdq3n.js → chunk-qnxctfdf.js} +2 -2
- package/dist/chunk-qr23snrp.js +2 -0
- package/dist/{chunk-v8rfeev5.js → chunk-r1vkk7qp.js} +2 -2
- package/dist/{chunk-qp3xd98j.js → chunk-r3a15pax.js} +2 -2
- package/dist/{chunk-pa9zfbh6.js → chunk-rdymnn2t.js} +2 -2
- package/dist/{chunk-8q63njnd.js → chunk-reb7rddz.js} +1 -1
- package/dist/chunk-s151a2dj.js +2 -0
- package/dist/{chunk-v1z6n7wz.js → chunk-sphc7xzx.js} +4 -4
- package/dist/chunk-sqettc34.js +2 -0
- package/dist/chunk-srgbv05n.js +2 -0
- package/dist/chunk-t0d4rsfx.js +2 -0
- package/dist/chunk-t0k0yk24.js +2 -0
- package/dist/chunk-tdcgskyy.js +2 -0
- package/dist/chunk-te3hr6d7.js +2 -0
- package/dist/chunk-tes8fdv6.js +2 -0
- package/dist/{chunk-9tqa8xvf.js → chunk-thpwk6ya.js} +2 -2
- package/dist/{chunk-w9nwb8r3.js → chunk-tmfrq4nq.js} +7 -7
- package/dist/{chunk-tnkxww7b.js → chunk-tqvw1673.js} +5 -5
- package/dist/chunk-v6j5vkce.js +2 -0
- package/dist/chunk-vmp876q6.js +2 -0
- package/dist/{chunk-4s5q1aea.js → chunk-vpzdqbw7.js} +4 -4
- package/dist/{chunk-tktkj2dc.js → chunk-vwp5fchy.js} +1 -1
- package/dist/{chunk-1hajf3wc.js → chunk-w6e30qkz.js} +13 -13
- package/dist/{chunk-3gn1t0pa.js → chunk-w76cve9j.js} +9 -9
- package/dist/{chunk-7fr038wx.js → chunk-wa7fzgw7.js} +4 -4
- package/dist/chunk-wes5fdpe.js +2 -0
- package/dist/chunk-wfnfb4fr.js +2 -0
- package/dist/{chunk-cdsv4yrv.js → chunk-wfrqwtar.js} +1 -1
- package/dist/chunk-wzwfbehm.js +20 -0
- package/dist/{chunk-j56mg28d.js → chunk-x8ghjw9b.js} +2 -2
- package/dist/{chunk-74rf78w8.js → chunk-x8h81amr.js} +2 -2
- package/dist/chunk-xbhb8102.js +2 -0
- package/dist/{chunk-5j619xgb.js → chunk-xqjat573.js} +2 -2
- package/dist/chunk-xv4paxmt.js +2 -0
- package/dist/{chunk-5gppagt3.js → chunk-y2jqx5k4.js} +1 -1
- package/dist/{chunk-d6arvs57.js → chunk-y64f5t74.js} +5 -5
- package/dist/chunk-yeaqebnd.js +2 -0
- package/dist/chunk-yj20tq3s.js +2 -0
- package/dist/chunk-yjm7c78z.js +2 -0
- package/dist/{chunk-h0c6jtrj.js → chunk-yjnaqahd.js} +4 -4
- package/dist/{chunk-epcy3r18.js → chunk-zmr0pvcd.js} +113 -105
- package/dist/{chunk-6pt4158p.js → chunk-zv3zpmv1.js} +1 -1
- package/dist/{chunk-7sartb04.js → chunk-zva4a7xq.js} +2 -2
- package/dist/cli.js +19 -19
- package/dist/client/signals-authoring-runtime.js +2 -2
- package/dist/client/signals-binding-utils-runtime.js +2 -4
- package/dist/client/signals-component-props-runtime.js +8 -2
- package/dist/client/signals-expression-compiler-runtime.js +1 -1
- package/dist/client/signals-for-runtime.js +34 -0
- package/dist/client/signals-handler-runtime.js +43 -20
- package/dist/client/signals-helpers-runtime.js +39 -0
- package/dist/client/signals-native-row-runtime.d.ts +26 -0
- package/dist/client/signals-native-row-runtime.js +626 -0
- package/dist/client/signals-process-element-runtime.js +305 -287
- package/dist/client/signals-proxy-runtime.js +56 -31
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.js +8 -0
- package/dist/native/compiler/bundle.js +1 -1
- package/dist/native/compiler/inline-style.js +38 -1
- package/dist/native/compiler/style-variables.js +9 -1
- package/dist/native/event-names.js +1 -0
- package/dist/native/prop-names.js +9 -1
- package/dist/native/runtime/binding-tree.d.ts +2 -0
- package/dist/native/runtime/binding-tree.js +12 -1
- package/dist/native/runtime/craft-bridge.js +66 -0
- package/dist/native/runtime/craft.d.ts +78 -2
- package/dist/native/runtime/native-host.d.ts +2 -0
- package/dist/native/runtime/native-host.js +179 -76
- package/dist/pwa.js +3 -3
- package/dist/signals.d.ts +13 -10
- package/dist/signals.js +5 -3
- package/dist/ssg.js +15 -15
- package/dist/stx-virtual-ts.d.ts +25 -1
- package/dist/stx-virtual-ts.js +109 -6
- package/dist/typecheck.d.ts +3 -1
- package/dist/typecheck.js +28 -11
- package/package.json +5 -5
- package/dist/chunk-0675z8hj.js +0 -177
- package/dist/chunk-1brkqd5f.js +0 -2
- package/dist/chunk-1ds97d9m.js +0 -2
- package/dist/chunk-1tvb2stj.js +0 -2
- package/dist/chunk-2vxh8b8g.js +0 -2
- package/dist/chunk-33na85q2.js +0 -2
- package/dist/chunk-3t4t655h.js +0 -2
- package/dist/chunk-43ynckvh.js +0 -2
- package/dist/chunk-4v22nj67.js +0 -2
- package/dist/chunk-5v5w0cd2.js +0 -2
- package/dist/chunk-699t603m.js +0 -2
- package/dist/chunk-6f6xqzhb.js +0 -2
- package/dist/chunk-7mrr4ke5.js +0 -2
- package/dist/chunk-7tzzzvdg.js +0 -2
- package/dist/chunk-8a5txj4f.js +0 -2
- package/dist/chunk-8pphy0p1.js +0 -2
- package/dist/chunk-8rmb79zw.js +0 -2
- package/dist/chunk-8rwnzmvb.js +0 -2
- package/dist/chunk-90pxjq62.js +0 -2
- package/dist/chunk-9s4ggstz.js +0 -2
- package/dist/chunk-9xdz8r73.js +0 -2
- package/dist/chunk-agvykxs8.js +0 -2
- package/dist/chunk-ajj56vrw.js +0 -2
- package/dist/chunk-ay4ep67v.js +0 -2
- package/dist/chunk-bwfncfe1.js +0 -3
- package/dist/chunk-d5e47gr4.js +0 -2
- package/dist/chunk-d910ytt2.js +0 -2
- package/dist/chunk-d9p7xaj7.js +0 -2
- package/dist/chunk-dsrn2vgp.js +0 -2
- package/dist/chunk-fkkdt6sj.js +0 -2
- package/dist/chunk-fpw03bhv.js +0 -2
- package/dist/chunk-fxy0cq7h.js +0 -2
- package/dist/chunk-g6smtcc0.js +0 -2
- package/dist/chunk-g747k4gg.js +0 -3
- package/dist/chunk-gryrg1c0.js +0 -2
- package/dist/chunk-gvj862m1.js +0 -2
- package/dist/chunk-h5nrnen8.js +0 -2
- package/dist/chunk-hagk74x6.js +0 -2
- package/dist/chunk-hv0whj8t.js +0 -2
- package/dist/chunk-k2brrhf8.js +0 -2
- package/dist/chunk-k6ncb5qm.js +0 -2
- package/dist/chunk-kn38mjpp.js +0 -2
- package/dist/chunk-kvmpc0sg.js +0 -2
- package/dist/chunk-nbjgytem.js +0 -2
- package/dist/chunk-nf2bzqaw.js +0 -2
- package/dist/chunk-nt7wqqax.js +0 -2
- package/dist/chunk-pq1qs7bp.js +0 -2
- package/dist/chunk-pvw58x2j.js +0 -20
- package/dist/chunk-qk9v0emh.js +0 -2
- package/dist/chunk-qnj444zc.js +0 -2
- package/dist/chunk-s1wdzttg.js +0 -2
- package/dist/chunk-sq0qc9sk.js +0 -2
- package/dist/chunk-th5afzmv.js +0 -2
- package/dist/chunk-vgzfsh1z.js +0 -2
- package/dist/chunk-wmh4yxcs.js +0 -2
- package/dist/chunk-wr3adhd8.js +0 -2
- package/dist/chunk-xmae29mn.js +0 -2
- package/dist/chunk-zdwnzq78.js +0 -2
- package/dist/chunk-zssf9fdg.js +0 -2
- package/dist/chunk-zyf6737j.js +0 -2
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLiteral, handledXAttrsLiteral) {
|
|
2
|
-
return ` //
|
|
2
|
+
return ` // Known directive names to exclude from generic :attr binding
|
|
3
|
+
var DIRECTIVE_NAMES = ${directiveNamesLiteral};
|
|
4
|
+
|
|
5
|
+
// A bound value cannot introduce a URL scheme the page did not ask for.
|
|
6
|
+
// This is the client half of url-safety.ts: the server refuses a scheme
|
|
7
|
+
// substituted into an href, and x-href over a signal reaches the same
|
|
8
|
+
// attribute by another road. Same policy, same unsafe: prefix, so a page
|
|
9
|
+
// behaves the same whether the value arrived at render or at runtime.
|
|
10
|
+
var URL_NAV_ATTR = {href:1, 'xlink:href':1, action:1, formaction:1, ping:1, cite:1, manifest:1, data:1, to:1};
|
|
11
|
+
var URL_FETCH_ATTR = {src:1, srcset:1, poster:1, background:1};
|
|
12
|
+
function __stxSafeUrlAttr(attrName, value, warning) {
|
|
13
|
+
var navigable = URL_NAV_ATTR[attrName];
|
|
14
|
+
if (!navigable && !URL_FETCH_ATTR[attrName]) return value;
|
|
15
|
+
if (typeof value !== 'string' || !value) return value;
|
|
16
|
+
// Browsers ignore ASCII whitespace and controls inside a scheme and match
|
|
17
|
+
// it case-insensitively, so the spellings collapse before the test.
|
|
18
|
+
var probe = value.replace(/[\\u0000-\\u0020\\u00a0\\u2000-\\u200f\\u2028\\u2029\\ufeff]+/g, '').toLowerCase();
|
|
19
|
+
var refused = /^(?:javascript|vbscript|livescript|mocha|view-source):/.test(probe)
|
|
20
|
+
|| (navigable
|
|
21
|
+
? /^data:(?:text\\/html|text\\/xml|application\\/xhtml\\+xml|application\\/xml|image\\/svg\\+xml)/.test(probe)
|
|
22
|
+
: /^data:(?:text\\/html|application\\/xhtml\\+xml)/.test(probe));
|
|
23
|
+
if (!refused) return value;
|
|
24
|
+
if (!warning.warned) {
|
|
25
|
+
warning.warned = true;
|
|
26
|
+
console.warn('[stx] refused a ' + attrName + ' value whose scheme can run script: ' + probe.slice(0, 24));
|
|
27
|
+
}
|
|
28
|
+
return 'unsafe:' + value;
|
|
29
|
+
}
|
|
30
|
+
// SVG attributes are case-sensitive, but the HTML parser lowercases
|
|
31
|
+
// prefixed attribute names \u2014 ':viewBox' arrives as ':viewbox' because
|
|
32
|
+
// the spec's "adjust SVG attributes" step only covers unprefixed names.
|
|
33
|
+
// Without restoring the canonical casing, setAttribute('viewbox') creates
|
|
34
|
+
// a dead duplicate attribute and the real viewBox never updates.
|
|
35
|
+
var SVG_ATTR_CASE = {attributename:'attributeName', attributetype:'attributeType', basefrequency:'baseFrequency', baseprofile:'baseProfile', calcmode:'calcMode', clippathunits:'clipPathUnits', diffuseconstant:'diffuseConstant', edgemode:'edgeMode', filterunits:'filterUnits', glyphref:'glyphRef', gradienttransform:'gradientTransform', gradientunits:'gradientUnits', kernelmatrix:'kernelMatrix', kernelunitlength:'kernelUnitLength', keypoints:'keyPoints', keysplines:'keySplines', keytimes:'keyTimes', lengthadjust:'lengthAdjust', limitingconeangle:'limitingConeAngle', markerheight:'markerHeight', markerunits:'markerUnits', markerwidth:'markerWidth', maskcontentunits:'maskContentUnits', maskunits:'maskUnits', numoctaves:'numOctaves', pathlength:'pathLength', patterncontentunits:'patternContentUnits', patterntransform:'patternTransform', patternunits:'patternUnits', pointsatx:'pointsAtX', pointsaty:'pointsAtY', pointsatz:'pointsAtZ', preservealpha:'preserveAlpha', preserveaspectratio:'preserveAspectRatio', primitiveunits:'primitiveUnits', refx:'refX', refy:'refY', repeatcount:'repeatCount', repeatdur:'repeatDur', requiredextensions:'requiredExtensions', requiredfeatures:'requiredFeatures', specularconstant:'specularConstant', specularexponent:'specularExponent', spreadmethod:'spreadMethod', startoffset:'startOffset', stddeviation:'stdDeviation', stitchtiles:'stitchTiles', surfacescale:'surfaceScale', systemlanguage:'systemLanguage', tablevalues:'tableValues', targetx:'targetX', targety:'targetY', textlength:'textLength', viewbox:'viewBox', viewtarget:'viewTarget', xchannelselector:'xChannelSelector', ychannelselector:'yChannelSelector', zoomandpan:'zoomAndPan'};
|
|
36
|
+
var SVG_NS = 'http://www.w3.org/2000/svg';
|
|
37
|
+
var EVENT_RE = ${eventRegexLiteral};
|
|
38
|
+
var X_HANDLED = ${handledXAttrsLiteral};
|
|
39
|
+
var KEY_MAP = {enter:'Enter', tab:'Tab', escape:'Escape', space:' ', up:'ArrowUp', down:'ArrowDown', left:'ArrowLeft', right:'ArrowRight', 'delete':'Delete', backspace:'Backspace'};
|
|
40
|
+
|
|
41
|
+
// True for text a binding wrote, or markup :html injected: data, never
|
|
3
42
|
// template. Checked only for text that holds braces, so the climb is rare.
|
|
4
43
|
function isInertContent(node) {
|
|
5
44
|
for (var n = node; n; n = n.parentNode) if (n.__stx_inert_content) return true;
|
|
@@ -241,7 +280,8 @@ else if (part) {
|
|
|
241
280
|
const activeScope = evaluationScope || attrCapturedScope;
|
|
242
281
|
// Decode HTML entities that browsers may encode in attribute values
|
|
243
282
|
// e.g. :text="a > b" may be stored as :text="a > b" in HTML
|
|
244
|
-
|
|
283
|
+
// Nearly no expression holds an entity: six replaces on every run of every binding.
|
|
284
|
+
var expr = rawExpr.indexOf('&') === -1 ? rawExpr : rawExpr.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'");
|
|
245
285
|
try {
|
|
246
286
|
if (/^__[A-Z_]+__$/.test(expr.trim())) return expr;
|
|
247
287
|
|
|
@@ -285,44 +325,8 @@ catch (e2) {
|
|
|
285
325
|
}
|
|
286
326
|
};
|
|
287
327
|
|
|
288
|
-
//
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
// A bound value cannot introduce a URL scheme the page did not ask for.
|
|
292
|
-
// This is the client half of url-safety.ts: the server refuses a scheme
|
|
293
|
-
// substituted into an href, and x-href over a signal reaches the same
|
|
294
|
-
// attribute by another road. Same policy, same unsafe: prefix, so a page
|
|
295
|
-
// behaves the same whether the value arrived at render or at runtime.
|
|
296
|
-
var URL_NAV_ATTR = {href:1, 'xlink:href':1, action:1, formaction:1, ping:1, cite:1, manifest:1, data:1, to:1};
|
|
297
|
-
var URL_FETCH_ATTR = {src:1, srcset:1, poster:1, background:1};
|
|
298
|
-
var urlRefusalWarned = false;
|
|
299
|
-
function safeUrlAttr(attrName, value) {
|
|
300
|
-
var navigable = URL_NAV_ATTR[attrName];
|
|
301
|
-
if (!navigable && !URL_FETCH_ATTR[attrName]) return value;
|
|
302
|
-
if (typeof value !== 'string' || !value) return value;
|
|
303
|
-
// Browsers ignore ASCII whitespace and controls inside a scheme and match
|
|
304
|
-
// it case-insensitively, so the spellings collapse before the test.
|
|
305
|
-
var probe = value.replace(/[\\u0000-\\u0020\\u00a0\\u2000-\\u200f\\u2028\\u2029\\ufeff]+/g, '').toLowerCase();
|
|
306
|
-
var refused = /^(?:javascript|vbscript|livescript|mocha|view-source):/.test(probe)
|
|
307
|
-
|| (navigable
|
|
308
|
-
? /^data:(?:text\\/html|text\\/xml|application\\/xhtml\\+xml|application\\/xml|image\\/svg\\+xml)/.test(probe)
|
|
309
|
-
: /^data:(?:text\\/html|application\\/xhtml\\+xml)/.test(probe));
|
|
310
|
-
if (!refused) return value;
|
|
311
|
-
if (!urlRefusalWarned) {
|
|
312
|
-
urlRefusalWarned = true;
|
|
313
|
-
console.warn('[stx] refused a ' + attrName + ' value whose scheme can run script: ' + probe.slice(0, 24));
|
|
314
|
-
}
|
|
315
|
-
return 'unsafe:' + value;
|
|
316
|
-
}
|
|
317
|
-
// SVG attributes are case-sensitive, but the HTML parser lowercases
|
|
318
|
-
// prefixed attribute names \u2014 ':viewBox' arrives as ':viewbox' because
|
|
319
|
-
// the spec's "adjust SVG attributes" step only covers unprefixed names.
|
|
320
|
-
// Without restoring the canonical casing, setAttribute('viewbox') creates
|
|
321
|
-
// a dead duplicate attribute and the real viewBox never updates.
|
|
322
|
-
var SVG_ATTR_CASE = {attributename:'attributeName', attributetype:'attributeType', basefrequency:'baseFrequency', baseprofile:'baseProfile', calcmode:'calcMode', clippathunits:'clipPathUnits', diffuseconstant:'diffuseConstant', edgemode:'edgeMode', filterunits:'filterUnits', glyphref:'glyphRef', gradienttransform:'gradientTransform', gradientunits:'gradientUnits', kernelmatrix:'kernelMatrix', kernelunitlength:'kernelUnitLength', keypoints:'keyPoints', keysplines:'keySplines', keytimes:'keyTimes', lengthadjust:'lengthAdjust', limitingconeangle:'limitingConeAngle', markerheight:'markerHeight', markerunits:'markerUnits', markerwidth:'markerWidth', maskcontentunits:'maskContentUnits', maskunits:'maskUnits', numoctaves:'numOctaves', pathlength:'pathLength', patterncontentunits:'patternContentUnits', patterntransform:'patternTransform', patternunits:'patternUnits', pointsatx:'pointsAtX', pointsaty:'pointsAtY', pointsatz:'pointsAtZ', preservealpha:'preserveAlpha', preserveaspectratio:'preserveAspectRatio', primitiveunits:'primitiveUnits', refx:'refX', refy:'refY', repeatcount:'repeatCount', repeatdur:'repeatDur', requiredextensions:'requiredExtensions', requiredfeatures:'requiredFeatures', specularconstant:'specularConstant', specularexponent:'specularExponent', spreadmethod:'spreadMethod', startoffset:'startOffset', stddeviation:'stdDeviation', stitchtiles:'stitchTiles', surfacescale:'surfaceScale', systemlanguage:'systemLanguage', tablevalues:'tableValues', targetx:'targetX', targety:'targetY', textlength:'textLength', viewbox:'viewBox', viewtarget:'viewTarget', xchannelselector:'xChannelSelector', ychannelselector:'yChannelSelector', zoomandpan:'zoomAndPan'};
|
|
323
|
-
var SVG_NS = 'http://www.w3.org/2000/svg';
|
|
324
|
-
var EVENT_RE = ${eventRegexLiteral};
|
|
325
|
-
var KEY_MAP = {enter:'Enter', tab:'Tab', escape:'Escape', space:' ', up:'ArrowUp', down:'ArrowDown', left:'ArrowLeft', right:'ArrowRight', 'delete':'Delete', backspace:'Backspace'};
|
|
328
|
+
// One refusal warning per element, as before the policy moved out.
|
|
329
|
+
var urlWarning = { warned: false };
|
|
326
330
|
|
|
327
331
|
// Handle attributes
|
|
328
332
|
getElementAttributes(el).forEach(attr => {
|
|
@@ -357,13 +361,12 @@ catch (e2) {
|
|
|
357
361
|
// :attr still works for backward compat but is reserved for structural directives.
|
|
358
362
|
// x-text, x-html, x-model, x-show, x-if, x-for, x-cloak, x-ref, x-data are
|
|
359
363
|
// handled by their own code paths below \u2014 exclude them here.
|
|
360
|
-
var X_HANDLED = ${handledXAttrsLiteral};
|
|
361
364
|
if (name.startsWith('@bind:') || name.startsWith('x-bind:')
|
|
362
365
|
|| (name.startsWith(':') && !name.startsWith('::') && !DIRECTIVE_NAMES[name.slice(1).split('.')[0]] && !EVENT_RE.test(name.slice(1)))
|
|
363
366
|
|| (name.startsWith('x-') && !X_HANDLED[name.split('.')[0]] && !X_HANDLED[name])) {
|
|
364
367
|
let attrName = name.startsWith('@bind:') ? name.slice(6) : name.startsWith('x-bind:') ? name.slice(7) : name.startsWith('x-') ? name.slice(2) : name.slice(1);
|
|
365
368
|
if (el.namespaceURI === SVG_NS && SVG_ATTR_CASE[attrName]) attrName = SVG_ATTR_CASE[attrName];
|
|
366
|
-
var parentBindingNames = (el.getAttribute && el.getAttribute('data-stx-parent-bindings') || '')
|
|
369
|
+
var parentBindingNames = __stxWords(el.getAttribute && el.getAttribute('data-stx-parent-bindings') || '');
|
|
367
370
|
var bindingScope = el.__stx_parent_scope && parentBindingNames.includes(attrName)
|
|
368
371
|
? el.__stx_parent_scope
|
|
369
372
|
: attrCapturedScope;
|
|
@@ -377,112 +380,7 @@ catch (e2) {
|
|
|
377
380
|
effect(() => {
|
|
378
381
|
if (!attributesVisible()) return;
|
|
379
382
|
const v = evalAttrExpr(value, bindingScope);
|
|
380
|
-
|
|
381
|
-
// attribute does not update a <select>'s chosen option and can leave
|
|
382
|
-
// inputs displaying stale text after a reactive update.
|
|
383
|
-
if (attrName === 'value' && 'value' in el) {
|
|
384
|
-
var controlValue = v;
|
|
385
|
-
if (typeof v === 'object' && v !== null) {
|
|
386
|
-
try { controlValue = JSON.stringify(v); }
|
|
387
|
-
catch (e) { controlValue = String(v); }
|
|
388
|
-
}
|
|
389
|
-
controlValue = v === false || v === null || v === undefined ? '' : String(controlValue);
|
|
390
|
-
el.__stx_bound_value = controlValue;
|
|
391
|
-
var applyControlValue = function() {
|
|
392
|
-
if (!attributesVisible()) return;
|
|
393
|
-
var desiredValue = el.__stx_bound_value == null ? '' : String(el.__stx_bound_value);
|
|
394
|
-
el.value = desiredValue;
|
|
395
|
-
if (desiredValue === '' && el.tagName !== 'OPTION') el.removeAttribute(attrName);
|
|
396
|
-
else if (el.getAttribute(attrName) !== desiredValue) el.setAttribute(attrName, desiredValue);
|
|
397
|
-
if (typeof el.__stx_model_sync === 'function') el.__stx_model_sync();
|
|
398
|
-
};
|
|
399
|
-
applyControlValue();
|
|
400
|
-
|
|
401
|
-
// A select's value binding is processed before its child
|
|
402
|
-
// directives. When a nested :for creates the matching options
|
|
403
|
-
// afterward, the browser otherwise leaves the first option
|
|
404
|
-
// selected. Keep the desired value and reapply it whenever the
|
|
405
|
-
// option tree changes, including later reactive list updates.
|
|
406
|
-
if (el.tagName === 'SELECT' && !el.__stx_value_observer && typeof window.MutationObserver !== 'undefined') {
|
|
407
|
-
el.__stx_value_observer = new window.MutationObserver(applyControlValue);
|
|
408
|
-
el.__stx_value_observer.observe(el, {
|
|
409
|
-
childList: true,
|
|
410
|
-
subtree: true,
|
|
411
|
-
attributes: true,
|
|
412
|
-
attributeFilter: ['value'],
|
|
413
|
-
});
|
|
414
|
-
el.__stx_destroy = el.__stx_destroy || [];
|
|
415
|
-
el.__stx_destroy.push(function() {
|
|
416
|
-
if (el.__stx_value_observer) el.__stx_value_observer.disconnect();
|
|
417
|
-
el.__stx_value_observer = null;
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
// Checked, selected, and indeterminate are live DOM properties, just like value.
|
|
423
|
-
// Updating only the HTML attribute leaves a user-touched checkbox or
|
|
424
|
-
// radio in its previous state because the property becomes dirty.
|
|
425
|
-
// Indeterminate has no corresponding effective HTML attribute at all.
|
|
426
|
-
if ((attrName === 'checked' || attrName === 'selected' || attrName === 'indeterminate') && attrName in el) {
|
|
427
|
-
var selectedState = Boolean(v);
|
|
428
|
-
el[attrName] = selectedState;
|
|
429
|
-
if (attrName === 'indeterminate') {
|
|
430
|
-
el.removeAttribute(attrName);
|
|
431
|
-
}
|
|
432
|
-
else if (selectedState) {
|
|
433
|
-
el.setAttribute(attrName, '');
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
el.removeAttribute(attrName);
|
|
437
|
-
}
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
// aria-* and data-* carry a STRING: the platform's boolean attribute
|
|
441
|
-
// is presence, which cannot say "false" and wrote data-open="" for
|
|
442
|
-
// true, so a [data-open='true'] selector never matched. React renders
|
|
443
|
-
// both as "true" / "false", and so does this.
|
|
444
|
-
if ((attrName.startsWith('aria-') || attrName.startsWith('data-')) && typeof v === 'boolean') {
|
|
445
|
-
stxHost.setAttribute(el, attrName, String(v));
|
|
446
|
-
}
|
|
447
|
-
else if (typeof v === 'boolean') {
|
|
448
|
-
stxHost.setAttribute(el, attrName, v);
|
|
449
|
-
}
|
|
450
|
-
else if (v === null || v === undefined) {
|
|
451
|
-
stxHost.removeAttribute(el, attrName);
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
var attrValue = v;
|
|
455
|
-
if (typeof v === 'object') {
|
|
456
|
-
try { attrValue = JSON.stringify(v); }
|
|
457
|
-
catch (e) { attrValue = String(v); }
|
|
458
|
-
}
|
|
459
|
-
var attrValueSafe = safeUrlAttr(attrName, attrValue);
|
|
460
|
-
// Keep structured values structured for non-DOM hosts. The DOM
|
|
461
|
-
// host serializes them at its boundary, preserving web output.
|
|
462
|
-
var hostValue = (typeof v === 'object' && v !== null) ? v : attrValueSafe;
|
|
463
|
-
// Writing the value an attribute already has is not nothing: a
|
|
464
|
-
// frame given its own src again loads again (an entry in the
|
|
465
|
-
// page's history each time) and a video restarts. A player whose
|
|
466
|
-
// rest and next set share a video re-set it on every step.
|
|
467
|
-
if (el.getAttribute(attrName) === String(attrValueSafe)) return;
|
|
468
|
-
// A frame already on the page that is pointed somewhere else
|
|
469
|
-
// navigates, and every navigation is an entry in the page's own
|
|
470
|
-
// history: a player showing a video per step left one per step,
|
|
471
|
-
// and Back had to be tapped through all of them before it left
|
|
472
|
-
// the screen. Out of the page and back in, the frame starts afresh
|
|
473
|
-
// (its first load adds no entry, and its old entries go with it).
|
|
474
|
-
var parentNode = el.parentNode;
|
|
475
|
-
if (attrName === 'src' && el.tagName === 'IFRAME' && parentNode && el.isConnected
|
|
476
|
-
&& el.hasAttribute('src') && el.getAttribute('src') !== String(attrValueSafe)) {
|
|
477
|
-
var nextSibling = el.nextSibling;
|
|
478
|
-
parentNode.removeChild(el);
|
|
479
|
-
stxHost.setAttribute(el, attrName, hostValue);
|
|
480
|
-
parentNode.insertBefore(el, nextSibling);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
stxHost.setAttribute(el, attrName, hostValue);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
383
|
+
applyBoundAttribute(el, attrName, v, attributesVisible, urlWarning);
|
|
486
384
|
});
|
|
487
385
|
el.removeAttribute(name);
|
|
488
386
|
}
|
|
@@ -557,7 +455,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
557
455
|
const parts = name.slice(1).split('.');
|
|
558
456
|
// HTML folds attribute names to lowercase; the forwarding metadata
|
|
559
457
|
// retains the declared event spelling (e.g. update:modelValue).
|
|
560
|
-
const parentEventNames = (el.getAttribute && el.getAttribute('data-stx-parent-events') || '')
|
|
458
|
+
const parentEventNames = __stxWords(el.getAttribute && el.getAttribute('data-stx-parent-events') || '');
|
|
561
459
|
const eventName = parentEventNames.find(function(event) {
|
|
562
460
|
return event.toLowerCase() === parts[0].toLowerCase();
|
|
563
461
|
}) || parts[0];
|
|
@@ -580,146 +478,11 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
580
478
|
|
|
581
479
|
// Capture scope at setup time so @for loop variables are available when event fires
|
|
582
480
|
const isForwardedComponentEvent = !!(el.__stx_parent_scope && parentEventNames.includes(eventName));
|
|
583
|
-
|
|
481
|
+
const eventCapturedScope = isForwardedComponentEvent
|
|
584
482
|
? layerTemplateScopes(globalHelpers, el.__stx_parent_scope)
|
|
585
483
|
: layerTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
|
|
586
484
|
|
|
587
|
-
|
|
588
|
-
// A forwarded handler belongs to the caller, whose scope can be
|
|
589
|
-
// resolved again after this listener is bound: a component inside
|
|
590
|
-
// another component's :if, in a dialog, was bound against the
|
|
591
|
-
// page's scope and only later handed its real caller, so
|
|
592
|
-
// @pick="pickFromBank" found nothing and did nothing. Read it now.
|
|
593
|
-
if (isForwardedComponentEvent && el.__stx_parent_scope)
|
|
594
|
-
eventCapturedScope = layerTemplateScopes(globalHelpers, el.__stx_parent_scope);
|
|
595
|
-
// Vue-style component listeners fall through to the rendered native
|
|
596
|
-
// root unless the child emits the same event. Signal components use
|
|
597
|
-
// a scope wrapper, so native events arrive here from a descendant.
|
|
598
|
-
// Ignore that native event only after defineEmits() has declared or
|
|
599
|
-
// emitted the same name, preventing submit/click handlers from
|
|
600
|
-
// firing once for the native event and again for the CustomEvent.
|
|
601
|
-
var componentEmits = el.__stx_component_emits;
|
|
602
|
-
if (isForwardedComponentEvent && event.target !== el
|
|
603
|
-
&& componentEmits && componentEmits[eventName]) return;
|
|
604
|
-
|
|
605
|
-
// Vue-style component handlers receive the emitted payload directly.
|
|
606
|
-
// Native root events still receive the Event object so server-only
|
|
607
|
-
// components can forward clicks and other browser events.
|
|
608
|
-
var emittedArgs = isForwardedComponentEvent && event instanceof CustomEvent
|
|
609
|
-
&& Array.isArray(event.__stx_emit_args) ? event.__stx_emit_args : null;
|
|
610
|
-
var handlerEvent = emittedArgs ? emittedArgs[0]
|
|
611
|
-
: isForwardedComponentEvent && event instanceof CustomEvent ? event.detail : event;
|
|
612
|
-
|
|
613
|
-
// Skip an opener click that reaches UI which just became visible in
|
|
614
|
-
// this frame. A click whose target is inside the revealed subtree is
|
|
615
|
-
// a real interaction and must not be discarded, especially for
|
|
616
|
-
// async lists whose controls are usable as soon as they render.
|
|
617
|
-
if (eventName === 'click') {
|
|
618
|
-
var ancestor = el;
|
|
619
|
-
while (ancestor) {
|
|
620
|
-
if (ancestor.__stx_shown_at
|
|
621
|
-
&& (performance.now() - ancestor.__stx_shown_at) < 50
|
|
622
|
-
&& !(ancestor.contains && ancestor.contains(event.target))) return;
|
|
623
|
-
ancestor = ancestor.parentElement;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
// System key modifiers
|
|
627
|
-
if (modifiers.includes('self') && event.target !== el) return;
|
|
628
|
-
if (modifiers.includes('ctrl') && !event.ctrlKey) return;
|
|
629
|
-
if (modifiers.includes('alt') && !event.altKey) return;
|
|
630
|
-
if (modifiers.includes('shift') && !event.shiftKey) return;
|
|
631
|
-
if (modifiers.includes('meta') && !event.metaKey) return;
|
|
632
|
-
// Key modifiers
|
|
633
|
-
for (var mi = 0; mi < modifiers.length; mi++) {
|
|
634
|
-
if (KEY_MAP[modifiers[mi]] && event.key !== KEY_MAP[modifiers[mi]]) return;
|
|
635
|
-
}
|
|
636
|
-
if (modifiers.includes('prevent')) event.preventDefault();
|
|
637
|
-
if (modifiers.includes('stop')) event.stopPropagation();
|
|
638
|
-
// Execute with captured scope (includes @for loop variables)
|
|
639
|
-
// For x-data scopes, expressions like "mobileOpen = !mobileOpen" need to
|
|
640
|
-
// read the signal value AND write back through the signal's setter.
|
|
641
|
-
try {
|
|
642
|
-
if (!value || /^__[A-Z_]+__$/.test(value.trim())) return;
|
|
643
|
-
var shorthandFn = parseEventShorthand(value, eventCapturedScope);
|
|
644
|
-
if (shorthandFn) { shorthandFn.apply(null, emittedArgs || [handlerEvent]); return; }
|
|
645
|
-
// Check if any scope values are signals (x-data pattern)
|
|
646
|
-
// A derived value reads like a signal in a handler, as it does in a
|
|
647
|
-
// binding: \`pick(selectedPackage)\` passes the package. Leaving it
|
|
648
|
-
// out handed the handler the derived's getter function, so
|
|
649
|
-
// \`selectedPackage.trainer_id\` was undefined with nothing said.
|
|
650
|
-
// Only the names the handler mentions. A page's scope holds
|
|
651
|
-
// hundreds; reading, testing and declaring every one of them on
|
|
652
|
-
// each click or hover cost far more than the handler itself.
|
|
653
|
-
var handlerNames = __stxNamesIn(value).filter(function(k) {
|
|
654
|
-
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) && (k in eventCapturedScope);
|
|
655
|
-
});
|
|
656
|
-
var hasSignals = handlerNames.some(function(k) {
|
|
657
|
-
var v = eventCapturedScope[k];
|
|
658
|
-
return v && typeof v === 'function' && (v._isSignal || v._isDerived);
|
|
659
|
-
});
|
|
660
|
-
// Only use signal read/write proxy for DIRECT assignment expressions
|
|
661
|
-
// like "count = count + 1" or "open = !open". Function calls like
|
|
662
|
-
// "openModal()" handle their own signal.set() internally \u2014 the writeback
|
|
663
|
-
// would RESET signals to their pre-handler values.
|
|
664
|
-
var isDirectAssignment = hasSignals && /^[a-zA-Z_$]\\w*\\s*=/.test(value.trim()) && !value.trim().startsWith('==');
|
|
665
|
-
if (isDirectAssignment) {
|
|
666
|
-
var getVars = handlerNames.map(function(k) {
|
|
667
|
-
return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && (__s["' + k + '"]._isSignal || __s["' + k + '"]._isDerived) ? __s["' + k + '"]() : __s["' + k + '"]';
|
|
668
|
-
}).join(';');
|
|
669
|
-
var setVars = handlerNames.filter(function(k) {
|
|
670
|
-
var v = eventCapturedScope[k];
|
|
671
|
-
return v && typeof v === 'function' && v._isSignal;
|
|
672
|
-
}).map(function(k) {
|
|
673
|
-
return 'if(' + k + ' !== __s["' + k + '"]()) __s["' + k + '"].set(' + k + ')';
|
|
674
|
-
}).join(';');
|
|
675
|
-
var body = getVars + ';' + value + ';' + setVars;
|
|
676
|
-
var fn2 = __stxCompile(['__s', '$event'], body);
|
|
677
|
-
fn2(eventCapturedScope, handlerEvent);
|
|
678
|
-
} else if (hasSignals) {
|
|
679
|
-
// Function calls with signals in scope keep any signal used through
|
|
680
|
-
// its object API as a raw signal function, and unwrap the rest for
|
|
681
|
-
// primitive reads.
|
|
682
|
-
var unwrapVars = handlerNames.map(function(k) {
|
|
683
|
-
var v = eventCapturedScope[k];
|
|
684
|
-
// A :for item is a signal only as an implementation detail, so
|
|
685
|
-
// that keyed rows can update in place. Its \`.value\` is a field
|
|
686
|
-
// on the item, never the signal compatibility API \u2014 the same
|
|
687
|
-
// rule createAutoUnwrapProxy states for binding expressions.
|
|
688
|
-
// Without the carve-out, expressionUsesSignalApi sees
|
|
689
|
-
// \`option.value\` and hands the handler the raw signal, so a
|
|
690
|
-
// handler like \`pick(option.value)\` receives the whole item.
|
|
691
|
-
// It is not an error, so it lands silently: the wrong value is
|
|
692
|
-
// stored and only surfaces much later.
|
|
693
|
-
if (v && typeof v === 'function' && ((v._isSignal && !v._isStxLoopItem) || v._isDerived)
|
|
694
|
-
&& (expressionCallsSignal(value, k) || expressionUsesSignalApi(value, k))) {
|
|
695
|
-
return 'var ' + k + ' = __s["' + k + '"]';
|
|
696
|
-
}
|
|
697
|
-
return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && (__s["' + k + '"]._isSignal || __s["' + k + '"]._isDerived) ? __s["' + k + '"]() : __s["' + k + '"]';
|
|
698
|
-
}).join(';');
|
|
699
|
-
var fn3 = __stxCompile(['__s', '$event'], unwrapVars + ';' + value);
|
|
700
|
-
fn3(eventCapturedScope, handlerEvent);
|
|
701
|
-
} else {
|
|
702
|
-
var fn = __stxCompileScoped(eventCapturedScope, ['$event'], value);
|
|
703
|
-
fn(...__stxArgs(fn, eventCapturedScope), handlerEvent);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
catch (e) {
|
|
707
|
-
// See #1694: dropping the TypeError/ReferenceError carve-out for inline
|
|
708
|
-
// handlers \u2014 same reason as executeHandler above. Silencing these hid
|
|
709
|
-
// the substring-detector bug (auto-unwrap missing .set( inside helper
|
|
710
|
-
// calls) for ~30min of bisecting in the field.
|
|
711
|
-
console.warn('[STX] Handler error:', value, e);
|
|
712
|
-
}
|
|
713
|
-
}, {
|
|
714
|
-
capture: modifiers.includes('capture'),
|
|
715
|
-
// A touch or wheel listener that is not passive holds every scroll
|
|
716
|
-
// starting on the element until this thread has run it. Passive
|
|
717
|
-
// unless .prevent needs preventDefault() or .nonpassive asks.
|
|
718
|
-
passive: modifiers.includes('passive')
|
|
719
|
-
|| (/^(touchstart|touchmove|wheel|mousewheel)$/i.test(eventName)
|
|
720
|
-
&& !modifiers.includes('prevent') && !modifiers.includes('nonpassive')),
|
|
721
|
-
once: modifiers.includes('once')
|
|
722
|
-
});
|
|
485
|
+
listenTemplateEvent(el, eventName, modifiers, value, eventCapturedScope, isForwardedComponentEvent);
|
|
723
486
|
el.removeAttribute(name);
|
|
724
487
|
}
|
|
725
488
|
});
|
|
@@ -739,5 +502,260 @@ catch (e) {
|
|
|
739
502
|
processElement(child, scope);
|
|
740
503
|
});
|
|
741
504
|
}
|
|
742
|
-
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// A bound attribute's new value, written as the element's kind wants it:
|
|
508
|
+
// live properties for form controls, strings for aria-/data- booleans, a
|
|
509
|
+
// structured value kept structured for a native host. Shared by
|
|
510
|
+
// processElement and the native row plans so both write a value one way.
|
|
511
|
+
function applyBoundAttribute(el, attrName, v, attributesVisible, urlWarning) {
|
|
512
|
+
// Form control values are live DOM properties. Setting only the HTML
|
|
513
|
+
// attribute does not update a <select>'s chosen option and can leave
|
|
514
|
+
// inputs displaying stale text after a reactive update.
|
|
515
|
+
if (attrName === 'value' && 'value' in el) {
|
|
516
|
+
var controlValue = v;
|
|
517
|
+
if (typeof v === 'object' && v !== null) {
|
|
518
|
+
try { controlValue = JSON.stringify(v); }
|
|
519
|
+
catch (e) { controlValue = String(v); }
|
|
520
|
+
}
|
|
521
|
+
controlValue = v === false || v === null || v === undefined ? '' : String(controlValue);
|
|
522
|
+
el.__stx_bound_value = controlValue;
|
|
523
|
+
var applyControlValue = function() {
|
|
524
|
+
if (!attributesVisible()) return;
|
|
525
|
+
var desiredValue = el.__stx_bound_value == null ? '' : String(el.__stx_bound_value);
|
|
526
|
+
el.value = desiredValue;
|
|
527
|
+
if (desiredValue === '' && el.tagName !== 'OPTION') el.removeAttribute(attrName);
|
|
528
|
+
else if (el.getAttribute(attrName) !== desiredValue) el.setAttribute(attrName, desiredValue);
|
|
529
|
+
if (typeof el.__stx_model_sync === 'function') el.__stx_model_sync();
|
|
530
|
+
};
|
|
531
|
+
applyControlValue();
|
|
532
|
+
|
|
533
|
+
// A select's value binding is processed before its child
|
|
534
|
+
// directives. When a nested :for creates the matching options
|
|
535
|
+
// afterward, the browser otherwise leaves the first option
|
|
536
|
+
// selected. Keep the desired value and reapply it whenever the
|
|
537
|
+
// option tree changes, including later reactive list updates.
|
|
538
|
+
if (el.tagName === 'SELECT' && !el.__stx_value_observer && typeof window.MutationObserver !== 'undefined') {
|
|
539
|
+
el.__stx_value_observer = new window.MutationObserver(applyControlValue);
|
|
540
|
+
el.__stx_value_observer.observe(el, {
|
|
541
|
+
childList: true,
|
|
542
|
+
subtree: true,
|
|
543
|
+
attributes: true,
|
|
544
|
+
attributeFilter: ['value'],
|
|
545
|
+
});
|
|
546
|
+
el.__stx_destroy = el.__stx_destroy || [];
|
|
547
|
+
el.__stx_destroy.push(function() {
|
|
548
|
+
if (el.__stx_value_observer) el.__stx_value_observer.disconnect();
|
|
549
|
+
el.__stx_value_observer = null;
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
// Checked, selected, and indeterminate are live DOM properties, just like value.
|
|
555
|
+
// Updating only the HTML attribute leaves a user-touched checkbox or
|
|
556
|
+
// radio in its previous state because the property becomes dirty.
|
|
557
|
+
// Indeterminate has no corresponding effective HTML attribute at all.
|
|
558
|
+
if ((attrName === 'checked' || attrName === 'selected' || attrName === 'indeterminate') && attrName in el) {
|
|
559
|
+
var selectedState = Boolean(v);
|
|
560
|
+
el[attrName] = selectedState;
|
|
561
|
+
if (attrName === 'indeterminate') {
|
|
562
|
+
el.removeAttribute(attrName);
|
|
563
|
+
}
|
|
564
|
+
else if (selectedState) {
|
|
565
|
+
el.setAttribute(attrName, '');
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
el.removeAttribute(attrName);
|
|
569
|
+
}
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
// aria-* and data-* carry a STRING: the platform's boolean attribute
|
|
573
|
+
// is presence, which cannot say "false" and wrote data-open="" for
|
|
574
|
+
// true, so a [data-open='true'] selector never matched. React renders
|
|
575
|
+
// both as "true" / "false", and so does this.
|
|
576
|
+
if ((attrName.startsWith('aria-') || attrName.startsWith('data-')) && typeof v === 'boolean') {
|
|
577
|
+
stxHost.setAttribute(el, attrName, String(v));
|
|
578
|
+
}
|
|
579
|
+
else if (typeof v === 'boolean') {
|
|
580
|
+
stxHost.setAttribute(el, attrName, v);
|
|
581
|
+
}
|
|
582
|
+
else if (v === null || v === undefined) {
|
|
583
|
+
stxHost.removeAttribute(el, attrName);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
var attrValue = v;
|
|
587
|
+
if (typeof v === 'object') {
|
|
588
|
+
try { attrValue = JSON.stringify(v); }
|
|
589
|
+
catch (e) { attrValue = String(v); }
|
|
590
|
+
}
|
|
591
|
+
var attrValueSafe = __stxSafeUrlAttr(attrName, attrValue, urlWarning);
|
|
592
|
+
// Keep structured values structured for non-DOM hosts. The DOM
|
|
593
|
+
// host serializes them at its boundary, preserving web output.
|
|
594
|
+
var hostValue = (typeof v === 'object' && v !== null) ? v : attrValueSafe;
|
|
595
|
+
// Writing the value an attribute already has is not nothing: a
|
|
596
|
+
// frame given its own src again loads again (an entry in the
|
|
597
|
+
// page's history each time) and a video restarts. A player whose
|
|
598
|
+
// rest and next set share a video re-set it on every step.
|
|
599
|
+
if (el.getAttribute(attrName) === String(attrValueSafe)) return;
|
|
600
|
+
// A frame already on the page that is pointed somewhere else
|
|
601
|
+
// navigates, and every navigation is an entry in the page's own
|
|
602
|
+
// history: a player showing a video per step left one per step,
|
|
603
|
+
// and Back had to be tapped through all of them before it left
|
|
604
|
+
// the screen. Out of the page and back in, the frame starts afresh
|
|
605
|
+
// (its first load adds no entry, and its old entries go with it).
|
|
606
|
+
var parentNode = el.parentNode;
|
|
607
|
+
if (attrName === 'src' && el.tagName === 'IFRAME' && parentNode && el.isConnected
|
|
608
|
+
&& el.hasAttribute('src') && el.getAttribute('src') !== String(attrValueSafe)) {
|
|
609
|
+
var nextSibling = el.nextSibling;
|
|
610
|
+
parentNode.removeChild(el);
|
|
611
|
+
stxHost.setAttribute(el, attrName, hostValue);
|
|
612
|
+
parentNode.insertBefore(el, nextSibling);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
stxHost.setAttribute(el, attrName, hostValue);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// An authored @event listener. The scope is re-read for a forwarded
|
|
621
|
+
// component event, whose caller can be resolved after the listener is bound.
|
|
622
|
+
function listenTemplateEvent(el, eventName, modifiers, value, eventCapturedScope, isForwardedComponentEvent) {
|
|
623
|
+
stxHost.listen(el, eventName, (event) => {
|
|
624
|
+
// A forwarded handler belongs to the caller, whose scope can be
|
|
625
|
+
// resolved again after this listener is bound: a component inside
|
|
626
|
+
// another component's :if, in a dialog, was bound against the
|
|
627
|
+
// page's scope and only later handed its real caller, so
|
|
628
|
+
// @pick="pickFromBank" found nothing and did nothing. Read it now.
|
|
629
|
+
if (isForwardedComponentEvent && el.__stx_parent_scope)
|
|
630
|
+
eventCapturedScope = layerTemplateScopes(globalHelpers, el.__stx_parent_scope);
|
|
631
|
+
// Vue-style component listeners fall through to the rendered native
|
|
632
|
+
// root unless the child emits the same event. Signal components use
|
|
633
|
+
// a scope wrapper, so native events arrive here from a descendant.
|
|
634
|
+
// Ignore that native event only after defineEmits() has declared or
|
|
635
|
+
// emitted the same name, preventing submit/click handlers from
|
|
636
|
+
// firing once for the native event and again for the CustomEvent.
|
|
637
|
+
var componentEmits = el.__stx_component_emits;
|
|
638
|
+
if (isForwardedComponentEvent && event.target !== el
|
|
639
|
+
&& componentEmits && componentEmits[eventName]) return;
|
|
640
|
+
|
|
641
|
+
// Vue-style component handlers receive the emitted payload directly.
|
|
642
|
+
// Native root events still receive the Event object so server-only
|
|
643
|
+
// components can forward clicks and other browser events.
|
|
644
|
+
var emittedArgs = isForwardedComponentEvent && event instanceof CustomEvent
|
|
645
|
+
&& Array.isArray(event.__stx_emit_args) ? event.__stx_emit_args : null;
|
|
646
|
+
var handlerEvent = emittedArgs ? emittedArgs[0]
|
|
647
|
+
: isForwardedComponentEvent && event instanceof CustomEvent ? event.detail : event;
|
|
648
|
+
|
|
649
|
+
// Skip an opener click that reaches UI which just became visible in
|
|
650
|
+
// this frame. A click whose target is inside the revealed subtree is
|
|
651
|
+
// a real interaction and must not be discarded, especially for
|
|
652
|
+
// async lists whose controls are usable as soon as they render.
|
|
653
|
+
if (eventName === 'click') {
|
|
654
|
+
var ancestor = el;
|
|
655
|
+
while (ancestor) {
|
|
656
|
+
if (ancestor.__stx_shown_at
|
|
657
|
+
&& (performance.now() - ancestor.__stx_shown_at) < 50
|
|
658
|
+
&& !(ancestor.contains && ancestor.contains(event.target))) return;
|
|
659
|
+
ancestor = ancestor.parentElement;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
// System key modifiers
|
|
663
|
+
if (modifiers.includes('self') && event.target !== el) return;
|
|
664
|
+
if (modifiers.includes('ctrl') && !event.ctrlKey) return;
|
|
665
|
+
if (modifiers.includes('alt') && !event.altKey) return;
|
|
666
|
+
if (modifiers.includes('shift') && !event.shiftKey) return;
|
|
667
|
+
if (modifiers.includes('meta') && !event.metaKey) return;
|
|
668
|
+
// Key modifiers
|
|
669
|
+
for (var mi = 0; mi < modifiers.length; mi++) {
|
|
670
|
+
if (KEY_MAP[modifiers[mi]] && event.key !== KEY_MAP[modifiers[mi]]) return;
|
|
671
|
+
}
|
|
672
|
+
if (modifiers.includes('prevent')) event.preventDefault();
|
|
673
|
+
if (modifiers.includes('stop')) event.stopPropagation();
|
|
674
|
+
// Execute with captured scope (includes @for loop variables)
|
|
675
|
+
// For x-data scopes, expressions like "mobileOpen = !mobileOpen" need to
|
|
676
|
+
// read the signal value AND write back through the signal's setter.
|
|
677
|
+
try {
|
|
678
|
+
if (!value || /^__[A-Z_]+__$/.test(value.trim())) return;
|
|
679
|
+
var shorthandFn = parseEventShorthand(value, eventCapturedScope);
|
|
680
|
+
if (shorthandFn) { shorthandFn.apply(null, emittedArgs || [handlerEvent]); return; }
|
|
681
|
+
// Check if any scope values are signals (x-data pattern)
|
|
682
|
+
// A derived value reads like a signal in a handler, as it does in a
|
|
683
|
+
// binding: \`pick(selectedPackage)\` passes the package. Leaving it
|
|
684
|
+
// out handed the handler the derived's getter function, so
|
|
685
|
+
// \`selectedPackage.trainer_id\` was undefined with nothing said.
|
|
686
|
+
// Only the names the handler mentions. A page's scope holds
|
|
687
|
+
// hundreds; reading, testing and declaring every one of them on
|
|
688
|
+
// each click or hover cost far more than the handler itself.
|
|
689
|
+
var handlerNames = __stxNamesIn(value).filter(function(k) {
|
|
690
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) && (k in eventCapturedScope);
|
|
691
|
+
});
|
|
692
|
+
var hasSignals = handlerNames.some(function(k) {
|
|
693
|
+
var v = eventCapturedScope[k];
|
|
694
|
+
return v && typeof v === 'function' && (v._isSignal || v._isDerived);
|
|
695
|
+
});
|
|
696
|
+
// Only use signal read/write proxy for DIRECT assignment expressions
|
|
697
|
+
// like "count = count + 1" or "open = !open". Function calls like
|
|
698
|
+
// "openModal()" handle their own signal.set() internally \u2014 the writeback
|
|
699
|
+
// would RESET signals to their pre-handler values.
|
|
700
|
+
var isDirectAssignment = hasSignals && /^[a-zA-Z_$]\\w*\\s*=/.test(value.trim()) && !value.trim().startsWith('==');
|
|
701
|
+
if (isDirectAssignment) {
|
|
702
|
+
var getVars = handlerNames.map(function(k) {
|
|
703
|
+
return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && (__s["' + k + '"]._isSignal || __s["' + k + '"]._isDerived) ? __s["' + k + '"]() : __s["' + k + '"]';
|
|
704
|
+
}).join(';');
|
|
705
|
+
var setVars = handlerNames.filter(function(k) {
|
|
706
|
+
var v = eventCapturedScope[k];
|
|
707
|
+
return v && typeof v === 'function' && v._isSignal;
|
|
708
|
+
}).map(function(k) {
|
|
709
|
+
return 'if(' + k + ' !== __s["' + k + '"]()) __s["' + k + '"].set(' + k + ')';
|
|
710
|
+
}).join(';');
|
|
711
|
+
var body = getVars + ';' + value + ';' + setVars;
|
|
712
|
+
var fn2 = __stxCompile(['__s', '$event'], body);
|
|
713
|
+
fn2(eventCapturedScope, handlerEvent);
|
|
714
|
+
} else if (hasSignals) {
|
|
715
|
+
// Function calls with signals in scope keep any signal used through
|
|
716
|
+
// its object API as a raw signal function, and unwrap the rest for
|
|
717
|
+
// primitive reads.
|
|
718
|
+
var unwrapVars = handlerNames.map(function(k) {
|
|
719
|
+
var v = eventCapturedScope[k];
|
|
720
|
+
// A :for item is a signal only as an implementation detail, so
|
|
721
|
+
// that keyed rows can update in place. Its \`.value\` is a field
|
|
722
|
+
// on the item, never the signal compatibility API \u2014 the same
|
|
723
|
+
// rule createAutoUnwrapProxy states for binding expressions.
|
|
724
|
+
// Without the carve-out, expressionUsesSignalApi sees
|
|
725
|
+
// \`option.value\` and hands the handler the raw signal, so a
|
|
726
|
+
// handler like \`pick(option.value)\` receives the whole item.
|
|
727
|
+
// It is not an error, so it lands silently: the wrong value is
|
|
728
|
+
// stored and only surfaces much later.
|
|
729
|
+
if (v && typeof v === 'function' && ((v._isSignal && !v._isStxLoopItem) || v._isDerived)
|
|
730
|
+
&& (expressionCallsSignal(value, k) || expressionUsesSignalApi(value, k))) {
|
|
731
|
+
return 'var ' + k + ' = __s["' + k + '"]';
|
|
732
|
+
}
|
|
733
|
+
return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && (__s["' + k + '"]._isSignal || __s["' + k + '"]._isDerived) ? __s["' + k + '"]() : __s["' + k + '"]';
|
|
734
|
+
}).join(';');
|
|
735
|
+
var fn3 = __stxCompile(['__s', '$event'], unwrapVars + ';' + value);
|
|
736
|
+
fn3(eventCapturedScope, handlerEvent);
|
|
737
|
+
} else {
|
|
738
|
+
var fn = __stxCompileScoped(eventCapturedScope, ['$event'], value);
|
|
739
|
+
fn(...__stxArgs(fn, eventCapturedScope), handlerEvent);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
catch (e) {
|
|
743
|
+
// See #1694: dropping the TypeError/ReferenceError carve-out for inline
|
|
744
|
+
// handlers \u2014 same reason as executeHandler above. Silencing these hid
|
|
745
|
+
// the substring-detector bug (auto-unwrap missing .set( inside helper
|
|
746
|
+
// calls) for ~30min of bisecting in the field.
|
|
747
|
+
console.warn('[STX] Handler error:', value, e);
|
|
748
|
+
}
|
|
749
|
+
}, {
|
|
750
|
+
capture: modifiers.includes('capture'),
|
|
751
|
+
// A touch or wheel listener that is not passive holds every scroll
|
|
752
|
+
// starting on the element until this thread has run it. Passive
|
|
753
|
+
// unless .prevent needs preventDefault() or .nonpassive asks.
|
|
754
|
+
passive: modifiers.includes('passive')
|
|
755
|
+
|| (/^(touchstart|touchmove|wheel|mousewheel)$/i.test(eventName)
|
|
756
|
+
&& !modifiers.includes('prevent') && !modifiers.includes('nonpassive')),
|
|
757
|
+
once: modifiers.includes('once')
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
`;
|
|
743
761
|
}
|