solid-js 1.9.4 → 1.9.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016-2023 Ryan Carniato
3
+ Copyright (c) 2016-2025 Ryan Carniato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/dev.cjs CHANGED
@@ -144,6 +144,7 @@ function nextHydrateContext() {
144
144
  };
145
145
  }
146
146
 
147
+ const IS_DEV = true;
147
148
  const equalFn = (a, b) => a === b;
148
149
  const $PROXY = Symbol("solid-proxy");
149
150
  const SUPPORTS_PROXY = typeof Proxy === "function";
@@ -174,7 +175,8 @@ let ExecCount = 0;
174
175
  const DevHooks = {
175
176
  afterUpdate: null,
176
177
  afterCreateOwner: null,
177
- afterCreateSignal: null
178
+ afterCreateSignal: null,
179
+ afterRegisterGraph: null
178
180
  };
179
181
  function createRoot(fn, detachedOwner) {
180
182
  const listener = Listener,
@@ -215,8 +217,12 @@ function createSignal(value, options) {
215
217
  };
216
218
  {
217
219
  if (options.name) s.name = options.name;
218
- if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
219
- if (!options.internal) registerGraph(s);
220
+ if (options.internal) {
221
+ s.internal = true;
222
+ } else {
223
+ registerGraph(s);
224
+ if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
225
+ }
220
226
  }
221
227
  const setter = value => {
222
228
  if (typeof value === "function") {
@@ -578,9 +584,11 @@ function devComponent(Comp, props) {
578
584
  return c.tValue !== undefined ? c.tValue : c.value;
579
585
  }
580
586
  function registerGraph(value) {
581
- if (!Owner) return;
582
- if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
583
- value.graph = Owner;
587
+ if (Owner) {
588
+ if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
589
+ value.graph = Owner;
590
+ }
591
+ if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
584
592
  }
585
593
  function createContext(defaultValue, options) {
586
594
  const id = Symbol("context");
@@ -691,7 +699,7 @@ function writeSignal(node, value, isComp) {
691
699
  }
692
700
  if (Updates.length > 10e5) {
693
701
  Updates = [];
694
- if (true) throw new Error("Potential Infinite Loop Detected.");
702
+ if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
695
703
  throw new Error();
696
704
  }
697
705
  }, false);
@@ -1097,8 +1105,8 @@ function observable(input) {
1097
1105
  }
1098
1106
  };
1099
1107
  }
1100
- function from(producer) {
1101
- const [s, set] = createSignal(undefined, {
1108
+ function from(producer, initalValue = undefined) {
1109
+ const [s, set] = createSignal(initalValue, {
1102
1110
  equals: false
1103
1111
  });
1104
1112
  if ("subscribe" in producer) {
@@ -1462,7 +1470,7 @@ function lazy(fn) {
1462
1470
  }
1463
1471
  let Comp;
1464
1472
  return createMemo(() => (Comp = comp()) ? untrack(() => {
1465
- if (true) Object.assign(Comp, {
1473
+ if (IS_DEV) Object.assign(Comp, {
1466
1474
  [$DEVCOMP]: true
1467
1475
  });
1468
1476
  if (!ctx || sharedConfig.done) return Comp(props);
@@ -1501,8 +1509,11 @@ function Index(props) {
1501
1509
  }
1502
1510
  function Show(props) {
1503
1511
  const keyed = props.keyed;
1504
- const condition = createMemo(() => props.when, undefined, {
1505
- equals: (a, b) => keyed ? a === b : !a === !b,
1512
+ const conditionValue = createMemo(() => props.when, undefined, {
1513
+ name: "condition value"
1514
+ } );
1515
+ const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
1516
+ equals: (a, b) => !a === !b,
1506
1517
  name: "condition"
1507
1518
  } );
1508
1519
  return createMemo(() => {
@@ -1512,7 +1523,7 @@ function Show(props) {
1512
1523
  const fn = typeof child === "function" && child.length > 0;
1513
1524
  return fn ? untrack(() => child(keyed ? c : () => {
1514
1525
  if (!untrack(condition)) throw narrowedError("Show");
1515
- return props.when;
1526
+ return conditionValue();
1516
1527
  })) : child;
1517
1528
  }
1518
1529
  return props.fallback;
@@ -1521,35 +1532,38 @@ function Show(props) {
1521
1532
  } );
1522
1533
  }
1523
1534
  function Switch(props) {
1524
- let keyed = false;
1525
- const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1526
- const conditions = children(() => props.children),
1527
- evalConditions = createMemo(() => {
1528
- let conds = conditions();
1529
- if (!Array.isArray(conds)) conds = [conds];
1530
- for (let i = 0; i < conds.length; i++) {
1531
- const c = conds[i].when;
1532
- if (c) {
1533
- keyed = !!conds[i].keyed;
1534
- return [i, c, conds[i]];
1535
- }
1536
- }
1537
- return [-1];
1538
- }, undefined, {
1539
- equals,
1540
- name: "eval conditions"
1541
- } );
1535
+ const chs = children(() => props.children);
1536
+ const switchFunc = createMemo(() => {
1537
+ const ch = chs();
1538
+ const mps = Array.isArray(ch) ? ch : [ch];
1539
+ let func = () => undefined;
1540
+ for (let i = 0; i < mps.length; i++) {
1541
+ const index = i;
1542
+ const mp = mps[i];
1543
+ const prevFunc = func;
1544
+ const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
1545
+ name: "condition value"
1546
+ } );
1547
+ const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
1548
+ equals: (a, b) => !a === !b,
1549
+ name: "condition"
1550
+ } );
1551
+ func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
1552
+ }
1553
+ return func;
1554
+ });
1542
1555
  return createMemo(() => {
1543
- const [index, when, cond] = evalConditions();
1544
- if (index < 0) return props.fallback;
1545
- const c = cond.children;
1546
- const fn = typeof c === "function" && c.length > 0;
1547
- return fn ? untrack(() => c(keyed ? when : () => {
1548
- if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1549
- return cond.when;
1550
- })) : c;
1556
+ const sel = switchFunc()();
1557
+ if (!sel) return props.fallback;
1558
+ const [index, conditionValue, mp] = sel;
1559
+ const child = mp.children;
1560
+ const fn = typeof child === "function" && child.length > 0;
1561
+ return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
1562
+ if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
1563
+ return conditionValue();
1564
+ })) : child;
1551
1565
  }, undefined, {
1552
- name: "value"
1566
+ name: "eval conditions"
1553
1567
  } );
1554
1568
  }
1555
1569
  function Match(props) {
package/dist/dev.js CHANGED
@@ -144,6 +144,7 @@ function nextHydrateContext() {
144
144
  };
145
145
  }
146
146
 
147
+ const IS_DEV = true;
147
148
  const equalFn = (a, b) => a === b;
148
149
  const $PROXY = Symbol("solid-proxy");
149
150
  const SUPPORTS_PROXY = typeof Proxy === "function";
@@ -174,7 +175,8 @@ let ExecCount = 0;
174
175
  const DevHooks = {
175
176
  afterUpdate: null,
176
177
  afterCreateOwner: null,
177
- afterCreateSignal: null
178
+ afterCreateSignal: null,
179
+ afterRegisterGraph: null
178
180
  };
179
181
  function createRoot(fn, detachedOwner) {
180
182
  const listener = Listener,
@@ -220,8 +222,12 @@ function createSignal(value, options) {
220
222
  };
221
223
  {
222
224
  if (options.name) s.name = options.name;
223
- if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
224
- if (!options.internal) registerGraph(s);
225
+ if (options.internal) {
226
+ s.internal = true;
227
+ } else {
228
+ registerGraph(s);
229
+ if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
230
+ }
225
231
  }
226
232
  const setter = value => {
227
233
  if (typeof value === "function") {
@@ -648,10 +654,12 @@ function devComponent(Comp, props) {
648
654
  return c.tValue !== undefined ? c.tValue : c.value;
649
655
  }
650
656
  function registerGraph(value) {
651
- if (!Owner) return;
652
- if (Owner.sourceMap) Owner.sourceMap.push(value);
653
- else Owner.sourceMap = [value];
654
- value.graph = Owner;
657
+ if (Owner) {
658
+ if (Owner.sourceMap) Owner.sourceMap.push(value);
659
+ else Owner.sourceMap = [value];
660
+ value.graph = Owner;
661
+ }
662
+ if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
655
663
  }
656
664
  function createContext(defaultValue, options) {
657
665
  const id = Symbol("context");
@@ -765,7 +773,7 @@ function writeSignal(node, value, isComp) {
765
773
  }
766
774
  if (Updates.length > 10e5) {
767
775
  Updates = [];
768
- if (true) throw new Error("Potential Infinite Loop Detected.");
776
+ if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
769
777
  throw new Error();
770
778
  }
771
779
  }, false);
@@ -1198,8 +1206,8 @@ function observable(input) {
1198
1206
  }
1199
1207
  };
1200
1208
  }
1201
- function from(producer) {
1202
- const [s, set] = createSignal(undefined, {
1209
+ function from(producer, initalValue = undefined) {
1210
+ const [s, set] = createSignal(initalValue, {
1203
1211
  equals: false
1204
1212
  });
1205
1213
  if ("subscribe" in producer) {
@@ -1595,7 +1603,7 @@ function lazy(fn) {
1595
1603
  return createMemo(() =>
1596
1604
  (Comp = comp())
1597
1605
  ? untrack(() => {
1598
- if (true)
1606
+ if (IS_DEV)
1599
1607
  Object.assign(Comp, {
1600
1608
  [$DEVCOMP]: true
1601
1609
  });
@@ -1646,10 +1654,15 @@ function Index(props) {
1646
1654
  }
1647
1655
  function Show(props) {
1648
1656
  const keyed = props.keyed;
1649
- const condition = createMemo(() => props.when, undefined, {
1650
- equals: (a, b) => (keyed ? a === b : !a === !b),
1651
- name: "condition"
1657
+ const conditionValue = createMemo(() => props.when, undefined, {
1658
+ name: "condition value"
1652
1659
  });
1660
+ const condition = keyed
1661
+ ? conditionValue
1662
+ : createMemo(conditionValue, undefined, {
1663
+ equals: (a, b) => !a === !b,
1664
+ name: "condition"
1665
+ });
1653
1666
  return createMemo(
1654
1667
  () => {
1655
1668
  const c = condition();
@@ -1663,7 +1676,7 @@ function Show(props) {
1663
1676
  ? c
1664
1677
  : () => {
1665
1678
  if (!untrack(condition)) throw narrowedError("Show");
1666
- return props.when;
1679
+ return conditionValue();
1667
1680
  }
1668
1681
  )
1669
1682
  )
@@ -1678,50 +1691,51 @@ function Show(props) {
1678
1691
  );
1679
1692
  }
1680
1693
  function Switch(props) {
1681
- let keyed = false;
1682
- const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1683
- const conditions = children(() => props.children),
1684
- evalConditions = createMemo(
1685
- () => {
1686
- let conds = conditions();
1687
- if (!Array.isArray(conds)) conds = [conds];
1688
- for (let i = 0; i < conds.length; i++) {
1689
- const c = conds[i].when;
1690
- if (c) {
1691
- keyed = !!conds[i].keyed;
1692
- return [i, c, conds[i]];
1693
- }
1694
- }
1695
- return [-1];
1696
- },
1697
- undefined,
1698
- {
1699
- equals,
1700
- name: "eval conditions"
1701
- }
1702
- );
1694
+ const chs = children(() => props.children);
1695
+ const switchFunc = createMemo(() => {
1696
+ const ch = chs();
1697
+ const mps = Array.isArray(ch) ? ch : [ch];
1698
+ let func = () => undefined;
1699
+ for (let i = 0; i < mps.length; i++) {
1700
+ const index = i;
1701
+ const mp = mps[i];
1702
+ const prevFunc = func;
1703
+ const conditionValue = createMemo(() => (prevFunc() ? undefined : mp.when), undefined, {
1704
+ name: "condition value"
1705
+ });
1706
+ const condition = mp.keyed
1707
+ ? conditionValue
1708
+ : createMemo(conditionValue, undefined, {
1709
+ equals: (a, b) => !a === !b,
1710
+ name: "condition"
1711
+ });
1712
+ func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
1713
+ }
1714
+ return func;
1715
+ });
1703
1716
  return createMemo(
1704
1717
  () => {
1705
- const [index, when, cond] = evalConditions();
1706
- if (index < 0) return props.fallback;
1707
- const c = cond.children;
1708
- const fn = typeof c === "function" && c.length > 0;
1718
+ const sel = switchFunc()();
1719
+ if (!sel) return props.fallback;
1720
+ const [index, conditionValue, mp] = sel;
1721
+ const child = mp.children;
1722
+ const fn = typeof child === "function" && child.length > 0;
1709
1723
  return fn
1710
1724
  ? untrack(() =>
1711
- c(
1712
- keyed
1713
- ? when
1725
+ child(
1726
+ mp.keyed
1727
+ ? conditionValue()
1714
1728
  : () => {
1715
- if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1716
- return cond.when;
1729
+ if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
1730
+ return conditionValue();
1717
1731
  }
1718
1732
  )
1719
1733
  )
1720
- : c;
1734
+ : child;
1721
1735
  },
1722
1736
  undefined,
1723
1737
  {
1724
- name: "value"
1738
+ name: "eval conditions"
1725
1739
  }
1726
1740
  );
1727
1741
  }
package/dist/solid.cjs CHANGED
@@ -144,6 +144,7 @@ function nextHydrateContext() {
144
144
  };
145
145
  }
146
146
 
147
+ const IS_DEV = false;
147
148
  const equalFn = (a, b) => a === b;
148
149
  const $PROXY = Symbol("solid-proxy");
149
150
  const SUPPORTS_PROXY = typeof Proxy === "function";
@@ -651,7 +652,7 @@ function writeSignal(node, value, isComp) {
651
652
  }
652
653
  if (Updates.length > 10e5) {
653
654
  Updates = [];
654
- if (false) ;
655
+ if (IS_DEV) ;
655
656
  throw new Error();
656
657
  }
657
658
  }, false);
@@ -1054,8 +1055,8 @@ function observable(input) {
1054
1055
  }
1055
1056
  };
1056
1057
  }
1057
- function from(producer) {
1058
- const [s, set] = createSignal(undefined, {
1058
+ function from(producer, initalValue = undefined) {
1059
+ const [s, set] = createSignal(initalValue, {
1059
1060
  equals: false
1060
1061
  });
1061
1062
  if ("subscribe" in producer) {
@@ -1415,7 +1416,7 @@ function lazy(fn) {
1415
1416
  }
1416
1417
  let Comp;
1417
1418
  return createMemo(() => (Comp = comp()) ? untrack(() => {
1418
- if (false) ;
1419
+ if (IS_DEV) ;
1419
1420
  if (!ctx || sharedConfig.done) return Comp(props);
1420
1421
  const c = sharedConfig.context;
1421
1422
  setHydrateContext(ctx);
@@ -1448,8 +1449,9 @@ function Index(props) {
1448
1449
  }
1449
1450
  function Show(props) {
1450
1451
  const keyed = props.keyed;
1451
- const condition = createMemo(() => props.when, undefined, {
1452
- equals: (a, b) => keyed ? a === b : !a === !b
1452
+ const conditionValue = createMemo(() => props.when, undefined, undefined);
1453
+ const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
1454
+ equals: (a, b) => !a === !b
1453
1455
  });
1454
1456
  return createMemo(() => {
1455
1457
  const c = condition();
@@ -1458,39 +1460,40 @@ function Show(props) {
1458
1460
  const fn = typeof child === "function" && child.length > 0;
1459
1461
  return fn ? untrack(() => child(keyed ? c : () => {
1460
1462
  if (!untrack(condition)) throw narrowedError("Show");
1461
- return props.when;
1463
+ return conditionValue();
1462
1464
  })) : child;
1463
1465
  }
1464
1466
  return props.fallback;
1465
1467
  }, undefined, undefined);
1466
1468
  }
1467
1469
  function Switch(props) {
1468
- let keyed = false;
1469
- const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1470
- const conditions = children(() => props.children),
1471
- evalConditions = createMemo(() => {
1472
- let conds = conditions();
1473
- if (!Array.isArray(conds)) conds = [conds];
1474
- for (let i = 0; i < conds.length; i++) {
1475
- const c = conds[i].when;
1476
- if (c) {
1477
- keyed = !!conds[i].keyed;
1478
- return [i, c, conds[i]];
1479
- }
1480
- }
1481
- return [-1];
1482
- }, undefined, {
1483
- equals
1484
- });
1470
+ const chs = children(() => props.children);
1471
+ const switchFunc = createMemo(() => {
1472
+ const ch = chs();
1473
+ const mps = Array.isArray(ch) ? ch : [ch];
1474
+ let func = () => undefined;
1475
+ for (let i = 0; i < mps.length; i++) {
1476
+ const index = i;
1477
+ const mp = mps[i];
1478
+ const prevFunc = func;
1479
+ const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
1480
+ const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
1481
+ equals: (a, b) => !a === !b
1482
+ });
1483
+ func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
1484
+ }
1485
+ return func;
1486
+ });
1485
1487
  return createMemo(() => {
1486
- const [index, when, cond] = evalConditions();
1487
- if (index < 0) return props.fallback;
1488
- const c = cond.children;
1489
- const fn = typeof c === "function" && c.length > 0;
1490
- return fn ? untrack(() => c(keyed ? when : () => {
1491
- if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1492
- return cond.when;
1493
- })) : c;
1488
+ const sel = switchFunc()();
1489
+ if (!sel) return props.fallback;
1490
+ const [index, conditionValue, mp] = sel;
1491
+ const child = mp.children;
1492
+ const fn = typeof child === "function" && child.length > 0;
1493
+ return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
1494
+ if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
1495
+ return conditionValue();
1496
+ })) : child;
1494
1497
  }, undefined, undefined);
1495
1498
  }
1496
1499
  function Match(props) {
package/dist/solid.js CHANGED
@@ -144,6 +144,7 @@ function nextHydrateContext() {
144
144
  };
145
145
  }
146
146
 
147
+ const IS_DEV = false;
147
148
  const equalFn = (a, b) => a === b;
148
149
  const $PROXY = Symbol("solid-proxy");
149
150
  const SUPPORTS_PROXY = typeof Proxy === "function";
@@ -712,7 +713,7 @@ function writeSignal(node, value, isComp) {
712
713
  }
713
714
  if (Updates.length > 10e5) {
714
715
  Updates = [];
715
- if (false);
716
+ if (IS_DEV);
716
717
  throw new Error();
717
718
  }
718
719
  }, false);
@@ -1138,8 +1139,8 @@ function observable(input) {
1138
1139
  }
1139
1140
  };
1140
1141
  }
1141
- function from(producer) {
1142
- const [s, set] = createSignal(undefined, {
1142
+ function from(producer, initalValue = undefined) {
1143
+ const [s, set] = createSignal(initalValue, {
1143
1144
  equals: false
1144
1145
  });
1145
1146
  if ("subscribe" in producer) {
@@ -1531,7 +1532,7 @@ function lazy(fn) {
1531
1532
  return createMemo(() =>
1532
1533
  (Comp = comp())
1533
1534
  ? untrack(() => {
1534
- if (false);
1535
+ if (IS_DEV);
1535
1536
  if (!ctx || sharedConfig.done) return Comp(props);
1536
1537
  const c = sharedConfig.context;
1537
1538
  setHydrateContext(ctx);
@@ -1566,9 +1567,12 @@ function Index(props) {
1566
1567
  }
1567
1568
  function Show(props) {
1568
1569
  const keyed = props.keyed;
1569
- const condition = createMemo(() => props.when, undefined, {
1570
- equals: (a, b) => (keyed ? a === b : !a === !b)
1571
- });
1570
+ const conditionValue = createMemo(() => props.when, undefined, undefined);
1571
+ const condition = keyed
1572
+ ? conditionValue
1573
+ : createMemo(conditionValue, undefined, {
1574
+ equals: (a, b) => !a === !b
1575
+ });
1572
1576
  return createMemo(
1573
1577
  () => {
1574
1578
  const c = condition();
@@ -1582,7 +1586,7 @@ function Show(props) {
1582
1586
  ? c
1583
1587
  : () => {
1584
1588
  if (!untrack(condition)) throw narrowedError("Show");
1585
- return props.when;
1589
+ return conditionValue();
1586
1590
  }
1587
1591
  )
1588
1592
  )
@@ -1595,45 +1599,48 @@ function Show(props) {
1595
1599
  );
1596
1600
  }
1597
1601
  function Switch(props) {
1598
- let keyed = false;
1599
- const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
1600
- const conditions = children(() => props.children),
1601
- evalConditions = createMemo(
1602
- () => {
1603
- let conds = conditions();
1604
- if (!Array.isArray(conds)) conds = [conds];
1605
- for (let i = 0; i < conds.length; i++) {
1606
- const c = conds[i].when;
1607
- if (c) {
1608
- keyed = !!conds[i].keyed;
1609
- return [i, c, conds[i]];
1610
- }
1611
- }
1612
- return [-1];
1613
- },
1614
- undefined,
1615
- {
1616
- equals
1617
- }
1618
- );
1602
+ const chs = children(() => props.children);
1603
+ const switchFunc = createMemo(() => {
1604
+ const ch = chs();
1605
+ const mps = Array.isArray(ch) ? ch : [ch];
1606
+ let func = () => undefined;
1607
+ for (let i = 0; i < mps.length; i++) {
1608
+ const index = i;
1609
+ const mp = mps[i];
1610
+ const prevFunc = func;
1611
+ const conditionValue = createMemo(
1612
+ () => (prevFunc() ? undefined : mp.when),
1613
+ undefined,
1614
+ undefined
1615
+ );
1616
+ const condition = mp.keyed
1617
+ ? conditionValue
1618
+ : createMemo(conditionValue, undefined, {
1619
+ equals: (a, b) => !a === !b
1620
+ });
1621
+ func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
1622
+ }
1623
+ return func;
1624
+ });
1619
1625
  return createMemo(
1620
1626
  () => {
1621
- const [index, when, cond] = evalConditions();
1622
- if (index < 0) return props.fallback;
1623
- const c = cond.children;
1624
- const fn = typeof c === "function" && c.length > 0;
1627
+ const sel = switchFunc()();
1628
+ if (!sel) return props.fallback;
1629
+ const [index, conditionValue, mp] = sel;
1630
+ const child = mp.children;
1631
+ const fn = typeof child === "function" && child.length > 0;
1625
1632
  return fn
1626
1633
  ? untrack(() =>
1627
- c(
1628
- keyed
1629
- ? when
1634
+ child(
1635
+ mp.keyed
1636
+ ? conditionValue()
1630
1637
  : () => {
1631
- if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1632
- return cond.when;
1638
+ if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
1639
+ return conditionValue();
1633
1640
  }
1634
1641
  )
1635
1642
  )
1636
- : c;
1643
+ : child;
1637
1644
  },
1638
1645
  undefined,
1639
1646
  undefined
@@ -868,7 +868,7 @@ export namespace JSX {
868
868
  ping?: FunctionMaybe<string>;
869
869
  referrerpolicy?: FunctionMaybe<HTMLReferrerPolicy>;
870
870
  rel?: FunctionMaybe<string>;
871
- target?: FunctionMaybe<string>;
871
+ target?: FunctionMaybe<"_self" | "_blank" | "_parent" | "_top" | (string & {})>;
872
872
  type?: FunctionMaybe<string>;
873
873
  referrerPolicy?: FunctionMaybe<HTMLReferrerPolicy>;
874
874
  }
@@ -1022,7 +1022,31 @@ export namespace JSX {
1022
1022
  size?: FunctionMaybe<number | string>;
1023
1023
  src?: FunctionMaybe<string>;
1024
1024
  step?: FunctionMaybe<number | string>;
1025
- type?: FunctionMaybe<string>;
1025
+ type?: FunctionMaybe<
1026
+ | "button"
1027
+ | "checkbox"
1028
+ | "color"
1029
+ | "date"
1030
+ | "datetime-local"
1031
+ | "email"
1032
+ | "file"
1033
+ | "hidden"
1034
+ | "image"
1035
+ | "month"
1036
+ | "number"
1037
+ | "password"
1038
+ | "radio"
1039
+ | "range"
1040
+ | "reset"
1041
+ | "search"
1042
+ | "submit"
1043
+ | "tel"
1044
+ | "text"
1045
+ | "time"
1046
+ | "url"
1047
+ | "week"
1048
+ | (string & {})
1049
+ >;
1026
1050
  value?: FunctionMaybe<string | string[] | number>;
1027
1051
  width?: FunctionMaybe<number | string>;
1028
1052
  crossOrigin?: FunctionMaybe<HTMLCrossorigin>;
@@ -1079,6 +1103,9 @@ export namespace JSX {
1079
1103
  interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
1080
1104
  autoplay?: FunctionMaybe<boolean>;
1081
1105
  controls?: FunctionMaybe<boolean>;
1106
+ controlslist?: FunctionMaybe<
1107
+ "nodownload" | "nofullscreen" | "noplaybackrate" | "noremoteplayback" | (string & {})
1108
+ >;
1082
1109
  crossorigin?: FunctionMaybe<HTMLCrossorigin>;
1083
1110
  loop?: FunctionMaybe<boolean>;
1084
1111
  mediagroup?: FunctionMaybe<string>;
@@ -1248,6 +1275,7 @@ export namespace JSX {
1248
1275
  poster?: FunctionMaybe<string>;
1249
1276
  width?: FunctionMaybe<number | string>;
1250
1277
  disablepictureinpicture?: FunctionMaybe<boolean>;
1278
+ disableremoteplayback?: FunctionMaybe<boolean>;
1251
1279
  }
1252
1280
  type SVGPreserveAspectRatio =
1253
1281
  | "none"
@@ -64,7 +64,7 @@ function parseTag(tag) {
64
64
  }
65
65
  function pushTextNode(list, html, start) {
66
66
  const end = html.indexOf('<', start);
67
- const content = html.slice(start, end === -1 ? void 0 : end);
67
+ const content = html.slice(start, end === -1 ? undefined : end);
68
68
  if (!/^\s*$/.test(content)) {
69
69
  list.push({
70
70
  type: 'text',
@@ -83,7 +83,7 @@ function pushCommentNode(list, tag) {
83
83
  }
84
84
  function parse(html) {
85
85
  const result = [];
86
- let current = void 0;
86
+ let current = undefined;
87
87
  let level = -1;
88
88
  const arr = [];
89
89
  const byTag = {};
@@ -92,7 +92,7 @@ function parse(html) {
92
92
  const isComment = tag.slice(0, 4) === '<!--';
93
93
  const start = index + tag.length;
94
94
  const nextChar = html.charAt(start);
95
- let parent = void 0;
95
+ let parent = undefined;
96
96
  if (isOpen && !isComment) {
97
97
  level++;
98
98
  current = parseTag(tag);
package/html/dist/html.js CHANGED
@@ -84,7 +84,7 @@ function parseTag(tag) {
84
84
  }
85
85
  function pushTextNode(list, html, start) {
86
86
  const end = html.indexOf("<", start);
87
- const content = html.slice(start, end === -1 ? void 0 : end);
87
+ const content = html.slice(start, end === -1 ? undefined : end);
88
88
  if (!/^\s*$/.test(content)) {
89
89
  list.push({
90
90
  type: "text",
@@ -103,7 +103,7 @@ function pushCommentNode(list, tag) {
103
103
  }
104
104
  function parse(html) {
105
105
  const result = [];
106
- let current = void 0;
106
+ let current = undefined;
107
107
  let level = -1;
108
108
  const arr = [];
109
109
  const byTag = {};
@@ -112,7 +112,7 @@ function parse(html) {
112
112
  const isComment = tag.slice(0, 4) === "<!--";
113
113
  const start = index + tag.length;
114
114
  const nextChar = html.charAt(start);
115
- let parent = void 0;
115
+ let parent = undefined;
116
116
  if (isOpen && !isComment) {
117
117
  level++;
118
118
  current = parseTag(tag);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.9.4",
4
+ "version": "1.9.5",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -1,3 +1,4 @@
1
+ export declare const IS_DEV: string | boolean;
1
2
  export declare const $RAW: unique symbol,
2
3
  $NODE: unique symbol,
3
4
  $HAS: unique symbol,
package/types/index.d.ts CHANGED
@@ -77,6 +77,9 @@ export declare const DEV:
77
77
  afterCreateSignal:
78
78
  | ((signal: import("./reactive/signal.js").SignalState<any>) => void)
79
79
  | null;
80
+ afterRegisterGraph:
81
+ | ((sourceMapValue: import("./reactive/signal.js").SourceMapValue) => void)
82
+ | null;
80
83
  };
81
84
  readonly writeSignal: typeof writeSignal;
82
85
  readonly registerGraph: typeof registerGraph;
package/types/jsx.d.ts CHANGED
@@ -963,7 +963,7 @@ export namespace JSX {
963
963
  ping?: string | undefined;
964
964
  referrerpolicy?: HTMLReferrerPolicy | undefined;
965
965
  rel?: string | undefined;
966
- target?: string | undefined;
966
+ target?: "_self" | "_blank" | "_parent" | "_top" | (string & {}) | undefined;
967
967
  type?: string | undefined;
968
968
  referrerPolicy?: HTMLReferrerPolicy | undefined;
969
969
  }
@@ -1125,7 +1125,31 @@ export namespace JSX {
1125
1125
  size?: number | string | undefined;
1126
1126
  src?: string | undefined;
1127
1127
  step?: number | string | undefined;
1128
- type?: string | undefined;
1128
+ type?:
1129
+ | "button"
1130
+ | "checkbox"
1131
+ | "color"
1132
+ | "date"
1133
+ | "datetime-local"
1134
+ | "email"
1135
+ | "file"
1136
+ | "hidden"
1137
+ | "image"
1138
+ | "month"
1139
+ | "number"
1140
+ | "password"
1141
+ | "radio"
1142
+ | "range"
1143
+ | "reset"
1144
+ | "search"
1145
+ | "submit"
1146
+ | "tel"
1147
+ | "text"
1148
+ | "time"
1149
+ | "url"
1150
+ | "week"
1151
+ | (string & {})
1152
+ | undefined;
1129
1153
  value?: string | string[] | number | undefined;
1130
1154
  width?: number | string | undefined;
1131
1155
  crossOrigin?: HTMLCrossorigin | undefined;
@@ -1182,6 +1206,13 @@ export namespace JSX {
1182
1206
  interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
1183
1207
  autoplay?: boolean | undefined;
1184
1208
  controls?: boolean | undefined;
1209
+ controlslist?:
1210
+ | "nodownload"
1211
+ | "nofullscreen"
1212
+ | "noplaybackrate"
1213
+ | "noremoteplayback"
1214
+ | (string & {})
1215
+ | undefined;
1185
1216
  crossorigin?: HTMLCrossorigin | undefined;
1186
1217
  loop?: boolean | undefined;
1187
1218
  mediagroup?: string | undefined;
@@ -1352,6 +1383,7 @@ export namespace JSX {
1352
1383
  poster?: string | undefined;
1353
1384
  width?: number | string | undefined;
1354
1385
  disablepictureinpicture?: boolean;
1386
+ disableremoteplayback?: boolean;
1355
1387
  }
1356
1388
  type SVGPreserveAspectRatio =
1357
1389
  | "none"
@@ -28,15 +28,15 @@ export type ObservableObserver<T> =
28
28
  * description https://docs.solidjs.com/reference/reactive-utilities/observable
29
29
  */
30
30
  export declare function observable<T>(input: Accessor<T>): Observable<T>;
31
- export declare function from<T>(
32
- producer:
33
- | ((setter: Setter<T | undefined>) => () => void)
34
- | {
35
- subscribe: (fn: (v: T) => void) =>
36
- | (() => void)
37
- | {
38
- unsubscribe: () => void;
39
- };
40
- }
41
- ): Accessor<T | undefined>;
31
+ type Producer<T> =
32
+ | ((setter: Setter<T>) => () => void)
33
+ | {
34
+ subscribe: (fn: (v: T) => void) =>
35
+ | (() => void)
36
+ | {
37
+ unsubscribe: () => void;
38
+ };
39
+ };
40
+ export declare function from<T>(producer: Producer<T>, initalValue: T): Accessor<T>;
41
+ export declare function from<T>(producer: Producer<T | undefined>): Accessor<T | undefined>;
42
42
  export {};
@@ -24,6 +24,7 @@ SOFTWARE.
24
24
  import { requestCallback } from "./scheduler.js";
25
25
  import type { JSX } from "../jsx.js";
26
26
  import type { FlowComponent } from "../render/index.js";
27
+ export declare const IS_DEV: string | boolean;
27
28
  export declare const equalFn: <T>(a: T, b: T) => boolean;
28
29
  export declare const $PROXY: unique symbol;
29
30
  export declare const SUPPORTS_PROXY: boolean;
@@ -35,7 +36,9 @@ export declare let Transition: TransitionState | null;
35
36
  export declare const DevHooks: {
36
37
  afterUpdate: (() => void) | null;
37
38
  afterCreateOwner: ((owner: Owner) => void) | null;
39
+ /** @deprecated use `afterRegisterGraph` */
38
40
  afterCreateSignal: ((signal: SignalState<any>) => void) | null;
41
+ afterRegisterGraph: ((sourceMapValue: SourceMapValue) => void) | null;
39
42
  };
40
43
  export type ComputationState = 0 | 1 | 2;
41
44
  export interface SourceMapValue {
@@ -49,6 +52,7 @@ export interface SignalState<T> extends SourceMapValue {
49
52
  observerSlots: number[] | null;
50
53
  tValue?: T;
51
54
  comparator?: (prev: T, next: T) => boolean;
55
+ internal?: true;
52
56
  }
53
57
  export interface Owner {
54
58
  owned: Computation<any>[] | null;
@@ -103,7 +103,12 @@ export declare function observable<T>(input: Accessor<T>): {
103
103
  subscribe(observer: ObservableObserver<T>): {
104
104
  unsubscribe(): void;
105
105
  };
106
- [Symbol.observable](): any;
106
+ [Symbol.observable](): {
107
+ subscribe(observer: ObservableObserver<T>): {
108
+ unsubscribe(): void;
109
+ };
110
+ [Symbol.observable](): /*elided*/ any;
111
+ };
107
112
  };
108
113
  export declare function from<T>(
109
114
  producer:
package/web/dist/dev.cjs CHANGED
@@ -122,13 +122,13 @@ function render(code, element, init, options = {}) {
122
122
  element.textContent = "";
123
123
  };
124
124
  }
125
- function template(html, isImportNode, isSVG) {
125
+ function template(html, isImportNode, isSVG, isMathML) {
126
126
  let node;
127
127
  const create = () => {
128
128
  if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
129
- const t = document.createElement("template");
129
+ const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
130
130
  t.innerHTML = html;
131
- return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
131
+ return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
132
132
  };
133
133
  const fn = isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
134
134
  fn.cloneNode = fn;
@@ -385,7 +385,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
385
385
  setAttribute(node, prop.slice(5), value);
386
386
  } else if (prop.slice(0, 5) === "bool:") {
387
387
  setBoolAttribute(node, prop.slice(5), value);
388
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || 'is' in props)) {
388
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || "is" in props)) {
389
389
  if (forceProp) {
390
390
  prop = prop.slice(5);
391
391
  isProp = true;
@@ -669,9 +669,8 @@ function Portal(props) {
669
669
  });
670
670
  return marker;
671
671
  }
672
- function Dynamic(props) {
673
- const [p, others] = solidJs.splitProps(props, ["component"]);
674
- const cached = solidJs.createMemo(() => p.component);
672
+ function createDynamic(component, props) {
673
+ const cached = solidJs.createMemo(component);
675
674
  return solidJs.createMemo(() => {
676
675
  const component = cached();
677
676
  switch (typeof component) {
@@ -679,15 +678,19 @@ function Dynamic(props) {
679
678
  Object.assign(component, {
680
679
  [solidJs.$DEVCOMP]: true
681
680
  });
682
- return solidJs.untrack(() => component(others));
681
+ return solidJs.untrack(() => component(props));
683
682
  case "string":
684
683
  const isSvg = SVGElements.has(component);
685
684
  const el = solidJs.sharedConfig.context ? getNextElement() : createElement(component, isSvg);
686
- spread(el, others, isSvg);
685
+ spread(el, props, isSvg);
687
686
  return el;
688
687
  }
689
688
  });
690
689
  }
690
+ function Dynamic(props) {
691
+ const [, others] = solidJs.splitProps(props, ["component"]);
692
+ return createDynamic(() => props.component, others);
693
+ }
691
694
 
692
695
  Object.defineProperty(exports, "ErrorBoundary", {
693
696
  enumerable: true,
@@ -764,6 +767,7 @@ exports.assign = assign;
764
767
  exports.classList = classList;
765
768
  exports.className = className;
766
769
  exports.clearDelegatedEvents = clearDelegatedEvents;
770
+ exports.createDynamic = createDynamic;
767
771
  exports.delegateEvents = delegateEvents;
768
772
  exports.dynamicProperty = dynamicProperty;
769
773
  exports.escape = escape;
package/web/dist/dev.js CHANGED
@@ -10,8 +10,8 @@ import {
10
10
  createMemo,
11
11
  createSignal,
12
12
  onCleanup,
13
- splitProps,
14
- $DEVCOMP
13
+ $DEVCOMP,
14
+ splitProps
15
15
  } from "solid-js";
16
16
  export {
17
17
  ErrorBoundary,
@@ -571,16 +571,18 @@ function render(code, element, init, options = {}) {
571
571
  element.textContent = "";
572
572
  };
573
573
  }
574
- function template(html, isImportNode, isSVG) {
574
+ function template(html, isImportNode, isSVG, isMathML) {
575
575
  let node;
576
576
  const create = () => {
577
577
  if (isHydrating())
578
578
  throw new Error(
579
579
  "Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration."
580
580
  );
581
- const t = document.createElement("template");
581
+ const t = isMathML
582
+ ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template")
583
+ : document.createElement("template");
582
584
  t.innerHTML = html;
583
- return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
585
+ return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
584
586
  };
585
587
  const fn = isImportNode
586
588
  ? () => untrack(() => document.importNode(node || (node = create()), true))
@@ -1160,9 +1162,8 @@ function Portal(props) {
1160
1162
  );
1161
1163
  return marker;
1162
1164
  }
1163
- function Dynamic(props) {
1164
- const [p, others] = splitProps(props, ["component"]);
1165
- const cached = createMemo(() => p.component);
1165
+ function createDynamic(component, props) {
1166
+ const cached = createMemo(component);
1166
1167
  return createMemo(() => {
1167
1168
  const component = cached();
1168
1169
  switch (typeof component) {
@@ -1170,15 +1171,19 @@ function Dynamic(props) {
1170
1171
  Object.assign(component, {
1171
1172
  [$DEVCOMP]: true
1172
1173
  });
1173
- return untrack(() => component(others));
1174
+ return untrack(() => component(props));
1174
1175
  case "string":
1175
1176
  const isSvg = SVGElements.has(component);
1176
1177
  const el = sharedConfig.context ? getNextElement() : createElement(component, isSvg);
1177
- spread(el, others, isSvg);
1178
+ spread(el, props, isSvg);
1178
1179
  return el;
1179
1180
  }
1180
1181
  });
1181
1182
  }
1183
+ function Dynamic(props) {
1184
+ const [, others] = splitProps(props, ["component"]);
1185
+ return createDynamic(() => props.component, others);
1186
+ }
1182
1187
 
1183
1188
  export {
1184
1189
  Aliases,
@@ -1200,6 +1205,7 @@ export {
1200
1205
  classList,
1201
1206
  className,
1202
1207
  clearDelegatedEvents,
1208
+ createDynamic,
1203
1209
  delegateEvents,
1204
1210
  dynamicProperty,
1205
1211
  escape,
@@ -408,7 +408,7 @@ function ssrElement(tag, props, children, needsId) {
408
408
  for (let i = 0; i < keys.length; i++) {
409
409
  const prop = keys[i];
410
410
  if (ChildProperties.has(prop)) {
411
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
411
+ if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
412
412
  continue;
413
413
  }
414
414
  const value = props[prop];
@@ -668,16 +668,19 @@ function notSup() {
668
668
 
669
669
  const isServer = true;
670
670
  const isDev = false;
671
- function Dynamic(props) {
672
- const [p, others] = solidJs.splitProps(props, ["component"]);
673
- const comp = p.component,
671
+ function createDynamic(component, props) {
672
+ const comp = component(),
674
673
  t = typeof comp;
675
674
  if (comp) {
676
- if (t === "function") return comp(others);else if (t === "string") {
677
- return ssrElement(comp, others, undefined, true);
675
+ if (t === "function") return comp(props);else if (t === "string") {
676
+ return ssrElement(comp, props, undefined, true);
678
677
  }
679
678
  }
680
679
  }
680
+ function Dynamic(props) {
681
+ const [, others] = solidJs.splitProps(props, ["component"]);
682
+ return createDynamic(() => props.component, others);
683
+ }
681
684
  function Portal(props) {
682
685
  return "";
683
686
  }
@@ -756,6 +759,7 @@ exports.addEventListener = notSup;
756
759
  exports.assign = notSup;
757
760
  exports.classList = notSup;
758
761
  exports.className = notSup;
762
+ exports.createDynamic = createDynamic;
759
763
  exports.delegateEvents = notSup;
760
764
  exports.dynamicProperty = notSup;
761
765
  exports.escape = escape;
@@ -858,7 +858,10 @@ function ssrElement(tag, props, children, needsId) {
858
858
  const prop = keys[i];
859
859
  if (ChildProperties.has(prop)) {
860
860
  if (children === undefined && !skipChildren)
861
- children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
861
+ children =
862
+ tag === "script" || tag === "style" || prop === "innerHTML"
863
+ ? props[prop]
864
+ : escape(props[prop]);
862
865
  continue;
863
866
  }
864
867
  const value = props[prop];
@@ -1142,17 +1145,20 @@ function notSup() {
1142
1145
 
1143
1146
  const isServer = true;
1144
1147
  const isDev = false;
1145
- function Dynamic(props) {
1146
- const [p, others] = splitProps(props, ["component"]);
1147
- const comp = p.component,
1148
+ function createDynamic(component, props) {
1149
+ const comp = component(),
1148
1150
  t = typeof comp;
1149
1151
  if (comp) {
1150
- if (t === "function") return comp(others);
1152
+ if (t === "function") return comp(props);
1151
1153
  else if (t === "string") {
1152
- return ssrElement(comp, others, undefined, true);
1154
+ return ssrElement(comp, props, undefined, true);
1153
1155
  }
1154
1156
  }
1155
1157
  }
1158
+ function Dynamic(props) {
1159
+ const [, others] = splitProps(props, ["component"]);
1160
+ return createDynamic(() => props.component, others);
1161
+ }
1156
1162
  function Portal(props) {
1157
1163
  return "";
1158
1164
  }
@@ -1176,6 +1182,7 @@ export {
1176
1182
  notSup as assign,
1177
1183
  notSup as classList,
1178
1184
  notSup as className,
1185
+ createDynamic,
1179
1186
  notSup as delegateEvents,
1180
1187
  notSup as dynamicProperty,
1181
1188
  escape,
package/web/dist/web.cjs CHANGED
@@ -119,12 +119,12 @@ function render(code, element, init, options = {}) {
119
119
  element.textContent = "";
120
120
  };
121
121
  }
122
- function template(html, isImportNode, isSVG) {
122
+ function template(html, isImportNode, isSVG, isMathML) {
123
123
  let node;
124
124
  const create = () => {
125
- const t = document.createElement("template");
125
+ const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
126
126
  t.innerHTML = html;
127
- return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
127
+ return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
128
128
  };
129
129
  const fn = isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
130
130
  fn.cloneNode = fn;
@@ -377,7 +377,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
377
377
  setAttribute(node, prop.slice(5), value);
378
378
  } else if (prop.slice(0, 5) === "bool:") {
379
379
  setBoolAttribute(node, prop.slice(5), value);
380
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || 'is' in props)) {
380
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || "is" in props)) {
381
381
  if (forceProp) {
382
382
  prop = prop.slice(5);
383
383
  isProp = true;
@@ -661,22 +661,25 @@ function Portal(props) {
661
661
  });
662
662
  return marker;
663
663
  }
664
- function Dynamic(props) {
665
- const [p, others] = solidJs.splitProps(props, ["component"]);
666
- const cached = solidJs.createMemo(() => p.component);
664
+ function createDynamic(component, props) {
665
+ const cached = solidJs.createMemo(component);
667
666
  return solidJs.createMemo(() => {
668
667
  const component = cached();
669
668
  switch (typeof component) {
670
669
  case "function":
671
- return solidJs.untrack(() => component(others));
670
+ return solidJs.untrack(() => component(props));
672
671
  case "string":
673
672
  const isSvg = SVGElements.has(component);
674
673
  const el = solidJs.sharedConfig.context ? getNextElement() : createElement(component, isSvg);
675
- spread(el, others, isSvg);
674
+ spread(el, props, isSvg);
676
675
  return el;
677
676
  }
678
677
  });
679
678
  }
679
+ function Dynamic(props) {
680
+ const [, others] = solidJs.splitProps(props, ["component"]);
681
+ return createDynamic(() => props.component, others);
682
+ }
680
683
 
681
684
  Object.defineProperty(exports, "ErrorBoundary", {
682
685
  enumerable: true,
@@ -753,6 +756,7 @@ exports.assign = assign;
753
756
  exports.classList = classList;
754
757
  exports.className = className;
755
758
  exports.clearDelegatedEvents = clearDelegatedEvents;
759
+ exports.createDynamic = createDynamic;
756
760
  exports.delegateEvents = delegateEvents;
757
761
  exports.dynamicProperty = dynamicProperty;
758
762
  exports.escape = escape;
package/web/dist/web.js CHANGED
@@ -565,12 +565,14 @@ function render(code, element, init, options = {}) {
565
565
  element.textContent = "";
566
566
  };
567
567
  }
568
- function template(html, isImportNode, isSVG) {
568
+ function template(html, isImportNode, isSVG, isMathML) {
569
569
  let node;
570
570
  const create = () => {
571
- const t = document.createElement("template");
571
+ const t = isMathML
572
+ ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template")
573
+ : document.createElement("template");
572
574
  t.innerHTML = html;
573
- return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
575
+ return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
574
576
  };
575
577
  const fn = isImportNode
576
578
  ? () => untrack(() => document.importNode(node || (node = create()), true))
@@ -1142,22 +1144,25 @@ function Portal(props) {
1142
1144
  );
1143
1145
  return marker;
1144
1146
  }
1145
- function Dynamic(props) {
1146
- const [p, others] = splitProps(props, ["component"]);
1147
- const cached = createMemo(() => p.component);
1147
+ function createDynamic(component, props) {
1148
+ const cached = createMemo(component);
1148
1149
  return createMemo(() => {
1149
1150
  const component = cached();
1150
1151
  switch (typeof component) {
1151
1152
  case "function":
1152
- return untrack(() => component(others));
1153
+ return untrack(() => component(props));
1153
1154
  case "string":
1154
1155
  const isSvg = SVGElements.has(component);
1155
1156
  const el = sharedConfig.context ? getNextElement() : createElement(component, isSvg);
1156
- spread(el, others, isSvg);
1157
+ spread(el, props, isSvg);
1157
1158
  return el;
1158
1159
  }
1159
1160
  });
1160
1161
  }
1162
+ function Dynamic(props) {
1163
+ const [, others] = splitProps(props, ["component"]);
1164
+ return createDynamic(() => props.component, others);
1165
+ }
1161
1166
 
1162
1167
  export {
1163
1168
  Aliases,
@@ -1179,6 +1184,7 @@ export {
1179
1184
  classList,
1180
1185
  className,
1181
1186
  clearDelegatedEvents,
1187
+ createDynamic,
1182
1188
  delegateEvents,
1183
1189
  dynamicProperty,
1184
1190
  escape,
@@ -44,6 +44,22 @@ export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
44
44
  } & {
45
45
  component: T | undefined;
46
46
  };
47
+ /**
48
+ * Renders an arbitrary component or element with the given props
49
+ *
50
+ * This is a lower level version of the `Dynamic` component, useful for
51
+ * performance optimizations in libraries. Do not use this unless you know
52
+ * what you are doing.
53
+ * ```typescript
54
+ * const element = () => multiline() ? 'textarea' : 'input';
55
+ * createDynamic(element, { value: value() });
56
+ * ```
57
+ * @description https://docs.solidjs.com/reference/components/dynamic
58
+ */
59
+ export declare function createDynamic<T extends ValidComponent>(
60
+ component: () => T | undefined,
61
+ props: ComponentProps<T>
62
+ ): JSX.Element;
47
63
  /**
48
64
  * Renders an arbitrary custom or native component and passes the other props
49
65
  * ```typescript