@stencil/core 5.0.0-rc.1 → 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.
@@ -1038,7 +1038,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
1038
1038
  return toReturn;
1039
1039
  }
1040
1040
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
1041
- return HostElementPrototype.__prepend(newChild);
1041
+ return HostElementPrototype.__prepend.call(this, newChild);
1042
1042
  });
1043
1043
  };
1044
1044
  };
@@ -1707,7 +1707,7 @@ const attachStyles = (hostRef) => {
1707
1707
  else if (BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
1708
1708
  else styleContainerNode = elm.getRootNode();
1709
1709
  const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
1710
- if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1710
+ if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
1711
1711
  elm["s-sc"] = scopeId;
1712
1712
  elm.classList.add(scopeId + "-h");
1713
1713
  }
@@ -1794,12 +1794,51 @@ const isComplexType = (o) => {
1794
1794
  return o === "object" || o === "function";
1795
1795
  };
1796
1796
  //#endregion
1797
- //#region src/runtime/signals-core.ts
1798
- const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1799
- const effect = (fn, options) => getCore().effect(fn, options);
1800
- function signal(value, options) {
1801
- return getCore().signal(value, options);
1802
- }
1797
+ //#region src/runtime/parse-property-value.ts
1798
+ /**
1799
+ * Parse a new property value for a given property type.
1800
+ *
1801
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1802
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1803
+ * 1. `any`, the type given to `propValue` in the function signature
1804
+ * 2. the type stored from `propType`.
1805
+ *
1806
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1807
+ *
1808
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1809
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1810
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1811
+ * ```tsx
1812
+ * <my-cmp prop-val={0}></my-cmp>
1813
+ * ```
1814
+ *
1815
+ * HTML prop values on the other hand, will always a string
1816
+ *
1817
+ * @param propValue the new value to coerce to some type
1818
+ * @param propType the type of the prop, expressed as a binary number
1819
+ * @returns the parsed/coerced value
1820
+ */
1821
+ const parsePropertyValue = (propValue, propType) => {
1822
+ if (propValue != null && !isComplexType(propValue)) {
1823
+ /**
1824
+ * ensure this value is of the correct prop type
1825
+ */
1826
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
1827
+ /**
1828
+ * force it to be a number
1829
+ */
1830
+ if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1831
+ /**
1832
+ * could have been passed as a number or boolean but we still want it as a string
1833
+ */
1834
+ if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
1835
+ return propValue;
1836
+ }
1837
+ /**
1838
+ * not sure exactly what type we want so no need to change to a different type
1839
+ */
1840
+ return propValue;
1841
+ };
1803
1842
  //#endregion
1804
1843
  //#region src/runtime/event-emitter.ts
1805
1844
  const createEvent = (ref, name, flags) => {
@@ -2863,24 +2902,24 @@ const markFirstConnected = (hostRef) => {
2863
2902
  hostRef.$onFirstConnectResolve$ = void 0;
2864
2903
  };
2865
2904
  /**
2866
- * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2867
- * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2868
- * `connectedCallback` paths so a component never connects before its nearest Stencil
2869
- * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2870
- * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2871
- * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2872
- * autoloader, where the ancestor tag may not be defined yet.
2905
+ * Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
2906
+ * completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
2907
+ * and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
2908
+ * connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
2909
+ * a returned promise, so a component whose ancestor is already connected carries on
2910
+ * synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
2911
+ * the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
2912
+ * tag may not be defined yet.
2873
2913
  *
2874
2914
  * @param ancestorElm the nearest Stencil ancestor element
2875
2915
  * @param registry the registry the waiting component is defined in
2916
+ * @returns a promise to await, or `undefined` if there's nothing to wait for
2876
2917
  */
2877
- const awaitAncestorConnected = async (ancestorElm, registry) => {
2878
- let ancestorHostRef = getHostRef(ancestorElm);
2879
- if (!BUILD$1.lazyLoad && !ancestorHostRef) {
2880
- await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2881
- ancestorHostRef = getHostRef(ancestorElm);
2882
- }
2883
- if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2918
+ const whenAncestorConnected = (ancestorElm, registry) => {
2919
+ const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
2920
+ const ancestorHostRef = getHostRef(ancestorElm);
2921
+ if (!BUILD$1.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
2922
+ return pendingConnect(ancestorHostRef);
2884
2923
  };
2885
2924
  const attachToAncestor = (hostRef, ancestorComponent) => {
2886
2925
  if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
@@ -2900,10 +2939,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2900
2939
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2901
2940
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2902
2941
  if (isInitialLoad) {
2903
- const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2904
- if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2905
2942
  queueMicrotask(() => {
2906
- dispatch();
2943
+ const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2944
+ if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
2945
+ else dispatch();
2907
2946
  });
2908
2947
  return;
2909
2948
  }
@@ -3206,6 +3245,124 @@ const serverSideConnected = (elm) => {
3206
3245
  }
3207
3246
  };
3208
3247
  //#endregion
3248
+ //#region src/runtime/set-value.ts
3249
+ /**
3250
+ * The value a reflected prop writes to its attribute: the serialized value if it has one.
3251
+ * @param hostRef the component's host ref
3252
+ * @param propName the prop
3253
+ * @param val the prop's value
3254
+ * @returns the value to reflect
3255
+ */
3256
+ const getReflectedValue = (hostRef, propName, val) => BUILD$1.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
3257
+ /**
3258
+ * Write a reflected prop's attribute as soon as the prop changes, like native elements do,
3259
+ * so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
3260
+ * @param hostRef the component's host ref
3261
+ * @param cmpMeta the component's runtime metadata
3262
+ * @param elm the host element
3263
+ * @param propName the prop that changed
3264
+ * @param oldAttrVal the previously reflected value
3265
+ * @param newAttrVal the value to reflect
3266
+ */
3267
+ const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
3268
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
3269
+ const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
3270
+ if (!attrName) return;
3271
+ if (BUILD$1.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
3272
+ setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
3273
+ if (BUILD$1.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
3274
+ };
3275
+ const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
3276
+ const run = (inst) => {
3277
+ let attrVal = val;
3278
+ for (const serializer of cmpMeta.$serializers$[propName]) {
3279
+ const [[methodName]] = Object.entries(serializer);
3280
+ attrVal = inst[methodName](attrVal, propName);
3281
+ }
3282
+ hostRef.$serializerValues$.set(propName, attrVal);
3283
+ };
3284
+ if (instance) run(instance);
3285
+ else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
3286
+ };
3287
+ const getValue = (ref, propName) => {
3288
+ if (BUILD$1.signalBacking) {
3289
+ const sig = getHostRef(ref)?.$signalValues$?.get(propName);
3290
+ if (sig !== void 0) return sig.value;
3291
+ }
3292
+ return getHostRef(ref).$instanceValues$.get(propName);
3293
+ };
3294
+ const setValue = (ref, propName, newVal, cmpMeta) => {
3295
+ const hostRef = getHostRef(ref);
3296
+ if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
3297
+ if (BUILD$1.signalBacking) {
3298
+ const sig = hostRef?.$signalValues$?.get(propName);
3299
+ if (sig !== void 0) {
3300
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3301
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3302
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3303
+ applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
3304
+ }
3305
+ if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
3306
+ return;
3307
+ }
3308
+ }
3309
+ if (!hostRef) {
3310
+ if (BUILD$1.lazyLoad) throw new Error(BUILD$1.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$}"`);
3311
+ return;
3312
+ }
3313
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3314
+ const oldVal = hostRef.$instanceValues$.get(propName);
3315
+ const flags = hostRef.$flags$;
3316
+ const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
3317
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3318
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3319
+ if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3320
+ hostRef.$instanceValues$.set(propName, newVal);
3321
+ const oldAttrVal = BUILD$1.reflect && getReflectedValue(hostRef, propName, oldVal);
3322
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
3323
+ if (BUILD$1.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
3324
+ if (BUILD$1.isDev) {
3325
+ 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);
3326
+ 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);
3327
+ }
3328
+ if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
3329
+ const watchMethods = cmpMeta.$watchers$[propName];
3330
+ if (watchMethods) watchMethods.map((watcher) => {
3331
+ try {
3332
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3333
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
3334
+ if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
3335
+ if (!instance) hostRef.$fetchedCbList$.push(() => {
3336
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3337
+ });
3338
+ else instance[watchMethodName](newVal, oldVal, propName);
3339
+ }
3340
+ } catch (e) {
3341
+ consoleError(e, elm);
3342
+ }
3343
+ });
3344
+ }
3345
+ if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
3346
+ if (instance.componentShouldUpdate) {
3347
+ const changes = hostRef.$queuedPropChanges$ ||= {};
3348
+ changes[propName] = {
3349
+ newVal,
3350
+ oldVal: changes[propName]?.oldVal ?? oldVal
3351
+ };
3352
+ }
3353
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3354
+ }
3355
+ }
3356
+ };
3357
+ //#endregion
3358
+ //#region src/runtime/signals-core.ts
3359
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
3360
+ const effect = (fn, options) => getCore().effect(fn, options);
3361
+ const untracked = (fn) => getCore().untracked(fn);
3362
+ function signal(value, options) {
3363
+ return getCore().signal(value, options);
3364
+ }
3365
+ //#endregion
3209
3366
  //#region src/runtime/signals.ts
3210
3367
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
3211
3368
  /**
@@ -3250,6 +3407,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3250
3407
  }
3251
3408
  prevScheduleVal = newVal;
3252
3409
  }));
3410
+ if (BUILD$1.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
3411
+ let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
3412
+ disposers.push(effect(() => {
3413
+ const attrVal = getReflectedValue(hostRef, memberName, sig.value);
3414
+ untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
3415
+ prevAttrVal = attrVal;
3416
+ }));
3417
+ }
3253
3418
  if (BUILD$1.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
3254
3419
  const watchMethods = cmpMeta.$watchers$[memberName];
3255
3420
  let prevWatchVal = sig.peek();
@@ -3318,7 +3483,7 @@ const initializeEffects = (elm, hostRef) => {
3318
3483
  * Modified for Stencil's compiler and vdom
3319
3484
  */
3320
3485
  const h = (nodeName, vnodeData, ...children) => {
3321
- if (typeof nodeName === "string") nodeName = transformTag(nodeName);
3486
+ if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
3322
3487
  let child = null;
3323
3488
  let key = null;
3324
3489
  let slotName = null;
@@ -3496,7 +3661,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3496
3661
  let scopeId;
3497
3662
  if (BUILD$1.scoped) {
3498
3663
  const cmpMeta = hostRef.$cmpMeta$;
3499
- if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
3664
+ if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
3500
3665
  scopeId = hostElm["s-sc"];
3501
3666
  hostElm.classList.add(scopeId + "-h");
3502
3667
  } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
@@ -3792,7 +3957,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
3792
3957
  if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
3793
3958
  do {
3794
3959
  const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
3795
- if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
3960
+ 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)) {
3796
3961
  slottedNode["s-sn"] = slotName;
3797
3962
  group.push({
3798
3963
  slot: slotNode,
@@ -4314,134 +4479,6 @@ const normalizeWatchers = (raw) => {
4314
4479
  return out;
4315
4480
  };
4316
4481
  //#endregion
4317
- //#region src/runtime/parse-property-value.ts
4318
- /**
4319
- * Parse a new property value for a given property type.
4320
- *
4321
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
4322
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
4323
- * 1. `any`, the type given to `propValue` in the function signature
4324
- * 2. the type stored from `propType`.
4325
- *
4326
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
4327
- *
4328
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
4329
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
4330
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
4331
- * ```tsx
4332
- * <my-cmp prop-val={0}></my-cmp>
4333
- * ```
4334
- *
4335
- * HTML prop values on the other hand, will always a string
4336
- *
4337
- * @param propValue the new value to coerce to some type
4338
- * @param propType the type of the prop, expressed as a binary number
4339
- * @returns the parsed/coerced value
4340
- */
4341
- const parsePropertyValue = (propValue, propType) => {
4342
- if (propValue != null && !isComplexType(propValue)) {
4343
- /**
4344
- * ensure this value is of the correct prop type
4345
- */
4346
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
4347
- /**
4348
- * force it to be a number
4349
- */
4350
- if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
4351
- /**
4352
- * could have been passed as a number or boolean but we still want it as a string
4353
- */
4354
- if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
4355
- return propValue;
4356
- }
4357
- /**
4358
- * not sure exactly what type we want so no need to change to a different type
4359
- */
4360
- return propValue;
4361
- };
4362
- //#endregion
4363
- //#region src/runtime/set-value.ts
4364
- const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
4365
- const run = (inst) => {
4366
- let attrVal = val;
4367
- for (const serializer of cmpMeta.$serializers$[propName]) {
4368
- const [[methodName]] = Object.entries(serializer);
4369
- attrVal = inst[methodName](attrVal, propName);
4370
- }
4371
- hostRef.$serializerValues$.set(propName, attrVal);
4372
- };
4373
- if (instance) run(instance);
4374
- else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
4375
- };
4376
- const getValue = (ref, propName) => {
4377
- if (BUILD$1.signalBacking) {
4378
- const sig = getHostRef(ref)?.$signalValues$?.get(propName);
4379
- if (sig !== void 0) return sig.value;
4380
- }
4381
- return getHostRef(ref).$instanceValues$.get(propName);
4382
- };
4383
- const setValue = (ref, propName, newVal, cmpMeta) => {
4384
- const hostRef = getHostRef(ref);
4385
- if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
4386
- if (BUILD$1.signalBacking) {
4387
- const sig = hostRef?.$signalValues$?.get(propName);
4388
- if (sig !== void 0) {
4389
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4390
- if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4391
- const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
4392
- applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
4393
- }
4394
- if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
4395
- return;
4396
- }
4397
- }
4398
- if (!hostRef) {
4399
- if (BUILD$1.lazyLoad) throw new Error(BUILD$1.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$}"`);
4400
- return;
4401
- }
4402
- const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
4403
- const oldVal = hostRef.$instanceValues$.get(propName);
4404
- const flags = hostRef.$flags$;
4405
- const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
4406
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4407
- const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4408
- if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4409
- hostRef.$instanceValues$.set(propName, newVal);
4410
- if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
4411
- if (BUILD$1.isDev) {
4412
- 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);
4413
- 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);
4414
- }
4415
- if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
4416
- const watchMethods = cmpMeta.$watchers$[propName];
4417
- if (watchMethods) watchMethods.map((watcher) => {
4418
- try {
4419
- const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
4420
- if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
4421
- if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
4422
- if (!instance) hostRef.$fetchedCbList$.push(() => {
4423
- hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
4424
- });
4425
- else instance[watchMethodName](newVal, oldVal, propName);
4426
- }
4427
- } catch (e) {
4428
- consoleError(e, elm);
4429
- }
4430
- });
4431
- }
4432
- if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
4433
- if (instance.componentShouldUpdate) {
4434
- const changes = hostRef.$queuedPropChanges$ ||= {};
4435
- changes[propName] = {
4436
- newVal,
4437
- oldVal: changes[propName]?.oldVal ?? oldVal
4438
- };
4439
- }
4440
- if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
4441
- }
4442
- }
4443
- };
4444
- //#endregion
4445
4482
  //#region src/runtime/proxy-component.ts
4446
4483
  /**
4447
4484
  * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
@@ -4684,7 +4721,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4684
4721
  replayPendingSetterValues(hostRef, cmpMeta);
4685
4722
  }
4686
4723
  endNewInstance();
4687
- if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4724
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) {
4725
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4726
+ if (ancestorConnected) await ancestorConnected;
4727
+ }
4688
4728
  if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4689
4729
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4690
4730
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
@@ -5085,8 +5125,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
5085
5125
  }
5086
5126
  connectedCallback(this);
5087
5127
  if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
5088
- await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
5089
- if (!this.isConnected) return;
5128
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
5129
+ if (ancestorConnected) {
5130
+ await ancestorConnected;
5131
+ if (!this.isConnected) return;
5132
+ }
5090
5133
  }
5091
5134
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
5092
5135
  if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);