@stencil/core 5.0.0-rc.1 → 5.0.0-rc.11

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.
@@ -232,7 +232,11 @@ const HOST_FLAGS = {
232
232
  * coming from the runtime's own reflection aren't applied back to the prop.
233
233
  */
234
234
  isReflecting: 16384,
235
- devOnRender: 4096,
235
+ /**
236
+ * Set by `forceUpdate()` so the next update renders even if `componentShouldUpdate` returns `false`.
237
+ */
238
+ isUpdateForced: 4096,
239
+ devOnRender: 32768,
236
240
  devOnDidLoad: 8192
237
241
  };
238
242
  const CF_scopedCssEncapsulation = 2;
@@ -1038,7 +1042,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
1038
1042
  return toReturn;
1039
1043
  }
1040
1044
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
1041
- return HostElementPrototype.__prepend(newChild);
1045
+ return HostElementPrototype.__prepend.call(this, newChild);
1042
1046
  });
1043
1047
  };
1044
1048
  };
@@ -1707,7 +1711,7 @@ const attachStyles = (hostRef) => {
1707
1711
  else if (BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
1708
1712
  else styleContainerNode = elm.getRootNode();
1709
1713
  const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
1710
- if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1714
+ if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
1711
1715
  elm["s-sc"] = scopeId;
1712
1716
  elm.classList.add(scopeId + "-h");
1713
1717
  }
@@ -1794,12 +1798,51 @@ const isComplexType = (o) => {
1794
1798
  return o === "object" || o === "function";
1795
1799
  };
1796
1800
  //#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
- }
1801
+ //#region src/runtime/parse-property-value.ts
1802
+ /**
1803
+ * Parse a new property value for a given property type.
1804
+ *
1805
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1806
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1807
+ * 1. `any`, the type given to `propValue` in the function signature
1808
+ * 2. the type stored from `propType`.
1809
+ *
1810
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1811
+ *
1812
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1813
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1814
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1815
+ * ```tsx
1816
+ * <my-cmp prop-val={0}></my-cmp>
1817
+ * ```
1818
+ *
1819
+ * HTML prop values on the other hand, will always a string
1820
+ *
1821
+ * @param propValue the new value to coerce to some type
1822
+ * @param propType the type of the prop, expressed as a binary number
1823
+ * @returns the parsed/coerced value
1824
+ */
1825
+ const parsePropertyValue = (propValue, propType) => {
1826
+ if (propValue != null && !isComplexType(propValue)) {
1827
+ /**
1828
+ * ensure this value is of the correct prop type
1829
+ */
1830
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
1831
+ /**
1832
+ * force it to be a number
1833
+ */
1834
+ if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1835
+ /**
1836
+ * could have been passed as a number or boolean but we still want it as a string
1837
+ */
1838
+ if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
1839
+ return propValue;
1840
+ }
1841
+ /**
1842
+ * not sure exactly what type we want so no need to change to a different type
1843
+ */
1844
+ return propValue;
1845
+ };
1803
1846
  //#endregion
1804
1847
  //#region src/runtime/event-emitter.ts
1805
1848
  const createEvent = (ref, name, flags) => {
@@ -2863,24 +2906,24 @@ const markFirstConnected = (hostRef) => {
2863
2906
  hostRef.$onFirstConnectResolve$ = void 0;
2864
2907
  };
2865
2908
  /**
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.
2909
+ * Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
2910
+ * completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
2911
+ * and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
2912
+ * connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
2913
+ * a returned promise, so a component whose ancestor is already connected carries on
2914
+ * synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
2915
+ * the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
2916
+ * tag may not be defined yet.
2873
2917
  *
2874
2918
  * @param ancestorElm the nearest Stencil ancestor element
2875
2919
  * @param registry the registry the waiting component is defined in
2920
+ * @returns a promise to await, or `undefined` if there's nothing to wait for
2876
2921
  */
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);
2922
+ const whenAncestorConnected = (ancestorElm, registry) => {
2923
+ const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
2924
+ const ancestorHostRef = getHostRef(ancestorElm);
2925
+ if (!BUILD$1.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
2926
+ return pendingConnect(ancestorHostRef);
2884
2927
  };
2885
2928
  const attachToAncestor = (hostRef, ancestorComponent) => {
2886
2929
  if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
@@ -2891,6 +2934,17 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
2891
2934
  if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2892
2935
  }
2893
2936
  };
2937
+ /**
2938
+ * Release the ancestor waiting on this component's update (registered by {@link attachToAncestor}).
2939
+ *
2940
+ * @param hostRef the component's host reference
2941
+ */
2942
+ const resolveAncestorWait = (hostRef) => {
2943
+ if (BUILD$1.asyncLoading && hostRef.$onRenderResolve$) {
2944
+ hostRef.$onRenderResolve$();
2945
+ hostRef.$onRenderResolve$ = void 0;
2946
+ }
2947
+ };
2894
2948
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2895
2949
  if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2896
2950
  if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
@@ -2900,10 +2954,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2900
2954
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2901
2955
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2902
2956
  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
2957
  queueMicrotask(() => {
2906
- dispatch();
2958
+ const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2959
+ if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
2960
+ else dispatch();
2907
2961
  });
2908
2962
  return;
2909
2963
  }
@@ -2956,8 +3010,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2956
3010
  if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
2957
3011
  const changes = hostRef.$queuedPropChanges$;
2958
3012
  hostRef.$queuedPropChanges$ = void 0;
2959
- if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
3013
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false && !(hostRef.$flags$ & HOST_FLAGS.isUpdateForced)) {
2960
3014
  hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
3015
+ resolveAncestorWait(hostRef);
2961
3016
  return;
2962
3017
  }
2963
3018
  }
@@ -3083,7 +3138,10 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
3083
3138
  * method, so we can call the method immediately. If not, check before calling it.
3084
3139
  */
3085
3140
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
3086
- if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
3141
+ if (updatable) {
3142
+ hostRef.$flags$ &= ~(HOST_FLAGS.isQueuedForUpdate | HOST_FLAGS.isUpdateForced);
3143
+ hostRef.$queuedPropChanges$ = void 0;
3144
+ }
3087
3145
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
3088
3146
  if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
3089
3147
  if (BUILD$1.vdomRender || BUILD$1.reflect) {
@@ -3134,10 +3192,7 @@ const postUpdateComponent = (hostRef) => {
3134
3192
  }
3135
3193
  if (BUILD$1.method && BUILD$1.lazyLoad) hostRef.$onInstanceResolve$(elm);
3136
3194
  if (BUILD$1.asyncLoading) {
3137
- if (hostRef.$onRenderResolve$) {
3138
- hostRef.$onRenderResolve$();
3139
- hostRef.$onRenderResolve$ = void 0;
3140
- }
3195
+ resolveAncestorWait(hostRef);
3141
3196
  if (hostRef.$flags$ & HOST_FLAGS.needsRerender) nextTick(() => scheduleUpdate(hostRef, false));
3142
3197
  hostRef.$flags$ &= ~(HOST_FLAGS.isWaitingForChildren | HOST_FLAGS.needsRerender);
3143
3198
  }
@@ -3146,7 +3201,10 @@ const forceUpdate = (ref) => {
3146
3201
  if (BUILD$1.updatable && (Build.isBrowser || Build.isTesting)) {
3147
3202
  const hostRef = getHostRef(ref);
3148
3203
  const isConnected = hostRef?.$hostElement$?.isConnected;
3149
- if (isConnected && (hostRef.$flags$ & (HOST_FLAGS.hasRendered | HOST_FLAGS.isQueuedForUpdate)) === HOST_FLAGS.hasRendered) scheduleUpdate(hostRef, false);
3204
+ if (isConnected && hostRef.$flags$ & HOST_FLAGS.hasRendered) {
3205
+ hostRef.$flags$ |= HOST_FLAGS.isUpdateForced;
3206
+ if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3207
+ }
3150
3208
  return isConnected;
3151
3209
  }
3152
3210
  return false;
@@ -3206,6 +3264,121 @@ const serverSideConnected = (elm) => {
3206
3264
  }
3207
3265
  };
3208
3266
  //#endregion
3267
+ //#region src/runtime/set-value.ts
3268
+ /**
3269
+ * The value a reflected prop writes to its attribute: the serialized value if it has one.
3270
+ * @param hostRef the component's host ref
3271
+ * @param propName the prop
3272
+ * @param val the prop's value
3273
+ * @returns the value to reflect
3274
+ */
3275
+ const getReflectedValue = (hostRef, propName, val) => BUILD$1.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
3276
+ /**
3277
+ * Write a reflected prop's attribute as soon as the prop changes, like native elements do,
3278
+ * so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
3279
+ * @param hostRef the component's host ref
3280
+ * @param cmpMeta the component's runtime metadata
3281
+ * @param elm the host element
3282
+ * @param propName the prop that changed
3283
+ * @param oldAttrVal the previously reflected value
3284
+ * @param newAttrVal the value to reflect
3285
+ */
3286
+ const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
3287
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
3288
+ const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
3289
+ if (!attrName) return;
3290
+ if (BUILD$1.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
3291
+ setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
3292
+ if (BUILD$1.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
3293
+ };
3294
+ const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
3295
+ const run = (inst) => {
3296
+ let attrVal = val;
3297
+ for (const serializer of cmpMeta.$serializers$[propName]) {
3298
+ const [[methodName]] = Object.entries(serializer);
3299
+ attrVal = inst[methodName](attrVal, propName);
3300
+ }
3301
+ hostRef.$serializerValues$.set(propName, attrVal);
3302
+ };
3303
+ if (instance) run(instance);
3304
+ else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
3305
+ };
3306
+ const getValue = (ref, propName) => {
3307
+ if (BUILD$1.signalBacking) {
3308
+ const sig = getHostRef(ref)?.$signalValues$?.get(propName);
3309
+ if (sig !== void 0) return sig.value;
3310
+ }
3311
+ return getHostRef(ref).$instanceValues$.get(propName);
3312
+ };
3313
+ const setValue = (ref, propName, newVal, cmpMeta) => {
3314
+ const hostRef = getHostRef(ref);
3315
+ if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
3316
+ if (BUILD$1.signalBacking) {
3317
+ const sig = hostRef?.$signalValues$?.get(propName);
3318
+ if (sig !== void 0) {
3319
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3320
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3321
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3322
+ applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
3323
+ }
3324
+ if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
3325
+ return;
3326
+ }
3327
+ }
3328
+ if (!hostRef) {
3329
+ 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$}"`);
3330
+ return;
3331
+ }
3332
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3333
+ const oldVal = hostRef.$instanceValues$.get(propName);
3334
+ const flags = hostRef.$flags$;
3335
+ const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
3336
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3337
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3338
+ if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3339
+ hostRef.$instanceValues$.set(propName, newVal);
3340
+ const oldAttrVal = BUILD$1.reflect && getReflectedValue(hostRef, propName, oldVal);
3341
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
3342
+ if (BUILD$1.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
3343
+ if (BUILD$1.isDev) {
3344
+ 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);
3345
+ 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);
3346
+ }
3347
+ if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
3348
+ const watchMethods = cmpMeta.$watchers$[propName];
3349
+ if (watchMethods) watchMethods.map((watcher) => {
3350
+ try {
3351
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3352
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
3353
+ if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
3354
+ if (!instance) hostRef.$fetchedCbList$.push(() => {
3355
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3356
+ });
3357
+ else instance[watchMethodName](newVal, oldVal, propName);
3358
+ }
3359
+ } catch (e) {
3360
+ consoleError(e, elm);
3361
+ }
3362
+ });
3363
+ }
3364
+ if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
3365
+ if (instance.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[propName] ||= {
3366
+ oldVal,
3367
+ newVal
3368
+ }).newVal = newVal;
3369
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3370
+ }
3371
+ }
3372
+ };
3373
+ //#endregion
3374
+ //#region src/runtime/signals-core.ts
3375
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
3376
+ const effect = (fn, options) => getCore().effect(fn, options);
3377
+ const untracked = (fn) => getCore().untracked(fn);
3378
+ function signal(value, options) {
3379
+ return getCore().signal(value, options);
3380
+ }
3381
+ //#endregion
3209
3382
  //#region src/runtime/signals.ts
3210
3383
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
3211
3384
  /**
@@ -3239,17 +3412,22 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3239
3412
  disposers.push(effect(() => {
3240
3413
  const newVal = sig.value;
3241
3414
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
3242
- if (instance?.componentShouldUpdate) {
3243
- const changes = hostRef.$queuedPropChanges$ ||= {};
3244
- changes[memberName] = {
3245
- newVal,
3246
- oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
3247
- };
3248
- }
3415
+ if (instance?.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[memberName] ||= {
3416
+ oldVal: prevScheduleVal,
3417
+ newVal
3418
+ }).newVal = newVal;
3249
3419
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3250
3420
  }
3251
3421
  prevScheduleVal = newVal;
3252
3422
  }));
3423
+ if (BUILD$1.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
3424
+ let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
3425
+ disposers.push(effect(() => {
3426
+ const attrVal = getReflectedValue(hostRef, memberName, sig.value);
3427
+ untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
3428
+ prevAttrVal = attrVal;
3429
+ }));
3430
+ }
3253
3431
  if (BUILD$1.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
3254
3432
  const watchMethods = cmpMeta.$watchers$[memberName];
3255
3433
  let prevWatchVal = sig.peek();
@@ -3318,7 +3496,7 @@ const initializeEffects = (elm, hostRef) => {
3318
3496
  * Modified for Stencil's compiler and vdom
3319
3497
  */
3320
3498
  const h = (nodeName, vnodeData, ...children) => {
3321
- if (typeof nodeName === "string") nodeName = transformTag(nodeName);
3499
+ if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
3322
3500
  let child = null;
3323
3501
  let key = null;
3324
3502
  let slotName = null;
@@ -3496,7 +3674,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3496
3674
  let scopeId;
3497
3675
  if (BUILD$1.scoped) {
3498
3676
  const cmpMeta = hostRef.$cmpMeta$;
3499
- if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
3677
+ if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
3500
3678
  scopeId = hostElm["s-sc"];
3501
3679
  hostElm.classList.add(scopeId + "-h");
3502
3680
  } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
@@ -3792,7 +3970,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
3792
3970
  if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
3793
3971
  do {
3794
3972
  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)) {
3973
+ 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
3974
  slottedNode["s-sn"] = slotName;
3797
3975
  group.push({
3798
3976
  slot: slotNode,
@@ -4314,134 +4492,6 @@ const normalizeWatchers = (raw) => {
4314
4492
  return out;
4315
4493
  };
4316
4494
  //#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
4495
  //#region src/runtime/proxy-component.ts
4446
4496
  /**
4447
4497
  * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
@@ -4684,7 +4734,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4684
4734
  replayPendingSetterValues(hostRef, cmpMeta);
4685
4735
  }
4686
4736
  endNewInstance();
4687
- if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4737
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) {
4738
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4739
+ if (ancestorConnected) await ancestorConnected;
4740
+ }
4688
4741
  if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4689
4742
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4690
4743
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
@@ -4746,10 +4799,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4746
4799
  else schedule();
4747
4800
  } catch (e) {
4748
4801
  consoleError(e, elm);
4749
- if (BUILD$1.asyncLoading && hostRef.$onRenderResolve$) {
4750
- hostRef.$onRenderResolve$();
4751
- hostRef.$onRenderResolve$ = void 0;
4752
- }
4802
+ resolveAncestorWait(hostRef);
4753
4803
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4754
4804
  if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4755
4805
  }
@@ -5085,8 +5135,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
5085
5135
  }
5086
5136
  connectedCallback(this);
5087
5137
  if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
5088
- await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
5089
- if (!this.isConnected) return;
5138
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
5139
+ if (ancestorConnected) {
5140
+ await ancestorConnected;
5141
+ if (!this.isConnected) return;
5142
+ }
5090
5143
  }
5091
5144
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
5092
5145
  if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);