solid-js 1.7.0-beta.0 → 1.7.0-beta.1

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/server.js CHANGED
@@ -4,7 +4,6 @@ const $TRACK = Symbol("solid-track");
4
4
  const $DEVCOMP = Symbol("solid-dev-component");
5
5
  const DEV = undefined;
6
6
  const ERROR = Symbol("error");
7
- const BRANCH = Symbol("branch");
8
7
  function castError(err) {
9
8
  if (err instanceof Error) return err;
10
9
  return new Error(typeof err === "string" ? err : "Unknown error", {
@@ -19,19 +18,35 @@ function handleError(err) {
19
18
  }
20
19
  const UNOWNED = {
21
20
  context: null,
22
- owner: null
21
+ owner: null,
22
+ owned: null,
23
+ cleanups: null
23
24
  };
24
25
  let Owner = null;
26
+ function createOwner() {
27
+ const o = {
28
+ owner: Owner,
29
+ context: null,
30
+ owned: null,
31
+ cleanups: null
32
+ };
33
+ if (Owner) {
34
+ if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
35
+ }
36
+ return o;
37
+ }
25
38
  function createRoot(fn, detachedOwner) {
26
39
  const owner = Owner,
27
40
  root = fn.length === 0 ? UNOWNED : {
28
41
  context: null,
29
- owner: detachedOwner === undefined ? owner : detachedOwner
42
+ owner: detachedOwner === undefined ? owner : detachedOwner,
43
+ owned: null,
44
+ cleanups: null
30
45
  };
31
46
  Owner = root;
32
47
  let result;
33
48
  try {
34
- result = fn(() => {});
49
+ result = fn(fn.length === 0 ? () => {} : () => cleanNode(root));
35
50
  } catch (err) {
36
51
  handleError(err);
37
52
  } finally {
@@ -45,10 +60,7 @@ function createSignal(value, options) {
45
60
  }];
46
61
  }
47
62
  function createComputed(fn, value) {
48
- Owner = {
49
- owner: Owner,
50
- context: null
51
- };
63
+ Owner = createOwner();
52
64
  try {
53
65
  fn(value);
54
66
  } catch (err) {
@@ -65,10 +77,7 @@ function createReaction(fn) {
65
77
  };
66
78
  }
67
79
  function createMemo(fn, value) {
68
- Owner = {
69
- owner: Owner,
70
- context: null
71
- };
80
+ Owner = createOwner();
72
81
  let v;
73
82
  try {
74
83
  v = fn(value);
@@ -104,16 +113,36 @@ function on(deps, fn, options = {}) {
104
113
  }
105
114
  function onMount(fn) {}
106
115
  function onCleanup(fn) {
107
- let node;
108
- if (Owner && (node = lookup(Owner, BRANCH))) {
109
- if (!node.cleanups) node.cleanups = [fn];else node.cleanups.push(fn);
116
+ if (Owner) {
117
+ if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
110
118
  }
111
119
  return fn;
112
120
  }
113
121
  function cleanNode(node) {
122
+ if (node.owned) {
123
+ for (let i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
124
+ node.owned = null;
125
+ }
114
126
  if (node.cleanups) {
115
127
  for (let i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
116
- node.cleanups = undefined;
128
+ node.cleanups = null;
129
+ }
130
+ }
131
+ function catchError(fn, handler) {
132
+ Owner = {
133
+ owner: Owner,
134
+ context: {
135
+ [ERROR]: [handler]
136
+ },
137
+ owned: null,
138
+ cleanups: null
139
+ };
140
+ try {
141
+ return fn();
142
+ } catch (err) {
143
+ handleError(err);
144
+ } finally {
145
+ Owner = Owner.owner;
117
146
  }
118
147
  }
119
148
  function onError(fn) {
@@ -343,7 +372,7 @@ function Index(props) {
343
372
  }
344
373
  function Show(props) {
345
374
  let c;
346
- return props.when ? typeof (c = props.children) === "function" ? c(props.when) : c : props.fallback || "";
375
+ return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
347
376
  }
348
377
  function Switch(props) {
349
378
  let conditions = props.children;
@@ -352,7 +381,7 @@ function Switch(props) {
352
381
  const w = conditions[i].when;
353
382
  if (w) {
354
383
  const c = conditions[i].children;
355
- return typeof c === "function" ? c(w) : c;
384
+ return typeof c === "function" ? c(conditions[i].keyed ? w : () => w) : c;
356
385
  }
357
386
  }
358
387
  return props.fallback || "";
@@ -378,17 +407,13 @@ function ErrorBoundary(props) {
378
407
  const f = props.fallback;
379
408
  return typeof f === "function" && f.length ? f(error, () => {}) : f;
380
409
  }
381
- onError(err => {
382
- error = err;
383
- !sync && ctx.replace("e" + id, displayFallback);
384
- sync = true;
385
- });
386
- onCleanup(() => cleanNode(clean));
387
410
  createMemo(() => {
388
- Owner.context = {
389
- [BRANCH]: clean = {}
390
- };
391
- return res = props.children;
411
+ clean = Owner;
412
+ return catchError(() => res = props.children, err => {
413
+ error = err;
414
+ !sync && ctx.replace("e" + id, displayFallback);
415
+ sync = true;
416
+ });
392
417
  });
393
418
  if (error) return displayFallback();
394
419
  sync = false;
@@ -437,7 +462,7 @@ function createResource(source, fetcher, options = {}) {
437
462
  };
438
463
  read.loading = false;
439
464
  read.error = undefined;
440
- read.state = "initialValue" in options ? "resolved" : "unresolved";
465
+ read.state = "initialValue" in options ? "ready" : "unresolved";
441
466
  Object.defineProperty(read, "latest", {
442
467
  get() {
443
468
  return read();
@@ -470,7 +495,7 @@ function createResource(source, fetcher, options = {}) {
470
495
  if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
471
496
  return p.then(res => {
472
497
  read.loading = false;
473
- read.state = "resolved";
498
+ read.state = "ready";
474
499
  ctx.resources[id].data = res;
475
500
  p = null;
476
501
  notifySuspense(contexts);
@@ -560,15 +585,9 @@ function SuspenseList(props) {
560
585
  }
561
586
  function Suspense(props) {
562
587
  let done;
563
- let clean;
564
588
  const ctx = sharedConfig.context;
565
589
  const id = ctx.id + ctx.count;
566
- const o = Owner;
567
- if (o) {
568
- if (o.context) o.context[BRANCH] = clean = {};else o.context = {
569
- [BRANCH]: clean = {}
570
- };
571
- }
590
+ const o = createOwner();
572
591
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
573
592
  resources: new Map(),
574
593
  completed: () => {
@@ -578,51 +597,51 @@ function Suspense(props) {
578
597
  }
579
598
  }
580
599
  });
600
+ function suspenseError(err) {
601
+ if (!done || !done(undefined, err)) {
602
+ if (o) runWithOwner(o.owner, () => {
603
+ throw err;
604
+ });else throw err;
605
+ }
606
+ }
581
607
  function runSuspense() {
582
608
  setHydrateContext({
583
609
  ...ctx,
584
610
  count: 0
585
611
  });
586
- return runWithOwner(o, () => {
587
- return createComponent(SuspenseContext.Provider, {
588
- value,
589
- get children() {
590
- clean && cleanNode(clean);
591
- return props.children;
592
- }
593
- });
594
- });
612
+ o && cleanNode(o);
613
+ return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
614
+ value,
615
+ get children() {
616
+ return catchError(() => props.children, suspenseError);
617
+ }
618
+ }));
595
619
  }
596
620
  const res = runSuspense();
597
621
  if (suspenseComplete(value)) return res;
598
- onError(err => {
599
- if (!done || !done(undefined, err)) {
600
- if (o) runWithOwner(o.owner, () => {
601
- throw err;
602
- });else throw err;
603
- }
604
- });
605
622
  done = ctx.async ? ctx.registerFragment(id) : undefined;
606
- if (ctx.async) {
623
+ return catchError(() => {
624
+ if (ctx.async) {
625
+ setHydrateContext({
626
+ ...ctx,
627
+ count: 0,
628
+ id: ctx.id + "0-f",
629
+ noHydrate: true
630
+ });
631
+ const res = {
632
+ t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
633
+ };
634
+ setHydrateContext(ctx);
635
+ return res;
636
+ }
607
637
  setHydrateContext({
608
638
  ...ctx,
609
639
  count: 0,
610
- id: ctx.id + "0.f",
611
- noHydrate: true
640
+ id: ctx.id + "0-f"
612
641
  });
613
- const res = {
614
- t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
615
- };
616
- setHydrateContext(ctx);
617
- return res;
618
- }
619
- setHydrateContext({
620
- ...ctx,
621
- count: 0,
622
- id: ctx.id + "0.f"
623
- });
624
- ctx.writeResource(id, "$$f");
625
- return props.fallback;
642
+ ctx.writeResource(id, "$$f");
643
+ return props.fallback;
644
+ }, suspenseError);
626
645
  }
627
646
 
628
647
  export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -445,6 +445,20 @@ function onCleanup(fn) {
445
445
  if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
446
446
  return fn;
447
447
  }
448
+ function catchError(fn, handler) {
449
+ ERROR || (ERROR = Symbol("error"));
450
+ Owner = createComputation(undefined, undefined, true);
451
+ Owner.context = {
452
+ [ERROR]: [handler]
453
+ };
454
+ try {
455
+ return fn();
456
+ } catch (err) {
457
+ handleError(err);
458
+ } finally {
459
+ Owner = Owner.owner;
460
+ }
461
+ }
448
462
  function onError(fn) {
449
463
  ERROR || (ERROR = Symbol("error"));
450
464
  if (Owner === null) ;else if (Owner.context === null) Owner.context = {
@@ -652,7 +666,8 @@ function runComputation(node, value, time) {
652
666
  node.owned = null;
653
667
  }
654
668
  }
655
- handleError(err);
669
+ node.updatedAt = time + 1;
670
+ return handleError(err);
656
671
  }
657
672
  if (!node.updatedAt || node.updatedAt <= time) {
658
673
  if (node.updatedAt != null && "observers" in node) {
@@ -831,7 +846,7 @@ function lookUpstream(node, ignore) {
831
846
  const source = node.sources[i];
832
847
  if (source.sources) {
833
848
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
834
- if (source !== ignore) runTop(source);
849
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
835
850
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
836
851
  }
837
852
  }
@@ -867,16 +882,16 @@ function cleanNode(node) {
867
882
  }
868
883
  if (Transition && Transition.running && node.pure) {
869
884
  if (node.tOwned) {
870
- for (i = 0; i < node.tOwned.length; i++) cleanNode(node.tOwned[i]);
885
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
871
886
  delete node.tOwned;
872
887
  }
873
888
  reset(node, true);
874
889
  } else if (node.owned) {
875
- for (i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
890
+ for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
876
891
  node.owned = null;
877
892
  }
878
893
  if (node.cleanups) {
879
- for (i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
894
+ for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
880
895
  node.cleanups = null;
881
896
  }
882
897
  if (Transition && Transition.running) node.tState = 0;else node.state = 0;
@@ -1356,7 +1371,10 @@ function Show(props) {
1356
1371
  if (c) {
1357
1372
  const child = props.children;
1358
1373
  const fn = typeof child === "function" && child.length > 0;
1359
- return fn ? untrack(() => child(keyed ? c : () => props.when)) : child;
1374
+ return fn ? untrack(() => child(keyed ? c : () => {
1375
+ if (false && !untrack(condition)) ;
1376
+ return props.when;
1377
+ })) : child;
1360
1378
  }
1361
1379
  return props.fallback;
1362
1380
  }, undefined, undefined);
@@ -1384,7 +1402,10 @@ function Switch(props) {
1384
1402
  if (index < 0) return props.fallback;
1385
1403
  const c = cond.children;
1386
1404
  const fn = typeof c === "function" && c.length > 0;
1387
- return fn ? untrack(() => c(keyed ? when : () => cond.when)) : c;
1405
+ return fn ? untrack(() => c(keyed ? when : () => {
1406
+ if (false && untrack(evalConditions)[0] !== index) ;
1407
+ return cond.when;
1408
+ })) : c;
1388
1409
  }, undefined, undefined);
1389
1410
  }
1390
1411
  function Match(props) {
@@ -1406,12 +1427,9 @@ function ErrorBoundary(props) {
1406
1427
  let e;
1407
1428
  if (e = errored()) {
1408
1429
  const f = props.fallback;
1409
- const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1410
- onError(setErrored);
1411
- return res;
1430
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1412
1431
  }
1413
- onError(setErrored);
1414
- return props.children;
1432
+ return catchError(() => props.children, setErrored);
1415
1433
  }, undefined, undefined);
1416
1434
  }
1417
1435
 
@@ -1597,6 +1615,7 @@ exports.SuspenseList = SuspenseList;
1597
1615
  exports.Switch = Switch;
1598
1616
  exports.batch = batch;
1599
1617
  exports.cancelCallback = cancelCallback;
1618
+ exports.catchError = catchError;
1600
1619
  exports.children = children;
1601
1620
  exports.createComponent = createComponent;
1602
1621
  exports.createComputed = createComputed;
package/dist/solid.js CHANGED
@@ -443,6 +443,20 @@ function onCleanup(fn) {
443
443
  if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
444
444
  return fn;
445
445
  }
446
+ function catchError(fn, handler) {
447
+ ERROR || (ERROR = Symbol("error"));
448
+ Owner = createComputation(undefined, undefined, true);
449
+ Owner.context = {
450
+ [ERROR]: [handler]
451
+ };
452
+ try {
453
+ return fn();
454
+ } catch (err) {
455
+ handleError(err);
456
+ } finally {
457
+ Owner = Owner.owner;
458
+ }
459
+ }
446
460
  function onError(fn) {
447
461
  ERROR || (ERROR = Symbol("error"));
448
462
  if (Owner === null) ;else if (Owner.context === null) Owner.context = {
@@ -650,7 +664,8 @@ function runComputation(node, value, time) {
650
664
  node.owned = null;
651
665
  }
652
666
  }
653
- handleError(err);
667
+ node.updatedAt = time + 1;
668
+ return handleError(err);
654
669
  }
655
670
  if (!node.updatedAt || node.updatedAt <= time) {
656
671
  if (node.updatedAt != null && "observers" in node) {
@@ -829,7 +844,7 @@ function lookUpstream(node, ignore) {
829
844
  const source = node.sources[i];
830
845
  if (source.sources) {
831
846
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
832
- if (source !== ignore) runTop(source);
847
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
833
848
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
834
849
  }
835
850
  }
@@ -865,16 +880,16 @@ function cleanNode(node) {
865
880
  }
866
881
  if (Transition && Transition.running && node.pure) {
867
882
  if (node.tOwned) {
868
- for (i = 0; i < node.tOwned.length; i++) cleanNode(node.tOwned[i]);
883
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
869
884
  delete node.tOwned;
870
885
  }
871
886
  reset(node, true);
872
887
  } else if (node.owned) {
873
- for (i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
888
+ for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
874
889
  node.owned = null;
875
890
  }
876
891
  if (node.cleanups) {
877
- for (i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
892
+ for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
878
893
  node.cleanups = null;
879
894
  }
880
895
  if (Transition && Transition.running) node.tState = 0;else node.state = 0;
@@ -1354,7 +1369,10 @@ function Show(props) {
1354
1369
  if (c) {
1355
1370
  const child = props.children;
1356
1371
  const fn = typeof child === "function" && child.length > 0;
1357
- return fn ? untrack(() => child(keyed ? c : () => props.when)) : child;
1372
+ return fn ? untrack(() => child(keyed ? c : () => {
1373
+ if (false && !untrack(condition)) ;
1374
+ return props.when;
1375
+ })) : child;
1358
1376
  }
1359
1377
  return props.fallback;
1360
1378
  }, undefined, undefined);
@@ -1382,7 +1400,10 @@ function Switch(props) {
1382
1400
  if (index < 0) return props.fallback;
1383
1401
  const c = cond.children;
1384
1402
  const fn = typeof c === "function" && c.length > 0;
1385
- return fn ? untrack(() => c(keyed ? when : () => cond.when)) : c;
1403
+ return fn ? untrack(() => c(keyed ? when : () => {
1404
+ if (false && untrack(evalConditions)[0] !== index) ;
1405
+ return cond.when;
1406
+ })) : c;
1386
1407
  }, undefined, undefined);
1387
1408
  }
1388
1409
  function Match(props) {
@@ -1404,12 +1425,9 @@ function ErrorBoundary(props) {
1404
1425
  let e;
1405
1426
  if (e = errored()) {
1406
1427
  const f = props.fallback;
1407
- const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1408
- onError(setErrored);
1409
- return res;
1428
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1410
1429
  }
1411
- onError(setErrored);
1412
- return props.children;
1430
+ return catchError(() => props.children, setErrored);
1413
1431
  }, undefined, undefined);
1414
1432
  }
1415
1433
 
@@ -1581,4 +1599,4 @@ function Suspense(props) {
1581
1599
 
1582
1600
  let DEV;
1583
1601
 
1584
- export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1602
+ export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
@@ -1209,6 +1209,7 @@ export namespace JSX {
1209
1209
  mask?: FunctionMaybe<string>;
1210
1210
  opacity?: FunctionMaybe<number | string | "inherit">;
1211
1211
  overflow?: FunctionMaybe<"visible" | "hidden" | "scroll" | "auto" | "inherit">;
1212
+ pathLength?: FunctionMaybe<string | number>;
1212
1213
  "pointer-events"?: FunctionMaybe<
1213
1214
  | "bounding-box"
1214
1215
  | "visiblePainted"
@@ -1291,6 +1292,7 @@ export namespace JSX {
1291
1292
  gradientUnits?: FunctionMaybe<SVGUnits>;
1292
1293
  gradientTransform?: FunctionMaybe<string>;
1293
1294
  spreadMethod?: FunctionMaybe<"pad" | "reflect" | "repeat">;
1295
+ href?: FunctionMaybe<string>
1294
1296
  }
1295
1297
  interface GraphicsElementSVGAttributes<T>
1296
1298
  extends CoreSVGAttributes<T>,
@@ -1330,6 +1332,7 @@ export namespace JSX {
1330
1332
  | "stroke-dashoffset"
1331
1333
  | "stroke-opacity"
1332
1334
  | "shape-rendering"
1335
+ | "pathLength"
1333
1336
  > {}
1334
1337
  interface TextContentElementSVGAttributes<T>
1335
1338
  extends CoreSVGAttributes<T>,
@@ -210,7 +210,7 @@ function createHTML(r, {
210
210
  cache.set(statics, templates);
211
211
  return templates;
212
212
  }
213
- function parseKeyValue(tag, name, value, isSVG, isCE, options) {
213
+ function parseKeyValue(node, tag, name, value, isSVG, isCE, options) {
214
214
  let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
215
215
  parts,
216
216
  namespace;
@@ -228,15 +228,15 @@ function createHTML(r, {
228
228
  const prev = `_$v${uuid++}`;
229
229
  options.decl.push(`${prev}={}`);
230
230
  options.exprs.push(`r.classList(${tag},${expr},${prev})`);
231
- } else if (namespace !== "attr" && (isChildProp || !isSVG && (r.PropAliases[name] || isProp) || isCE || namespace === "prop")) {
231
+ } else if (namespace !== "attr" && (isChildProp || !isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp) || isCE || namespace === "prop")) {
232
232
  if (isCE && !isChildProp && !isProp && namespace !== "prop") name = toPropertyName(name);
233
- options.exprs.push(`${tag}.${r.PropAliases[name] || name} = ${expr}`);
233
+ options.exprs.push(`${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`);
234
234
  } else {
235
235
  const ns = isSVG && name.indexOf(":") > -1 && r.SVGNamespace[name.split(":")[0]];
236
236
  if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
237
237
  }
238
238
  }
239
- function parseAttribute(tag, name, value, isSVG, isCE, options) {
239
+ function parseAttribute(node, tag, name, value, isSVG, isCE, options) {
240
240
  if (name.slice(0, 2) === "on") {
241
241
  if (!name.includes(":")) {
242
242
  const lc = name.slice(2).toLowerCase();
@@ -254,7 +254,7 @@ function createHTML(r, {
254
254
  exprs: []
255
255
  }),
256
256
  count = options.counter;
257
- parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
257
+ parseKeyValue(node, tag, name, value, isSVG, isCE, childOptions);
258
258
  options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
259
259
  if (value === "###") {
260
260
  options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
@@ -300,7 +300,7 @@ function createHTML(r, {
300
300
  continue;
301
301
  }
302
302
  parseNode(child, childOptions);
303
- i++;
303
+ if (!childOptions.multi && child.type === "comment" && child.content === "#") node.children.splice(i, 1);else i++;
304
304
  }
305
305
  options.counter = childOptions.counter;
306
306
  options.templateId = childOptions.templateId;
@@ -390,8 +390,12 @@ function createHTML(r, {
390
390
  options.templateId = childOptions.templateId;
391
391
  } else if (child.type === "text") {
392
392
  parts.push(`"${child.content}"`);
393
- } else if (child.type === "comment" && child.content === "#") {
394
- parts.push(`exprs[${options.counter++}]`);
393
+ } else if (child.type === "comment") {
394
+ if (child.content === "#") parts.push(`exprs[${options.counter++}]`);else if (child.content) {
395
+ for (let i = 0; i < child.content.split("###").length - 1; i++) {
396
+ parts.push(`exprs[${options.counter++}]`);
397
+ }
398
+ }
395
399
  }
396
400
  });
397
401
  options.exprs.push(`return [${parts.join(", \n")}]`);
@@ -431,7 +435,7 @@ function createHTML(r, {
431
435
  value = node.attrs[name];
432
436
  if (value.includes("###")) {
433
437
  delete node.attrs[name];
434
- parseAttribute(tag, name, value, isSVG, isCE, options);
438
+ parseAttribute(node, tag, name, value, isSVG, isCE, options);
435
439
  }
436
440
  }
437
441
  }
@@ -509,7 +513,7 @@ var index = createHTML({
509
513
  setAttributeNS: web.setAttributeNS,
510
514
  addEventListener: web.addEventListener,
511
515
  Aliases: web.Aliases,
512
- PropAliases: web.PropAliases,
516
+ getPropAlias: web.getPropAlias,
513
517
  Properties: web.Properties,
514
518
  ChildProperties: web.ChildProperties,
515
519
  DelegatedEvents: web.DelegatedEvents,
package/html/dist/html.js CHANGED
@@ -1,4 +1,4 @@
1
- import { effect, style, insert, untrack, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
1
+ import { effect, style, insert, untrack, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, getPropAlias, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
2
2
 
3
3
  const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
4
4
  const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
@@ -208,7 +208,7 @@ function createHTML(r, {
208
208
  cache.set(statics, templates);
209
209
  return templates;
210
210
  }
211
- function parseKeyValue(tag, name, value, isSVG, isCE, options) {
211
+ function parseKeyValue(node, tag, name, value, isSVG, isCE, options) {
212
212
  let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
213
213
  parts,
214
214
  namespace;
@@ -226,15 +226,15 @@ function createHTML(r, {
226
226
  const prev = `_$v${uuid++}`;
227
227
  options.decl.push(`${prev}={}`);
228
228
  options.exprs.push(`r.classList(${tag},${expr},${prev})`);
229
- } else if (namespace !== "attr" && (isChildProp || !isSVG && (r.PropAliases[name] || isProp) || isCE || namespace === "prop")) {
229
+ } else if (namespace !== "attr" && (isChildProp || !isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp) || isCE || namespace === "prop")) {
230
230
  if (isCE && !isChildProp && !isProp && namespace !== "prop") name = toPropertyName(name);
231
- options.exprs.push(`${tag}.${r.PropAliases[name] || name} = ${expr}`);
231
+ options.exprs.push(`${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`);
232
232
  } else {
233
233
  const ns = isSVG && name.indexOf(":") > -1 && r.SVGNamespace[name.split(":")[0]];
234
234
  if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
235
235
  }
236
236
  }
237
- function parseAttribute(tag, name, value, isSVG, isCE, options) {
237
+ function parseAttribute(node, tag, name, value, isSVG, isCE, options) {
238
238
  if (name.slice(0, 2) === "on") {
239
239
  if (!name.includes(":")) {
240
240
  const lc = name.slice(2).toLowerCase();
@@ -252,7 +252,7 @@ function createHTML(r, {
252
252
  exprs: []
253
253
  }),
254
254
  count = options.counter;
255
- parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
255
+ parseKeyValue(node, tag, name, value, isSVG, isCE, childOptions);
256
256
  options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
257
257
  if (value === "###") {
258
258
  options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
@@ -298,7 +298,7 @@ function createHTML(r, {
298
298
  continue;
299
299
  }
300
300
  parseNode(child, childOptions);
301
- i++;
301
+ if (!childOptions.multi && child.type === "comment" && child.content === "#") node.children.splice(i, 1);else i++;
302
302
  }
303
303
  options.counter = childOptions.counter;
304
304
  options.templateId = childOptions.templateId;
@@ -388,8 +388,12 @@ function createHTML(r, {
388
388
  options.templateId = childOptions.templateId;
389
389
  } else if (child.type === "text") {
390
390
  parts.push(`"${child.content}"`);
391
- } else if (child.type === "comment" && child.content === "#") {
392
- parts.push(`exprs[${options.counter++}]`);
391
+ } else if (child.type === "comment") {
392
+ if (child.content === "#") parts.push(`exprs[${options.counter++}]`);else if (child.content) {
393
+ for (let i = 0; i < child.content.split("###").length - 1; i++) {
394
+ parts.push(`exprs[${options.counter++}]`);
395
+ }
396
+ }
393
397
  }
394
398
  });
395
399
  options.exprs.push(`return [${parts.join(", \n")}]`);
@@ -429,7 +433,7 @@ function createHTML(r, {
429
433
  value = node.attrs[name];
430
434
  if (value.includes("###")) {
431
435
  delete node.attrs[name];
432
- parseAttribute(tag, name, value, isSVG, isCE, options);
436
+ parseAttribute(node, tag, name, value, isSVG, isCE, options);
433
437
  }
434
438
  }
435
439
  }
@@ -507,7 +511,7 @@ var index = createHTML({
507
511
  setAttributeNS,
508
512
  addEventListener,
509
513
  Aliases,
510
- PropAliases,
514
+ getPropAlias,
511
515
  Properties,
512
516
  ChildProperties,
513
517
  DelegatedEvents,
@@ -22,7 +22,7 @@ interface Runtime {
22
22
  setAttribute(node: Element, name: string, value: any): void;
23
23
  setAttributeNS(node: Element, namespace: string, name: string, value: any): void;
24
24
  Aliases: Record<string, string>;
25
- PropAliases: Record<string, string>;
25
+ getPropAlias(prop: string, tagName: string): string | undefined;
26
26
  Properties: Set<string>;
27
27
  ChildProperties: Set<string>;
28
28
  DelegatedEvents: Set<string>;