@stencil/core 5.0.0-beta.3 → 5.0.0-beta.31

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.
Files changed (36) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-DIvBaMnB.mjs} +182 -70
  3. package/dist/compiler/browser.d.ts +114 -81
  4. package/dist/compiler/browser.js +743 -339
  5. package/dist/compiler/index.d.mts +110 -2
  6. package/dist/compiler/index.mjs +3 -3
  7. package/dist/compiler/utils/index.d.mts +1 -1
  8. package/dist/{compiler-BPgV6bA4.mjs → compiler-BI12oAIV.mjs} +4840 -2899
  9. package/dist/declarations/stencil-public-compiler.d.ts +152 -129
  10. package/dist/declarations/stencil-public-docs.d.ts +23 -0
  11. package/dist/declarations/stencil-public-runtime.d.ts +62 -58
  12. package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
  13. package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
  14. package/dist/{index-BXAcVN2j.d.ts → index-CicD4Pgn.d.ts} +59 -55
  15. package/dist/index.d.mts +3 -0
  16. package/dist/index.mjs +1 -1
  17. package/dist/jsx-runtime.d.mts +6 -0
  18. package/dist/jsx-runtime.mjs +1 -1
  19. package/dist/{node-75gQKkFz.mjs → node-D-21Ykxi.mjs} +41 -47
  20. package/dist/runtime/client/lazy.js +321 -200
  21. package/dist/runtime/client/runtime.d.ts +73 -66
  22. package/dist/runtime/client/runtime.js +321 -200
  23. package/dist/runtime/index.d.ts +4 -5
  24. package/dist/runtime/index.js +319 -198
  25. package/dist/runtime/server/index.d.mts +11 -11
  26. package/dist/runtime/server/index.mjs +371 -239
  27. package/dist/runtime/server/runner.d.mts +4 -4
  28. package/dist/runtime/server/runner.mjs +82 -54
  29. package/dist/signals/index.d.ts +11 -2
  30. package/dist/signals/index.js +14 -35
  31. package/dist/sys/node/index.d.mts +1 -1
  32. package/dist/sys/node/index.mjs +1 -1
  33. package/dist/sys/node/worker.mjs +2 -2
  34. package/dist/testing/index.d.mts +136 -120
  35. package/dist/testing/index.mjs +328 -212
  36. package/package.json +8 -4
@@ -1,18 +1,95 @@
1
1
  import { BUILD as BUILD$1, Env, NAMESPACE } from "@stencil/core/app-data";
2
2
  import { globalStyles } from "@stencil/core/app-globals";
3
- import { effect, effect as effect$1, signal } from "@preact/signals-core";
3
+ import * as SignalsCore from "@preact/signals-core";
4
4
  //#region src/app-data/lazy.ts
5
5
  const BUILD = {
6
6
  ...BUILD$1,
7
7
  lazyLoad: true
8
8
  };
9
9
  //#endregion
10
+ //#region src/runtime/runtime-constants.ts
11
+ /**
12
+ * Bit flags for recording various properties of VDom nodes
13
+ */
14
+ const VNODE_FLAGS = {
15
+ /**
16
+ * Whether or not a vdom node is a slot reference
17
+ */
18
+ isSlotReference: 1,
19
+ /**
20
+ * Whether or not a slot element has fallback content
21
+ */
22
+ isSlotFallback: 2,
23
+ /**
24
+ * Whether or not an element is a host element
25
+ */
26
+ isHost: 4
27
+ };
28
+ const PROXY_FLAGS = {
29
+ isElementConstructor: 1,
30
+ proxyState: 2
31
+ };
32
+ const PLATFORM_FLAGS = {
33
+ /**
34
+ * designates a node in the DOM as being actively moved by the runtime
35
+ */
36
+ isTmpDisconnected: 1,
37
+ appLoaded: 2,
38
+ queueSync: 4,
39
+ queueMask: 6
40
+ };
41
+ /**
42
+ * A (subset) of node types which are relevant for the Stencil runtime. These
43
+ * values are based on the values which can possibly be returned by the
44
+ * `.nodeType` property of a DOM node. See here for details:
45
+ *
46
+ * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
47
+ */
48
+ const NODE_TYPE = {
49
+ ElementNode: 1,
50
+ TextNode: 3,
51
+ CommentNode: 8,
52
+ DocumentNode: 9,
53
+ DocumentTypeNode: 10,
54
+ DocumentFragment: 11
55
+ };
56
+ const HYDRATE_ID = "s-id";
57
+ const HYDRATED_STYLE_ID = "sty-id";
58
+ const HYDRATE_CHILD_ID = "c-id";
59
+ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
60
+ /**
61
+ * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
62
+ *
63
+ * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
64
+ * support as of Stencil v4.
65
+ */
66
+ const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
67
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
68
+ /**
69
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
70
+ */
71
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
72
+ const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
73
+ "formAssociatedCallback",
74
+ "formResetCallback",
75
+ "formDisabledCallback",
76
+ "formStateRestoreCallback"
77
+ ];
78
+ //#endregion
10
79
  //#region src/client/client-build.ts
80
+ /**
81
+ * `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
82
+ * sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
83
+ */
11
84
  const Build = {
12
- isDev: BUILD.isDev,
13
85
  isBrowser: true,
14
86
  isServer: false,
15
- isTesting: BUILD.isTesting
87
+ get isDev() {
88
+ return BUILD.isDev;
89
+ },
90
+ get isTesting() {
91
+ return BUILD.isTesting;
92
+ }
16
93
  };
17
94
  //#endregion
18
95
  //#region src/client/client-decorators.ts
@@ -494,79 +571,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
494
571
  //#endregion
495
572
  //#region src/client/client-style.ts
496
573
  const styles = /*@__PURE__*/ new Map();
497
- const modeResolutionChain = [];
498
- const setScopedSsr = (_opts) => {};
574
+ const modeResolver = [];
575
+ const setScopedSSR = (_opts) => {};
499
576
  const needsScopedSSR = () => false;
500
577
  //#endregion
501
- //#region src/runtime/runtime-constants.ts
502
- /**
503
- * Bit flags for recording various properties of VDom nodes
504
- */
505
- const VNODE_FLAGS = {
506
- /**
507
- * Whether or not a vdom node is a slot reference
508
- */
509
- isSlotReference: 1,
510
- /**
511
- * Whether or not a slot element has fallback content
512
- */
513
- isSlotFallback: 2,
514
- /**
515
- * Whether or not an element is a host element
516
- */
517
- isHost: 4
518
- };
519
- const PROXY_FLAGS = {
520
- isElementConstructor: 1,
521
- proxyState: 2
522
- };
523
- const PLATFORM_FLAGS = {
524
- /**
525
- * designates a node in the DOM as being actively moved by the runtime
526
- */
527
- isTmpDisconnected: 1,
528
- appLoaded: 2,
529
- queueSync: 4,
530
- queueMask: 6
531
- };
532
- /**
533
- * A (subset) of node types which are relevant for the Stencil runtime. These
534
- * values are based on the values which can possibly be returned by the
535
- * `.nodeType` property of a DOM node. See here for details:
536
- *
537
- * {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
538
- */
539
- const NODE_TYPE = {
540
- ElementNode: 1,
541
- TextNode: 3,
542
- CommentNode: 8,
543
- DocumentNode: 9,
544
- DocumentTypeNode: 10,
545
- DocumentFragment: 11
546
- };
547
- const HYDRATE_ID = "s-id";
548
- const HYDRATED_STYLE_ID = "sty-id";
549
- const HYDRATE_CHILD_ID = "c-id";
550
- const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
551
- /**
552
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
553
- *
554
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
555
- * support as of Stencil v4.
556
- */
557
- const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
558
- const XLINK_NS = "http://www.w3.org/1999/xlink";
559
- /**
560
- * Minimum delay, in milliseconds, before retrying a failed lazy component load.
561
- */
562
- const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
563
- const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
564
- "formAssociatedCallback",
565
- "formResetCallback",
566
- "formDisabledCallback",
567
- "formStateRestoreCallback"
568
- ];
569
- //#endregion
570
578
  //#region src/client/client-window.ts
571
579
  const win = typeof window !== "undefined" ? window : {};
572
580
  const H = win.HTMLElement || class {};
@@ -607,7 +615,7 @@ let queuePending = false;
607
615
  const queueDomReads = [];
608
616
  const queueDomWrites = [];
609
617
  const queueDomWritesLow = [];
610
- const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
618
+ const scheduleFlush = () => win.document?.hidden ? setTimeout(flush, 16) : plt.raf(flush);
611
619
  const queueTask = (queue, write) => (cb) => {
612
620
  queue.push(cb);
613
621
  if (!queuePending) {
@@ -970,6 +978,7 @@ const patchSlotAppendChild = (HostElementPrototype) => {
970
978
  const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
971
979
  if (slotNode) {
972
980
  addSlotRelocateNode(newChild, slotNode);
981
+ patchSlottedNode(newChild);
973
982
  const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
974
983
  const appendAfter = slotChildNodes[slotChildNodes.length - 1];
975
984
  const insertedNode = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, appendAfter.nextSibling);
@@ -992,8 +1001,10 @@ const patchSlotRemoveChild = (ElementPrototype) => {
992
1001
  ElementPrototype.__removeChild = ElementPrototype.removeChild;
993
1002
  ElementPrototype.removeChild = function(toRemove) {
994
1003
  if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
995
- if (getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"]) && toRemove.isConnected) {
996
- toRemove.remove();
1004
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"]);
1005
+ if (slotNode && toRemove.isConnected) {
1006
+ removeSlottedNode(toRemove);
1007
+ if (slotNode[0]) dispatchSlotChangeEvent(slotNode[0]);
997
1008
  updateFallbackSlotVisibility(this);
998
1009
  return;
999
1010
  }
@@ -1016,6 +1027,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
1016
1027
  const slotNode = getHostSlotNodes(internalCall(this, "childNodes"), this.tagName, slotName)[0];
1017
1028
  if (slotNode) {
1018
1029
  addSlotRelocateNode(newChild, slotNode, true);
1030
+ patchSlottedNode(newChild);
1019
1031
  const appendAfter = getSlotChildSiblings(slotNode, slotName)[0];
1020
1032
  const toReturn = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
1021
1033
  dispatchSlotChangeEvent(slotNode);
@@ -1091,6 +1103,7 @@ const patchInsertBefore = (HostElementPrototype) => {
1091
1103
  }
1092
1104
  if (slotName === currentChild["s-sn"]) {
1093
1105
  addSlotRelocateNode(newChild, slotNode);
1106
+ patchSlottedNode(newChild);
1094
1107
  internalCall(internalCall(currentChild, "parentNode"), "insertBefore")(newChild, currentChild);
1095
1108
  dispatchSlotChangeEvent(slotNode);
1096
1109
  }
@@ -1169,10 +1182,21 @@ const patchChildSlotNodes = (elm) => {
1169
1182
  } });
1170
1183
  };
1171
1184
  /**
1172
- * Patches sibling accessors of a 'slotted' node within a non-shadow component.
1173
- * Meaning whilst stepping through a non-shadow element's nodes, only the mock 'lightDOM' nodes are returned.
1174
- * Especially relevant when rendering components via SSR... Frameworks will often try to reconcile their
1175
- * VDOM with the real DOM by stepping through nodes with 'nextSibling' et al.
1185
+ * Patches a node slotted into a non-shadow component so it behaves as it would in a native slot:
1186
+ * - `parentNode` returns the host element
1187
+ * - `remove()` fires `slotchange` on the node's slot
1188
+ *
1189
+ * @param node the slotted node to be patched
1190
+ */
1191
+ const patchSlottedNode = (node) => {
1192
+ patchParentNode(node);
1193
+ patchSlottedRemove(node);
1194
+ };
1195
+ /**
1196
+ * Patches a slotted node from SSR markup: everything {@link patchSlottedNode} does, plus its
1197
+ * sibling accessors, so whilst stepping through a non-shadow element's nodes only the mock
1198
+ * 'lightDOM' nodes are returned. Frameworks hydrating SSR output often reconcile their VDOM with
1199
+ * the real DOM by stepping through nodes with 'nextSibling' et al.
1176
1200
  * - `nextSibling`
1177
1201
  * - `nextElementSibling`
1178
1202
  * - `previousSibling`
@@ -1180,11 +1204,11 @@ const patchChildSlotNodes = (elm) => {
1180
1204
  *
1181
1205
  * @param node the slotted node to be patched
1182
1206
  */
1183
- const patchSlottedNode = (node) => {
1207
+ const patchSsrSlottedNode = (node) => {
1184
1208
  if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
1185
1209
  patchNextSibling(node);
1186
1210
  patchPreviousSibling(node);
1187
- patchParentNode(node);
1211
+ patchSlottedNode(node);
1188
1212
  if (node.nodeType === Node.ELEMENT_NODE) {
1189
1213
  patchNextElementSibling(node);
1190
1214
  patchPreviousElementSibling(node);
@@ -1251,6 +1275,39 @@ const patchPreviousElementSibling = (element) => {
1251
1275
  } });
1252
1276
  };
1253
1277
  /**
1278
+ * Detaches a slotted node from where it physically sits in the component's rendered DOM, through
1279
+ * the unpatched accessors. Not via `remove()`: mock-doc's `remove()` calls
1280
+ * `parentNode.removeChild()`, and a slotted node's patched `parentNode` is the host, whose patched
1281
+ * `removeChild()` would come straight back here.
1282
+ *
1283
+ * @param node the slotted node to detach
1284
+ */
1285
+ const removeSlottedNode = (node) => {
1286
+ const parent = internalCall(node, "parentNode");
1287
+ if (parent) internalCall(parent, "removeChild")(node);
1288
+ };
1289
+ /**
1290
+ * Patches `remove()` on a node slotted into a non-shadow component, so that removing it fires
1291
+ * `slotchange` on its slot (and updates fallback content), as removing a node from a native slot
1292
+ * does. Stencil's own node moves, while `isTmpDisconnected` is set, don't fire it.
1293
+ *
1294
+ * @param node the slotted node to patch
1295
+ */
1296
+ const patchSlottedRemove = (node) => {
1297
+ const child = node;
1298
+ if (!child || child.__remove || typeof child.remove !== "function") return;
1299
+ child.__remove = child.remove;
1300
+ child.remove = function() {
1301
+ const host = this["s-ol"]?.parentElement;
1302
+ const { slotNode } = findSlotFromSlottedNode(this);
1303
+ removeSlottedNode(this);
1304
+ if (slotNode && !(plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected)) {
1305
+ dispatchSlotChangeEvent(slotNode);
1306
+ updateFallbackSlotVisibility(host);
1307
+ }
1308
+ };
1309
+ };
1310
+ /**
1254
1311
  * Patches the `parentNode` accessor of a non-shadow slotted node
1255
1312
  *
1256
1313
  * @param node the slotted node to be patched
@@ -1691,6 +1748,13 @@ const isComplexType = (o) => {
1691
1748
  return o === "object" || o === "function";
1692
1749
  };
1693
1750
  //#endregion
1751
+ //#region src/runtime/signals-core.ts
1752
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1753
+ const effect = (fn, options) => getCore().effect(fn, options);
1754
+ function signal(value, options) {
1755
+ return getCore().signal(value, options);
1756
+ }
1757
+ //#endregion
1694
1758
  //#region src/runtime/event-emitter.ts
1695
1759
  const createEvent = (ref, name, flags) => {
1696
1760
  const elm = getElement(ref);
@@ -1723,6 +1787,11 @@ const setRegistry = (registry) => {
1723
1787
  _registry = registry;
1724
1788
  };
1725
1789
  const getRegistry = () => _registry ?? customElements;
1790
+ /**
1791
+ * @param elm a defined component host
1792
+ * @returns the registry the host's class was defined in, else the active registry
1793
+ */
1794
+ const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
1726
1795
  //#endregion
1727
1796
  //#region src/runtime/vdom/set-accessor.ts
1728
1797
  /**
@@ -1766,7 +1835,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1766
1835
  attrMap.get(memberName)?.();
1767
1836
  if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
1768
1837
  let prevVal = oldValue;
1769
- attrMap.set(memberName, effect$1(() => {
1838
+ attrMap.set(memberName, effect(() => {
1770
1839
  const curVal = newValue.value;
1771
1840
  setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
1772
1841
  prevVal = curVal;
@@ -1846,10 +1915,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1846
1915
  const isComplex = isComplexType(newValue);
1847
1916
  if (!BUILD.lazyLoad) {
1848
1917
  const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
1849
- if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && typeof customElements !== "undefined" && !customElements.get(elm.tagName.toLowerCase())) {
1918
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
1850
1919
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
1851
1920
  elm["s-pp"].set(memberName, newValue);
1852
- return;
1921
+ if (isComplex || /[A-Z]/.test(memberName)) return;
1853
1922
  }
1854
1923
  }
1855
1924
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -1967,6 +2036,7 @@ function sortedAttrNames(attrNames) {
1967
2036
  let scopeId;
1968
2037
  let contentRef;
1969
2038
  let hostTagName;
2039
+ let hostRegistry;
1970
2040
  let useNativeShadowDom = false;
1971
2041
  let checkSlotFallbackVisibility = false;
1972
2042
  let checkSlotRelocate = false;
@@ -1976,6 +2046,7 @@ let isSvgMode = false;
1976
2046
  * These ensure that ref callbacks are called in the correct order:
1977
2047
  * first all removal callbacks (with null), then all attachment callbacks (with elements).
1978
2048
  */
2049
+ const initialSlotChanges = /* @__PURE__ */ new Set();
1979
2050
  const refCallbacksToRemove = [];
1980
2051
  const refCallbacksToAttach = [];
1981
2052
  /** Disposers for signal subscriptions on individual DOM nodes (text nodes, <s-show> wrappers). */
@@ -1983,16 +2054,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
1983
2054
  const disposeSignalVNode = (vnode) => {
1984
2055
  const elm = vnode.$elm$;
1985
2056
  if (elm) {
1986
- const dispose = signalNodeDisposers.get(elm);
1987
- if (dispose) {
1988
- dispose();
1989
- signalNodeDisposers.delete(elm);
1990
- }
2057
+ disposeTextSignal(elm);
1991
2058
  disposeAllSignalAttrs(elm);
1992
2059
  }
1993
2060
  vnode.$children$?.forEach(disposeSignalVNode);
1994
2061
  };
1995
2062
  /**
2063
+ * Tear down a text node's signal subscription, if it has one.
2064
+ * @param textNode the text node to unsubscribe
2065
+ */
2066
+ const disposeTextSignal = (textNode) => {
2067
+ const dispose = signalNodeDisposers.get(textNode);
2068
+ if (dispose) {
2069
+ dispose();
2070
+ signalNodeDisposers.delete(textNode);
2071
+ }
2072
+ };
2073
+ /**
2074
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
2075
+ * @param textNode the text node to keep in sync
2076
+ * @param textSig the signal to subscribe to
2077
+ */
2078
+ const wireTextSignal = (textNode, textSig) => {
2079
+ signalNodeDisposers.set(textNode, effect(() => {
2080
+ textNode.data = String(textSig.value);
2081
+ }));
2082
+ };
2083
+ /**
1996
2084
  * Create a DOM Node corresponding to one of the children of a given VNode.
1997
2085
  *
1998
2086
  * @param oldParentVNode the parent VNode from the previous render
@@ -2014,13 +2102,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2014
2102
  if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
2015
2103
  if (BUILD.vdomText && newVNode.$text$ != null) {
2016
2104
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
2017
- if (BUILD.vdomSignals && newVNode.$signal$) {
2018
- const textSig = newVNode.$signal$;
2019
- const textNode = elm;
2020
- signalNodeDisposers.set(textNode, effect$1(() => {
2021
- textNode.data = String(textSig.value);
2022
- }));
2023
- }
2105
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
2024
2106
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
2025
2107
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
2026
2108
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -2029,8 +2111,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2029
2111
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
2030
2112
  if (!win.document) throw new Error("No DOM environment available for rendering.");
2031
2113
  const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
2032
- const _reg = getRegistry();
2033
- const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
2114
+ const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
2034
2115
  elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
2035
2116
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
2036
2117
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
@@ -2288,7 +2369,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
2288
2369
  }
2289
2370
  if (BUILD.vdomKey && idxInOld >= 0) {
2290
2371
  elmToMove = oldCh[idxInOld];
2291
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
2372
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
2292
2373
  else {
2293
2374
  patch(elmToMove, newStartVnode, isInitialRender);
2294
2375
  oldCh[idxInOld] = void 0;
@@ -2381,7 +2462,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
2381
2462
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
2382
2463
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
2383
2464
  } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
2384
- else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
2465
+ else if (BUILD.vdomText) {
2466
+ if (BUILD.vdomSignals && newVNode.$signal$) {
2467
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
2468
+ disposeTextSignal(elm);
2469
+ wireTextSignal(elm, newVNode.$signal$);
2470
+ }
2471
+ } else {
2472
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
2473
+ if (oldVNode.$text$ !== text) elm.data = text;
2474
+ }
2475
+ }
2385
2476
  };
2386
2477
  /**
2387
2478
  * Component-global information about nodes which are either currently being
@@ -2510,10 +2601,13 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2510
2601
  if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2511
2602
  else if (typeof newNode["s-sn"] === "string") {
2512
2603
  const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
2513
- if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchParentNode(newNode);
2604
+ if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
2514
2605
  parent.insertBefore(newNode, reference);
2515
2606
  const { slotNode } = findSlotFromSlottedNode(newNode);
2516
- if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
2607
+ if (slotNode) {
2608
+ if (isInitialLoad) initialSlotChanges.add(slotNode);
2609
+ else dispatchSlotChangeEvent(slotNode);
2610
+ }
2517
2611
  return newNode;
2518
2612
  }
2519
2613
  }
@@ -2569,6 +2663,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2569
2663
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2570
2664
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2571
2665
  hostTagName = hostElm.tagName;
2666
+ hostRegistry = getHostRegistry(hostElm);
2572
2667
  if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
2573
2668
  Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2574
2669
 
@@ -2668,6 +2763,11 @@ render() {
2668
2763
  if (checkSlotFallbackVisibility) updateFallbackSlotVisibility(rootVnode.$elm$);
2669
2764
  plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
2670
2765
  relocateNodes.length = 0;
2766
+ if (initialSlotChanges.size) {
2767
+ const slotNodes = [...initialSlotChanges];
2768
+ initialSlotChanges.clear();
2769
+ nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
2770
+ }
2671
2771
  }
2672
2772
  if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2673
2773
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
@@ -2721,11 +2821,12 @@ const markFirstConnected = (hostRef) => {
2721
2821
  * autoloader, where the ancestor tag may not be defined yet.
2722
2822
  *
2723
2823
  * @param ancestorElm the nearest Stencil ancestor element
2824
+ * @param registry the registry the waiting component is defined in
2724
2825
  */
2725
- const awaitAncestorConnected = async (ancestorElm) => {
2826
+ const awaitAncestorConnected = async (ancestorElm, registry) => {
2726
2827
  let ancestorHostRef = getHostRef(ancestorElm);
2727
2828
  if (!BUILD.lazyLoad && !ancestorHostRef) {
2728
- await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2829
+ await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2729
2830
  ancestorHostRef = getHostRef(ancestorElm);
2730
2831
  }
2731
2832
  if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
@@ -3081,8 +3182,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3081
3182
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3082
3183
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
3083
3184
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
3084
- const initialVal = hostRef.$instanceValues$.get(memberName);
3085
- const sig = signal(initialVal);
3185
+ const sig = signal(hostRef.$instanceValues$.get(memberName));
3086
3186
  hostRef.$signalValues$.set(memberName, sig);
3087
3187
  let prevScheduleVal = sig.peek();
3088
3188
  disposers.push(effect(() => {
@@ -3210,9 +3310,7 @@ const h = (nodeName, vnodeData, ...children) => {
3210
3310
  if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
3211
3311
  }
3212
3312
  }
3213
- if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component. Make sure:
3214
- - You are NOT using hostData() and <Host> in the same component.
3215
- - <Host> is used once, and it's the single root component of the render() function.`);
3313
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
3216
3314
  if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
3217
3315
  const vnode = newVNode(nodeName, null);
3218
3316
  vnode.$attrs$ = vnodeData;
@@ -3265,17 +3363,23 @@ const vdomFnUtils = {
3265
3363
  * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
3266
3364
  * friendlier public interface (hence, 'convertToPublic').
3267
3365
  *
3268
- * @param node the virtual DOM node to convert
3366
+ * Functional components receive primitive children unwrapped, so those
3367
+ * become text-only child nodes.
3368
+ *
3369
+ * @param node the virtual DOM node (or primitive child) to convert
3269
3370
  * @returns a converted child node
3270
3371
  */
3271
- const convertToPublic = (node) => ({
3372
+ const convertToPublic = (node) => typeof node !== "object" ? {
3373
+ vtag: null,
3374
+ vtext: String(node)
3375
+ } : {
3272
3376
  vattrs: node.$attrs$,
3273
3377
  vchildren: node.$children$,
3274
3378
  vkey: node.$key$,
3275
3379
  vname: node.$name$,
3276
3380
  vtag: node.$tag$,
3277
3381
  vtext: node.$text$
3278
- });
3382
+ };
3279
3383
  /**
3280
3384
  * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
3281
3385
  * order to use the resulting object in the virtual DOM. The initial object was
@@ -3292,11 +3396,11 @@ const convertToPrivate = (node) => {
3292
3396
  if (node.vname) vnodeData.name = node.vname;
3293
3397
  return h(node.vtag, vnodeData, ...node.vchildren || []);
3294
3398
  }
3295
- const vnode = newVNode(node.vtag, node.vtext);
3296
- vnode.$attrs$ = node.vattrs;
3297
- vnode.$children$ = node.vchildren;
3298
- vnode.$key$ = node.vkey;
3299
- vnode.$name$ = node.vname;
3399
+ const vnode = newVNode(node.vtag ?? null, node.vtext);
3400
+ vnode.$attrs$ = node.vattrs ?? null;
3401
+ vnode.$children$ = node.vchildren ?? null;
3402
+ vnode.$key$ = node.vkey ?? null;
3403
+ vnode.$name$ = node.vname ?? null;
3300
3404
  return vnode;
3301
3405
  };
3302
3406
  /**
@@ -3416,7 +3520,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3416
3520
  }
3417
3521
  addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
3418
3522
  if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
3419
- if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSlottedNode(siNode);
3523
+ if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
3420
3524
  }
3421
3525
  currentPos = (siNode["s-oo"] || currentPos) + 1;
3422
3526
  }
@@ -3594,6 +3698,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
3594
3698
  const createSimpleVNode = (vnode) => ({
3595
3699
  $flags$: 0,
3596
3700
  $index$: "0",
3701
+ $children$: null,
3597
3702
  ...vnode
3598
3703
  });
3599
3704
  function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
@@ -3988,7 +4093,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
3988
4093
  else return shallowPart.trim();
3989
4094
  }).join(", ");
3990
4095
  };
3991
- const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
4096
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
3992
4097
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
3993
4098
  return processRules(cssText, (rule) => {
3994
4099
  let selector = rule.selector;
@@ -4107,8 +4212,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
4107
4212
  };
4108
4213
  //#endregion
4109
4214
  //#region src/runtime/mode.ts
4110
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
4111
- const setMode = (handler) => modeResolutionChain.push(handler);
4215
+ const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
4216
+ const setMode = (handler) => {
4217
+ modeResolver.length = 0;
4218
+ modeResolver.push(handler);
4219
+ };
4112
4220
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
4113
4221
  //#endregion
4114
4222
  //#region src/runtime/normalize-watchers.ts
@@ -4173,23 +4281,14 @@ const normalizeWatchers = (raw) => {
4173
4281
  *
4174
4282
  * @param propValue the new value to coerce to some type
4175
4283
  * @param propType the type of the prop, expressed as a binary number
4176
- * @param isFormAssociated whether the component is form-associated (optional)
4177
4284
  * @returns the parsed/coerced value
4178
4285
  */
4179
- const parsePropertyValue = (propValue, propType, isFormAssociated) => {
4286
+ const parsePropertyValue = (propValue, propType) => {
4180
4287
  if (propValue != null && !isComplexType(propValue)) {
4181
4288
  /**
4182
4289
  * ensure this value is of the correct prop type
4183
4290
  */
4184
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) {
4185
- /**
4186
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
4187
- * (regardless of its value, even "false") should make the property true.
4188
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
4189
- */
4190
- if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
4191
- else return propValue === "false" ? false : propValue === "" || !!propValue;
4192
- }
4291
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
4193
4292
  /**
4194
4293
  * force it to be a number
4195
4294
  */
@@ -4231,7 +4330,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4231
4330
  if (BUILD.signalBacking) {
4232
4331
  const sig = hostRef?.$signalValues$?.get(propName);
4233
4332
  if (sig !== void 0) {
4234
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4333
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4235
4334
  if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4236
4335
  const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4237
4336
  applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
@@ -4249,7 +4348,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4249
4348
  const oldVal = hostRef.$instanceValues$.get(propName);
4250
4349
  const flags = hostRef.$flags$;
4251
4350
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
4252
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4351
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4253
4352
  const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4254
4353
  if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4255
4354
  hostRef.$instanceValues$.set(propName, newVal);
@@ -4298,6 +4397,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4298
4397
  */
4299
4398
  const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
4300
4399
  /**
4400
+ * Hand values written to a lazy component's element before its instance existed to the
4401
+ * instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
4402
+ * whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
4403
+ *
4404
+ * @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
4405
+ * @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
4406
+ */
4407
+ const replayPendingSetterValues = (hostRef, cmpMeta) => {
4408
+ const instance = hostRef.$lazyInstance$;
4409
+ if (!instance) return;
4410
+ for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
4411
+ const pendingValue = hostRef.$instanceValues$.get(memberName);
4412
+ if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
4413
+ }
4414
+ };
4415
+ /**
4301
4416
  * Attach a series of runtime constructs to a compiled Stencil component
4302
4417
  * constructor, including getters and setters for the `@Prop` and `@State`
4303
4418
  * decorators, callbacks for when attributes change, and so on.
@@ -4354,9 +4469,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4354
4469
  if (BUILD.lazyLoad) {
4355
4470
  if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
4356
4471
  const ref = getHostRef(this);
4357
- const instance = ref ? ref.$lazyInstance$ : prototype;
4358
- if (!instance) return;
4359
- return instance[memberName];
4472
+ if (!ref) return prototype[memberName];
4473
+ return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
4360
4474
  }
4361
4475
  if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
4362
4476
  },
@@ -4371,7 +4485,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4371
4485
  }
4372
4486
  if (origSetter) {
4373
4487
  if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
4374
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated))]);
4488
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
4375
4489
  newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
4376
4490
  setValue(this, memberName, newValue, cmpMeta);
4377
4491
  return;
@@ -4383,21 +4497,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4383
4497
  if (BUILD.lazyLoad) {
4384
4498
  if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
4385
4499
  setValue(this, memberName, newValue, cmpMeta);
4386
- if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
4387
- if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
4388
- });
4389
4500
  return;
4390
4501
  }
4391
- const setterSetVal = () => {
4502
+ const parsedValue = parsePropertyValue(newValue, memberFlags);
4503
+ if (ref.$lazyInstance$) {
4392
4504
  const currentValue = ref.$lazyInstance$[memberName];
4393
4505
  if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
4394
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4506
+ ref.$lazyInstance$[memberName] = parsedValue;
4395
4507
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
4396
- };
4397
- if (ref.$lazyInstance$) setterSetVal();
4398
- else ref.$fetchedCbList$.push(() => {
4399
- setterSetVal();
4400
- });
4508
+ } else ref.$instanceValues$.set(memberName, parsedValue);
4401
4509
  }
4402
4510
  } });
4403
4511
  } else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
@@ -4449,7 +4557,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4449
4557
  const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4450
4558
  if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4451
4559
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4452
- if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4560
+ if (isBooleanTarget) {
4561
+ if (BUILD.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
4562
+ newValue = newValue !== null;
4563
+ }
4453
4564
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
4454
4565
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4455
4566
  });
@@ -4512,9 +4623,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4512
4623
  } catch (e) {
4513
4624
  consoleError(e, elm);
4514
4625
  }
4515
- if (BUILD.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4626
+ if (BUILD.member) {
4627
+ hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4628
+ replayPendingSetterValues(hostRef, cmpMeta);
4629
+ }
4516
4630
  endNewInstance();
4517
- if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4631
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4518
4632
  if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4519
4633
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4520
4634
  if (BUILD.asyncLoading) markFirstConnected(hostRef);
@@ -4614,9 +4728,16 @@ const connectedCallback = (elm) => {
4614
4728
  }
4615
4729
  if (BUILD.asyncLoading) {
4616
4730
  let ancestorComponent = elm;
4617
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) if (BUILD.hydrateClientSide && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
4618
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4619
- break;
4731
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
4732
+ if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
4733
+ ancestorComponent["s-p"] = [];
4734
+ ancestorComponent["s-rc"] = [];
4735
+ ancestorComponent["s-pc"] = [];
4736
+ }
4737
+ if (ancestorComponent["s-p"]) {
4738
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4739
+ break;
4740
+ }
4620
4741
  }
4621
4742
  }
4622
4743
  if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
@@ -4732,48 +4853,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4732
4853
  `${modulePath}?s-hmr=${hmrVersionId}`
4733
4854
  );
4734
4855
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4735
- if (!NewClass) return;
4736
- const ctor = customElements.get(cmpMeta.$tagName$);
4737
- if (ctor) {
4738
- for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4739
- if (key === "constructor") continue;
4740
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4741
- }
4742
- const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4743
- if (styleDesc) {
4744
- Object.defineProperty(ctor, "style", styleDesc);
4745
- const newStyle = NewClass.style;
4746
- if (newStyle) {
4747
- const scopeId = getScopeId(cmpMeta);
4748
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4749
- console.log("[stencil-hmr] registerStyle", {
4750
- tag: cmpMeta.$tagName$,
4751
- scopeId,
4752
- isShadow,
4753
- cssLen: newStyle.length
4754
- });
4755
- registerStyle(scopeId, newStyle, isShadow);
4756
- }
4757
- }
4758
- }
4759
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4760
- document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4761
- const hostRef = getHostRef(el);
4762
- if (BUILD.hostListener && hostRef?.$rmListeners$) {
4763
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4764
- hostRef.$rmListeners$ = void 0;
4765
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4766
- }
4767
- if (!isShadow && hostRef) {
4768
- console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4769
- attachStyles(hostRef);
4770
- }
4771
- forceUpdate(el);
4772
- });
4856
+ if (NewClass) hmrApplyClass(cmpMeta, NewClass);
4773
4857
  } catch (e) {
4774
4858
  console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4775
4859
  }
4776
4860
  };
4861
+ /**
4862
+ * Patch a re-executed component class onto the registered one and re-render every live instance.
4863
+ * Shared by the standalone re-import above and bundlers that re-execute the module themselves
4864
+ * (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
4865
+ *
4866
+ * @param cmpMeta runtime metadata for the component
4867
+ * @param NewClass the component's newly executed class
4868
+ */
4869
+ const hmrApplyClass = (cmpMeta, NewClass) => {
4870
+ const ctor = customElements.get(cmpMeta.$tagName$);
4871
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4872
+ if (ctor && ctor !== NewClass) {
4873
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4874
+ if (key === "constructor") continue;
4875
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4876
+ }
4877
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4878
+ if (styleDesc) {
4879
+ Object.defineProperty(ctor, "style", styleDesc);
4880
+ const newStyle = NewClass.style;
4881
+ if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
4882
+ }
4883
+ }
4884
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4885
+ const hostRef = getHostRef(el);
4886
+ if (BUILD.hostListener && hostRef?.$rmListeners$) {
4887
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4888
+ hostRef.$rmListeners$ = void 0;
4889
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4890
+ }
4891
+ if (!isShadow && hostRef) attachStyles(hostRef);
4892
+ forceUpdate(el);
4893
+ });
4894
+ };
4777
4895
  //#endregion
4778
4896
  //#region src/runtime/bootstrap-standalone.ts
4779
4897
  const defineCustomElement = (Cstr, compactMeta) => {
@@ -4796,9 +4914,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4796
4914
  cmpMeta.$serializers$ = Cstr.$serializers$;
4797
4915
  }
4798
4916
  if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4799
- if (BUILD.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4800
- hmrStart(this, cmpMeta, hmrVersionId);
4801
- };
4917
+ if (BUILD.hotModuleReplacement) {
4918
+ Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4919
+ hmrStart(this, cmpMeta, hmrVersionId);
4920
+ };
4921
+ Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
4922
+ }
4802
4923
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4803
4924
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4804
4925
  if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
@@ -4837,7 +4958,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4837
4958
  }
4838
4959
  connectedCallback(this);
4839
4960
  if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4840
- await awaitAncestorConnected(hostRef.$ancestorComponent$);
4961
+ await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4841
4962
  if (!this.isConnected) return;
4842
4963
  }
4843
4964
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
@@ -5152,7 +5273,7 @@ function Mixin(...mixins) {
5152
5273
  //#region src/runtime/nonce.ts
5153
5274
  /**
5154
5275
  * Assigns the given value to the nonce property on the runtime platform object.
5155
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
5276
+ * During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
5156
5277
  * @param nonce The value to be assigned to the platform nonce property.
5157
5278
  * @returns void
5158
5279
  */
@@ -5314,4 +5435,4 @@ function hasKeys(obj) {
5314
5435
  return false;
5315
5436
  }
5316
5437
  //#endregion
5317
- export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
5438
+ export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };