@stencil/core 5.0.0-rc.0 → 5.0.0-rc.10

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.
@@ -139,6 +139,11 @@ const HOST_FLAGS = {
139
139
  * is true while an initialization attempt is merely queued/in-flight.
140
140
  */
141
141
  hasFailedLoad: 2048,
142
+ /**
143
+ * Set while `renderVdom` patches the host, so writes of a serialized reflected value
144
+ * coming from the runtime's own reflection aren't applied back to the prop.
145
+ */
146
+ isReflecting: 16384,
142
147
  devOnRender: 4096,
143
148
  devOnDidLoad: 8192
144
149
  };
@@ -905,7 +910,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
905
910
  return toReturn;
906
911
  }
907
912
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
908
- return HostElementPrototype.__prepend(newChild);
913
+ return HostElementPrototype.__prepend.call(this, newChild);
909
914
  });
910
915
  };
911
916
  };
@@ -1574,7 +1579,7 @@ const attachStyles = (hostRef) => {
1574
1579
  else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
1575
1580
  else styleContainerNode = elm.getRootNode();
1576
1581
  const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
1577
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1582
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
1578
1583
  elm["s-sc"] = scopeId;
1579
1584
  elm.classList.add(scopeId + "-h");
1580
1585
  }
@@ -1661,12 +1666,51 @@ const isComplexType = (o) => {
1661
1666
  return o === "object" || o === "function";
1662
1667
  };
1663
1668
  //#endregion
1664
- //#region src/runtime/signals-core.ts
1665
- const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1666
- const effect = (fn, options) => getCore().effect(fn, options);
1667
- function signal(value, options) {
1668
- return getCore().signal(value, options);
1669
- }
1669
+ //#region src/runtime/parse-property-value.ts
1670
+ /**
1671
+ * Parse a new property value for a given property type.
1672
+ *
1673
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1674
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1675
+ * 1. `any`, the type given to `propValue` in the function signature
1676
+ * 2. the type stored from `propType`.
1677
+ *
1678
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1679
+ *
1680
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1681
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1682
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1683
+ * ```tsx
1684
+ * <my-cmp prop-val={0}></my-cmp>
1685
+ * ```
1686
+ *
1687
+ * HTML prop values on the other hand, will always a string
1688
+ *
1689
+ * @param propValue the new value to coerce to some type
1690
+ * @param propType the type of the prop, expressed as a binary number
1691
+ * @returns the parsed/coerced value
1692
+ */
1693
+ const parsePropertyValue = (propValue, propType) => {
1694
+ if (propValue != null && !isComplexType(propValue)) {
1695
+ /**
1696
+ * ensure this value is of the correct prop type
1697
+ */
1698
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
1699
+ /**
1700
+ * force it to be a number
1701
+ */
1702
+ if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1703
+ /**
1704
+ * could have been passed as a number or boolean but we still want it as a string
1705
+ */
1706
+ if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
1707
+ return propValue;
1708
+ }
1709
+ /**
1710
+ * not sure exactly what type we want so no need to change to a different type
1711
+ */
1712
+ return propValue;
1713
+ };
1670
1714
  //#endregion
1671
1715
  //#region src/runtime/event-emitter.ts
1672
1716
  const createEvent = (ref, name, flags) => {
@@ -2617,7 +2661,9 @@ render() {
2617
2661
  checkSlotFallbackVisibility = false;
2618
2662
  checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
2619
2663
  }
2664
+ if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
2620
2665
  patch(oldVNode, rootVnode, isInitialLoad);
2666
+ if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
2621
2667
  if (BUILD.slotRelocation) {
2622
2668
  plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2623
2669
  if (checkSlotRelocate) {
@@ -2728,24 +2774,24 @@ const markFirstConnected = (hostRef) => {
2728
2774
  hostRef.$onFirstConnectResolve$ = void 0;
2729
2775
  };
2730
2776
  /**
2731
- * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2732
- * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2733
- * `connectedCallback` paths so a component never connects before its nearest Stencil
2734
- * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2735
- * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2736
- * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2737
- * autoloader, where the ancestor tag may not be defined yet.
2777
+ * Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
2778
+ * completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
2779
+ * and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
2780
+ * connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
2781
+ * a returned promise, so a component whose ancestor is already connected carries on
2782
+ * synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
2783
+ * the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
2784
+ * tag may not be defined yet.
2738
2785
  *
2739
2786
  * @param ancestorElm the nearest Stencil ancestor element
2740
2787
  * @param registry the registry the waiting component is defined in
2788
+ * @returns a promise to await, or `undefined` if there's nothing to wait for
2741
2789
  */
2742
- const awaitAncestorConnected = async (ancestorElm, registry) => {
2743
- let ancestorHostRef = getHostRef(ancestorElm);
2744
- if (!BUILD.lazyLoad && !ancestorHostRef) {
2745
- await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2746
- ancestorHostRef = getHostRef(ancestorElm);
2747
- }
2748
- if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2790
+ const whenAncestorConnected = (ancestorElm, registry) => {
2791
+ const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
2792
+ const ancestorHostRef = getHostRef(ancestorElm);
2793
+ if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
2794
+ return pendingConnect(ancestorHostRef);
2749
2795
  };
2750
2796
  const attachToAncestor = (hostRef, ancestorComponent) => {
2751
2797
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
@@ -2765,10 +2811,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2765
2811
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2766
2812
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2767
2813
  if (isInitialLoad) {
2768
- const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2769
- if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2770
2814
  queueMicrotask(() => {
2771
- dispatch();
2815
+ const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2816
+ if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
2817
+ else dispatch();
2772
2818
  });
2773
2819
  return;
2774
2820
  }
@@ -3071,6 +3117,124 @@ const serverSideConnected = (elm) => {
3071
3117
  }
3072
3118
  };
3073
3119
  //#endregion
3120
+ //#region src/runtime/set-value.ts
3121
+ /**
3122
+ * The value a reflected prop writes to its attribute: the serialized value if it has one.
3123
+ * @param hostRef the component's host ref
3124
+ * @param propName the prop
3125
+ * @param val the prop's value
3126
+ * @returns the value to reflect
3127
+ */
3128
+ const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
3129
+ /**
3130
+ * Write a reflected prop's attribute as soon as the prop changes, like native elements do,
3131
+ * so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
3132
+ * @param hostRef the component's host ref
3133
+ * @param cmpMeta the component's runtime metadata
3134
+ * @param elm the host element
3135
+ * @param propName the prop that changed
3136
+ * @param oldAttrVal the previously reflected value
3137
+ * @param newAttrVal the value to reflect
3138
+ */
3139
+ const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
3140
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
3141
+ const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
3142
+ if (!attrName) return;
3143
+ if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
3144
+ setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
3145
+ if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
3146
+ };
3147
+ const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
3148
+ const run = (inst) => {
3149
+ let attrVal = val;
3150
+ for (const serializer of cmpMeta.$serializers$[propName]) {
3151
+ const [[methodName]] = Object.entries(serializer);
3152
+ attrVal = inst[methodName](attrVal, propName);
3153
+ }
3154
+ hostRef.$serializerValues$.set(propName, attrVal);
3155
+ };
3156
+ if (instance) run(instance);
3157
+ else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
3158
+ };
3159
+ const getValue = (ref, propName) => {
3160
+ if (BUILD.signalBacking) {
3161
+ const sig = getHostRef(ref)?.$signalValues$?.get(propName);
3162
+ if (sig !== void 0) return sig.value;
3163
+ }
3164
+ return getHostRef(ref).$instanceValues$.get(propName);
3165
+ };
3166
+ const setValue = (ref, propName, newVal, cmpMeta) => {
3167
+ const hostRef = getHostRef(ref);
3168
+ if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
3169
+ if (BUILD.signalBacking) {
3170
+ const sig = hostRef?.$signalValues$?.get(propName);
3171
+ if (sig !== void 0) {
3172
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3173
+ if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3174
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
3175
+ applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
3176
+ }
3177
+ if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
3178
+ return;
3179
+ }
3180
+ }
3181
+ if (!hostRef) {
3182
+ if (BUILD.lazyLoad) throw new Error(BUILD.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
3183
+ return;
3184
+ }
3185
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
3186
+ const oldVal = hostRef.$instanceValues$.get(propName);
3187
+ const flags = hostRef.$flags$;
3188
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3189
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3190
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3191
+ if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3192
+ hostRef.$instanceValues$.set(propName, newVal);
3193
+ const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
3194
+ if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
3195
+ if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
3196
+ if (BUILD.isDev) {
3197
+ if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
3198
+ else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
3199
+ }
3200
+ if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
3201
+ const watchMethods = cmpMeta.$watchers$[propName];
3202
+ if (watchMethods) watchMethods.map((watcher) => {
3203
+ try {
3204
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3205
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
3206
+ if (BUILD.signalBacking && !hostRef.$signalValues$) return;
3207
+ if (!instance) hostRef.$fetchedCbList$.push(() => {
3208
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3209
+ });
3210
+ else instance[watchMethodName](newVal, oldVal, propName);
3211
+ }
3212
+ } catch (e) {
3213
+ consoleError(e, elm);
3214
+ }
3215
+ });
3216
+ }
3217
+ if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
3218
+ if (instance.componentShouldUpdate) {
3219
+ const changes = hostRef.$queuedPropChanges$ ||= {};
3220
+ changes[propName] = {
3221
+ newVal,
3222
+ oldVal: changes[propName]?.oldVal ?? oldVal
3223
+ };
3224
+ }
3225
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3226
+ }
3227
+ }
3228
+ };
3229
+ //#endregion
3230
+ //#region src/runtime/signals-core.ts
3231
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
3232
+ const effect = (fn, options) => getCore().effect(fn, options);
3233
+ const untracked = (fn) => getCore().untracked(fn);
3234
+ function signal(value, options) {
3235
+ return getCore().signal(value, options);
3236
+ }
3237
+ //#endregion
3074
3238
  //#region src/runtime/signals.ts
3075
3239
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
3076
3240
  /**
@@ -3115,6 +3279,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3115
3279
  }
3116
3280
  prevScheduleVal = newVal;
3117
3281
  }));
3282
+ if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
3283
+ let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
3284
+ disposers.push(effect(() => {
3285
+ const attrVal = getReflectedValue(hostRef, memberName, sig.value);
3286
+ untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
3287
+ prevAttrVal = attrVal;
3288
+ }));
3289
+ }
3118
3290
  if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
3119
3291
  const watchMethods = cmpMeta.$watchers$[memberName];
3120
3292
  let prevWatchVal = sig.peek();
@@ -3183,7 +3355,7 @@ const initializeEffects = (elm, hostRef) => {
3183
3355
  * Modified for Stencil's compiler and vdom
3184
3356
  */
3185
3357
  const h = (nodeName, vnodeData, ...children) => {
3186
- if (typeof nodeName === "string") nodeName = transformTag(nodeName);
3358
+ if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
3187
3359
  let child = null;
3188
3360
  let key = null;
3189
3361
  let slotName = null;
@@ -3361,7 +3533,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3361
3533
  let scopeId;
3362
3534
  if (BUILD.scoped) {
3363
3535
  const cmpMeta = hostRef.$cmpMeta$;
3364
- if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
3536
+ if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
3365
3537
  scopeId = hostElm["s-sc"];
3366
3538
  hostElm.classList.add(scopeId + "-h");
3367
3539
  } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
@@ -3657,7 +3829,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
3657
3829
  if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
3658
3830
  do {
3659
3831
  const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
3660
- if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
3832
+ if ((slottedNode["getAttribute"] && slottedNode.getAttribute("s-sn")) === slotName || (sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
3661
3833
  slottedNode["s-sn"] = slotName;
3662
3834
  group.push({
3663
3835
  slot: slotNode,
@@ -4179,134 +4351,6 @@ const normalizeWatchers = (raw) => {
4179
4351
  return out;
4180
4352
  };
4181
4353
  //#endregion
4182
- //#region src/runtime/parse-property-value.ts
4183
- /**
4184
- * Parse a new property value for a given property type.
4185
- *
4186
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
4187
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
4188
- * 1. `any`, the type given to `propValue` in the function signature
4189
- * 2. the type stored from `propType`.
4190
- *
4191
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
4192
- *
4193
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
4194
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
4195
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
4196
- * ```tsx
4197
- * <my-cmp prop-val={0}></my-cmp>
4198
- * ```
4199
- *
4200
- * HTML prop values on the other hand, will always a string
4201
- *
4202
- * @param propValue the new value to coerce to some type
4203
- * @param propType the type of the prop, expressed as a binary number
4204
- * @returns the parsed/coerced value
4205
- */
4206
- const parsePropertyValue = (propValue, propType) => {
4207
- if (propValue != null && !isComplexType(propValue)) {
4208
- /**
4209
- * ensure this value is of the correct prop type
4210
- */
4211
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
4212
- /**
4213
- * force it to be a number
4214
- */
4215
- if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
4216
- /**
4217
- * could have been passed as a number or boolean but we still want it as a string
4218
- */
4219
- if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
4220
- return propValue;
4221
- }
4222
- /**
4223
- * not sure exactly what type we want so no need to change to a different type
4224
- */
4225
- return propValue;
4226
- };
4227
- //#endregion
4228
- //#region src/runtime/set-value.ts
4229
- const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
4230
- const run = (inst) => {
4231
- let attrVal = val;
4232
- for (const serializer of cmpMeta.$serializers$[propName]) {
4233
- const [[methodName]] = Object.entries(serializer);
4234
- attrVal = inst[methodName](attrVal, propName);
4235
- }
4236
- hostRef.$serializerValues$.set(propName, attrVal);
4237
- };
4238
- if (instance) run(instance);
4239
- else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
4240
- };
4241
- const getValue = (ref, propName) => {
4242
- if (BUILD.signalBacking) {
4243
- const sig = getHostRef(ref)?.$signalValues$?.get(propName);
4244
- if (sig !== void 0) return sig.value;
4245
- }
4246
- return getHostRef(ref).$instanceValues$.get(propName);
4247
- };
4248
- const setValue = (ref, propName, newVal, cmpMeta) => {
4249
- const hostRef = getHostRef(ref);
4250
- if (BUILD.signalBacking) {
4251
- const sig = hostRef?.$signalValues$?.get(propName);
4252
- if (sig !== void 0) {
4253
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4254
- if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4255
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4256
- applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
4257
- }
4258
- if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
4259
- return;
4260
- }
4261
- }
4262
- if (!hostRef) {
4263
- if (BUILD.lazyLoad) throw new Error(BUILD.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
4264
- return;
4265
- }
4266
- if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
4267
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4268
- const oldVal = hostRef.$instanceValues$.get(propName);
4269
- const flags = hostRef.$flags$;
4270
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
4271
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4272
- const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4273
- if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4274
- hostRef.$instanceValues$.set(propName, newVal);
4275
- if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
4276
- if (BUILD.isDev) {
4277
- if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
4278
- else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
4279
- }
4280
- if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
4281
- const watchMethods = cmpMeta.$watchers$[propName];
4282
- if (watchMethods) watchMethods.map((watcher) => {
4283
- try {
4284
- const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
4285
- if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
4286
- if (BUILD.signalBacking && !hostRef.$signalValues$) return;
4287
- if (!instance) hostRef.$fetchedCbList$.push(() => {
4288
- hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
4289
- });
4290
- else instance[watchMethodName](newVal, oldVal, propName);
4291
- }
4292
- } catch (e) {
4293
- consoleError(e, elm);
4294
- }
4295
- });
4296
- }
4297
- if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
4298
- if (instance.componentShouldUpdate) {
4299
- const changes = hostRef.$queuedPropChanges$ ||= {};
4300
- changes[propName] = {
4301
- newVal,
4302
- oldVal: changes[propName]?.oldVal ?? oldVal
4303
- };
4304
- }
4305
- if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
4306
- }
4307
- }
4308
- };
4309
- //#endregion
4310
4354
  //#region src/runtime/proxy-component.ts
4311
4355
  /**
4312
4356
  * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
@@ -4439,7 +4483,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4439
4483
  plt.jmp(() => {
4440
4484
  const propName = attrNameToPropName.get(attrName);
4441
4485
  const hostRef = getHostRef(this);
4442
- if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
4486
+ if (BUILD.serializer && hostRef.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
4443
4487
  if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
4444
4488
  newValue = this[propName];
4445
4489
  delete this[propName];
@@ -4549,7 +4593,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4549
4593
  replayPendingSetterValues(hostRef, cmpMeta);
4550
4594
  }
4551
4595
  endNewInstance();
4552
- if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4596
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
4597
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4598
+ if (ancestorConnected) await ancestorConnected;
4599
+ }
4553
4600
  if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4554
4601
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4555
4602
  if (BUILD.asyncLoading) markFirstConnected(hostRef);
@@ -4950,8 +4997,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4950
4997
  }
4951
4998
  connectedCallback(this);
4952
4999
  if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4953
- await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4954
- if (!this.isConnected) return;
5000
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
5001
+ if (ancestorConnected) {
5002
+ await ancestorConnected;
5003
+ if (!this.isConnected) return;
5004
+ }
4955
5005
  }
4956
5006
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4957
5007
  if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
@@ -5099,7 +5149,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
5099
5149
  if (!hostRef) return;
5100
5150
  const i = deferredConnectedCallbacks.findIndex((host) => host === this);
5101
5151
  if (i > -1) deferredConnectedCallbacks.splice(i, 1);
5102
- if (hostRef?.$vnode$?.$elm$ instanceof Node && !hostRef.$vnode$.$elm$.isConnected) delete hostRef.$vnode$.$elm$;
5152
+ if (hostRef.$vnode$?.$elm$?.isConnected === false) delete hostRef.$vnode$.$elm$;
5103
5153
  });
5104
5154
  }
5105
5155
  componentOnReady() {