@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.
- package/dist/{client-BMtGBEQV.mjs → client-DkvdNuPu.mjs} +9 -9
- package/dist/compiler/browser.d.ts +23 -5
- package/dist/compiler/browser.js +99 -17
- package/dist/compiler/index.d.mts +2 -2
- package/dist/compiler/index.mjs +2 -2
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-C_Y38j4m.mjs → compiler-ChKFuRry.mjs} +326 -123
- package/dist/declarations/stencil-public-compiler.d.ts +25 -7
- package/dist/{index-CFiy6MZ3.d.mts → index-BxnfbT3a.d.mts} +25 -7
- package/dist/{index-CViiWNQ9.d.mts → index-xOwTL_5Z.d.mts} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-Bkq8vRnu.mjs → node-C59vQZNg.mjs} +1 -1
- package/dist/runtime/client/lazy.js +202 -159
- package/dist/runtime/client/runtime.js +202 -159
- package/dist/runtime/index.js +202 -159
- package/dist/runtime/server/index.mjs +202 -159
- package/dist/runtime/server/runner.mjs +82 -7
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.mjs +198 -158
- package/package.json +4 -4
|
@@ -1044,7 +1044,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1044
1044
|
return toReturn;
|
|
1045
1045
|
}
|
|
1046
1046
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
1047
|
-
return HostElementPrototype.__prepend(newChild);
|
|
1047
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
1048
1048
|
});
|
|
1049
1049
|
};
|
|
1050
1050
|
};
|
|
@@ -1713,7 +1713,7 @@ const attachStyles = (hostRef) => {
|
|
|
1713
1713
|
else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
|
|
1714
1714
|
else styleContainerNode = elm.getRootNode();
|
|
1715
1715
|
const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
|
|
1716
|
-
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
|
|
1716
|
+
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
|
|
1717
1717
|
elm["s-sc"] = scopeId;
|
|
1718
1718
|
elm.classList.add(scopeId + "-h");
|
|
1719
1719
|
}
|
|
@@ -1800,12 +1800,51 @@ const isComplexType = (o) => {
|
|
|
1800
1800
|
return o === "object" || o === "function";
|
|
1801
1801
|
};
|
|
1802
1802
|
//#endregion
|
|
1803
|
-
//#region src/runtime/
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1803
|
+
//#region src/runtime/parse-property-value.ts
|
|
1804
|
+
/**
|
|
1805
|
+
* Parse a new property value for a given property type.
|
|
1806
|
+
*
|
|
1807
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1808
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1809
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1810
|
+
* 2. the type stored from `propType`.
|
|
1811
|
+
*
|
|
1812
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1813
|
+
*
|
|
1814
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1815
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1816
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1817
|
+
* ```tsx
|
|
1818
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1819
|
+
* ```
|
|
1820
|
+
*
|
|
1821
|
+
* HTML prop values on the other hand, will always a string
|
|
1822
|
+
*
|
|
1823
|
+
* @param propValue the new value to coerce to some type
|
|
1824
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1825
|
+
* @returns the parsed/coerced value
|
|
1826
|
+
*/
|
|
1827
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1828
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1829
|
+
/**
|
|
1830
|
+
* ensure this value is of the correct prop type
|
|
1831
|
+
*/
|
|
1832
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
1833
|
+
/**
|
|
1834
|
+
* force it to be a number
|
|
1835
|
+
*/
|
|
1836
|
+
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
1837
|
+
/**
|
|
1838
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
1839
|
+
*/
|
|
1840
|
+
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
1841
|
+
return propValue;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
1845
|
+
*/
|
|
1846
|
+
return propValue;
|
|
1847
|
+
};
|
|
1809
1848
|
//#endregion
|
|
1810
1849
|
//#region src/runtime/event-emitter.ts
|
|
1811
1850
|
const createEvent = (ref, name, flags) => {
|
|
@@ -2869,24 +2908,24 @@ const markFirstConnected = (hostRef) => {
|
|
|
2869
2908
|
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2870
2909
|
};
|
|
2871
2910
|
/**
|
|
2872
|
-
*
|
|
2873
|
-
* Shared by the lazy ({@link initializeComponent})
|
|
2874
|
-
* `connectedCallback` paths so a component never
|
|
2875
|
-
* ancestor, regardless of load order.
|
|
2876
|
-
*
|
|
2877
|
-
*
|
|
2878
|
-
*
|
|
2911
|
+
* Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
|
|
2912
|
+
* completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
|
|
2913
|
+
* and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
|
|
2914
|
+
* connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
|
|
2915
|
+
* a returned promise, so a component whose ancestor is already connected carries on
|
|
2916
|
+
* synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
|
|
2917
|
+
* the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
|
|
2918
|
+
* tag may not be defined yet.
|
|
2879
2919
|
*
|
|
2880
2920
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2881
2921
|
* @param registry the registry the waiting component is defined in
|
|
2922
|
+
* @returns a promise to await, or `undefined` if there's nothing to wait for
|
|
2882
2923
|
*/
|
|
2883
|
-
const
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
}
|
|
2889
|
-
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2924
|
+
const whenAncestorConnected = (ancestorElm, registry) => {
|
|
2925
|
+
const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
|
|
2926
|
+
const ancestorHostRef = getHostRef(ancestorElm);
|
|
2927
|
+
if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
|
|
2928
|
+
return pendingConnect(ancestorHostRef);
|
|
2890
2929
|
};
|
|
2891
2930
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2892
2931
|
if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
@@ -2906,10 +2945,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2906
2945
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2907
2946
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2908
2947
|
if (isInitialLoad) {
|
|
2909
|
-
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2910
|
-
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2911
2948
|
queueMicrotask(() => {
|
|
2912
|
-
|
|
2949
|
+
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2950
|
+
if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
|
|
2951
|
+
else dispatch();
|
|
2913
2952
|
});
|
|
2914
2953
|
return;
|
|
2915
2954
|
}
|
|
@@ -3212,6 +3251,124 @@ const serverSideConnected = (elm) => {
|
|
|
3212
3251
|
}
|
|
3213
3252
|
};
|
|
3214
3253
|
//#endregion
|
|
3254
|
+
//#region src/runtime/set-value.ts
|
|
3255
|
+
/**
|
|
3256
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3257
|
+
* @param hostRef the component's host ref
|
|
3258
|
+
* @param propName the prop
|
|
3259
|
+
* @param val the prop's value
|
|
3260
|
+
* @returns the value to reflect
|
|
3261
|
+
*/
|
|
3262
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3263
|
+
/**
|
|
3264
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3265
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3266
|
+
* @param hostRef the component's host ref
|
|
3267
|
+
* @param cmpMeta the component's runtime metadata
|
|
3268
|
+
* @param elm the host element
|
|
3269
|
+
* @param propName the prop that changed
|
|
3270
|
+
* @param oldAttrVal the previously reflected value
|
|
3271
|
+
* @param newAttrVal the value to reflect
|
|
3272
|
+
*/
|
|
3273
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3274
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3275
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3276
|
+
if (!attrName) return;
|
|
3277
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3278
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3279
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3280
|
+
};
|
|
3281
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3282
|
+
const run = (inst) => {
|
|
3283
|
+
let attrVal = val;
|
|
3284
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3285
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3286
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3287
|
+
}
|
|
3288
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3289
|
+
};
|
|
3290
|
+
if (instance) run(instance);
|
|
3291
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3292
|
+
};
|
|
3293
|
+
const getValue = (ref, propName) => {
|
|
3294
|
+
if (BUILD.signalBacking) {
|
|
3295
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3296
|
+
if (sig !== void 0) return sig.value;
|
|
3297
|
+
}
|
|
3298
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3299
|
+
};
|
|
3300
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3301
|
+
const hostRef = getHostRef(ref);
|
|
3302
|
+
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3303
|
+
if (BUILD.signalBacking) {
|
|
3304
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3305
|
+
if (sig !== void 0) {
|
|
3306
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3307
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3308
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3309
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3310
|
+
}
|
|
3311
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
if (!hostRef) {
|
|
3316
|
+
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$}"`);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3320
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3321
|
+
const flags = hostRef.$flags$;
|
|
3322
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3323
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3324
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3325
|
+
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3326
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3327
|
+
const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3328
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3329
|
+
if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3330
|
+
if (BUILD.isDev) {
|
|
3331
|
+
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);
|
|
3332
|
+
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);
|
|
3333
|
+
}
|
|
3334
|
+
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
3335
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3336
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3337
|
+
try {
|
|
3338
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3339
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3340
|
+
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
3341
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3342
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3343
|
+
});
|
|
3344
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3345
|
+
}
|
|
3346
|
+
} catch (e) {
|
|
3347
|
+
consoleError(e, elm);
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3352
|
+
if (instance.componentShouldUpdate) {
|
|
3353
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3354
|
+
changes[propName] = {
|
|
3355
|
+
newVal,
|
|
3356
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
//#endregion
|
|
3364
|
+
//#region src/runtime/signals-core.ts
|
|
3365
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3366
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3367
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3368
|
+
function signal(value, options) {
|
|
3369
|
+
return getCore().signal(value, options);
|
|
3370
|
+
}
|
|
3371
|
+
//#endregion
|
|
3215
3372
|
//#region src/runtime/signals.ts
|
|
3216
3373
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3217
3374
|
/**
|
|
@@ -3256,6 +3413,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3256
3413
|
}
|
|
3257
3414
|
prevScheduleVal = newVal;
|
|
3258
3415
|
}));
|
|
3416
|
+
if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3417
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3418
|
+
disposers.push(effect(() => {
|
|
3419
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3420
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3421
|
+
prevAttrVal = attrVal;
|
|
3422
|
+
}));
|
|
3423
|
+
}
|
|
3259
3424
|
if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3260
3425
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3261
3426
|
let prevWatchVal = sig.peek();
|
|
@@ -3324,7 +3489,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3324
3489
|
* Modified for Stencil's compiler and vdom
|
|
3325
3490
|
*/
|
|
3326
3491
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3327
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3492
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3328
3493
|
let child = null;
|
|
3329
3494
|
let key = null;
|
|
3330
3495
|
let slotName = null;
|
|
@@ -3502,7 +3667,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3502
3667
|
let scopeId;
|
|
3503
3668
|
if (BUILD.scoped) {
|
|
3504
3669
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
3505
|
-
if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
|
|
3670
|
+
if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
|
|
3506
3671
|
scopeId = hostElm["s-sc"];
|
|
3507
3672
|
hostElm.classList.add(scopeId + "-h");
|
|
3508
3673
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
@@ -3798,7 +3963,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3798
3963
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
3799
3964
|
do {
|
|
3800
3965
|
const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
|
|
3801
|
-
if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3966
|
+
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)) {
|
|
3802
3967
|
slottedNode["s-sn"] = slotName;
|
|
3803
3968
|
group.push({
|
|
3804
3969
|
slot: slotNode,
|
|
@@ -4320,134 +4485,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4320
4485
|
return out;
|
|
4321
4486
|
};
|
|
4322
4487
|
//#endregion
|
|
4323
|
-
//#region src/runtime/parse-property-value.ts
|
|
4324
|
-
/**
|
|
4325
|
-
* Parse a new property value for a given property type.
|
|
4326
|
-
*
|
|
4327
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
4328
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
4329
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
4330
|
-
* 2. the type stored from `propType`.
|
|
4331
|
-
*
|
|
4332
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
4333
|
-
*
|
|
4334
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
4335
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
4336
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
4337
|
-
* ```tsx
|
|
4338
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
4339
|
-
* ```
|
|
4340
|
-
*
|
|
4341
|
-
* HTML prop values on the other hand, will always a string
|
|
4342
|
-
*
|
|
4343
|
-
* @param propValue the new value to coerce to some type
|
|
4344
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
4345
|
-
* @returns the parsed/coerced value
|
|
4346
|
-
*/
|
|
4347
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
4348
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
4349
|
-
/**
|
|
4350
|
-
* ensure this value is of the correct prop type
|
|
4351
|
-
*/
|
|
4352
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4353
|
-
/**
|
|
4354
|
-
* force it to be a number
|
|
4355
|
-
*/
|
|
4356
|
-
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
4357
|
-
/**
|
|
4358
|
-
* could have been passed as a number or boolean but we still want it as a string
|
|
4359
|
-
*/
|
|
4360
|
-
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
4361
|
-
return propValue;
|
|
4362
|
-
}
|
|
4363
|
-
/**
|
|
4364
|
-
* not sure exactly what type we want so no need to change to a different type
|
|
4365
|
-
*/
|
|
4366
|
-
return propValue;
|
|
4367
|
-
};
|
|
4368
|
-
//#endregion
|
|
4369
|
-
//#region src/runtime/set-value.ts
|
|
4370
|
-
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
4371
|
-
const run = (inst) => {
|
|
4372
|
-
let attrVal = val;
|
|
4373
|
-
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
4374
|
-
const [[methodName]] = Object.entries(serializer);
|
|
4375
|
-
attrVal = inst[methodName](attrVal, propName);
|
|
4376
|
-
}
|
|
4377
|
-
hostRef.$serializerValues$.set(propName, attrVal);
|
|
4378
|
-
};
|
|
4379
|
-
if (instance) run(instance);
|
|
4380
|
-
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
4381
|
-
};
|
|
4382
|
-
const getValue = (ref, propName) => {
|
|
4383
|
-
if (BUILD.signalBacking) {
|
|
4384
|
-
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
4385
|
-
if (sig !== void 0) return sig.value;
|
|
4386
|
-
}
|
|
4387
|
-
return getHostRef(ref).$instanceValues$.get(propName);
|
|
4388
|
-
};
|
|
4389
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
4390
|
-
const hostRef = getHostRef(ref);
|
|
4391
|
-
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
4392
|
-
if (BUILD.signalBacking) {
|
|
4393
|
-
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4394
|
-
if (sig !== void 0) {
|
|
4395
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4396
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4397
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4398
|
-
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
4399
|
-
}
|
|
4400
|
-
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
4401
|
-
return;
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
if (!hostRef) {
|
|
4405
|
-
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$}"`);
|
|
4406
|
-
return;
|
|
4407
|
-
}
|
|
4408
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4409
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4410
|
-
const flags = hostRef.$flags$;
|
|
4411
|
-
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4412
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4413
|
-
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4414
|
-
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4415
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
|
4416
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
4417
|
-
if (BUILD.isDev) {
|
|
4418
|
-
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);
|
|
4419
|
-
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);
|
|
4420
|
-
}
|
|
4421
|
-
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
4422
|
-
const watchMethods = cmpMeta.$watchers$[propName];
|
|
4423
|
-
if (watchMethods) watchMethods.map((watcher) => {
|
|
4424
|
-
try {
|
|
4425
|
-
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4426
|
-
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
4427
|
-
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
4428
|
-
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
4429
|
-
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
4430
|
-
});
|
|
4431
|
-
else instance[watchMethodName](newVal, oldVal, propName);
|
|
4432
|
-
}
|
|
4433
|
-
} catch (e) {
|
|
4434
|
-
consoleError(e, elm);
|
|
4435
|
-
}
|
|
4436
|
-
});
|
|
4437
|
-
}
|
|
4438
|
-
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4439
|
-
if (instance.componentShouldUpdate) {
|
|
4440
|
-
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4441
|
-
changes[propName] = {
|
|
4442
|
-
newVal,
|
|
4443
|
-
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4444
|
-
};
|
|
4445
|
-
}
|
|
4446
|
-
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4447
|
-
}
|
|
4448
|
-
}
|
|
4449
|
-
};
|
|
4450
|
-
//#endregion
|
|
4451
4488
|
//#region src/runtime/proxy-component.ts
|
|
4452
4489
|
/**
|
|
4453
4490
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
@@ -4690,7 +4727,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4690
4727
|
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4691
4728
|
}
|
|
4692
4729
|
endNewInstance();
|
|
4693
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$)
|
|
4730
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
|
|
4731
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4732
|
+
if (ancestorConnected) await ancestorConnected;
|
|
4733
|
+
}
|
|
4694
4734
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4695
4735
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4696
4736
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -5091,8 +5131,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
5091
5131
|
}
|
|
5092
5132
|
connectedCallback(this);
|
|
5093
5133
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
5094
|
-
|
|
5095
|
-
if (
|
|
5134
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
5135
|
+
if (ancestorConnected) {
|
|
5136
|
+
await ancestorConnected;
|
|
5137
|
+
if (!this.isConnected) return;
|
|
5138
|
+
}
|
|
5096
5139
|
}
|
|
5097
5140
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
5098
5141
|
if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
|