@lwc/engine-core 6.1.1 → 6.2.1
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/framework/api.d.ts +9 -0
- package/dist/framework/base-lightning-element.d.ts +4 -2
- package/dist/framework/check-version-mismatch.d.ts +2 -0
- package/dist/framework/component.d.ts +3 -0
- package/dist/framework/decorators/api.d.ts +4 -1
- package/dist/framework/decorators/register.d.ts +2 -0
- package/dist/framework/decorators/track.d.ts +4 -1
- package/dist/framework/decorators/wire.d.ts +3 -1
- package/dist/framework/def.d.ts +2 -0
- package/dist/framework/get-component-constructor.d.ts +1 -0
- package/dist/framework/membrane.d.ts +1 -0
- package/dist/framework/modules/static-parts.d.ts +10 -6
- package/dist/framework/mutation-tracker.d.ts +2 -1
- package/dist/framework/readonly.d.ts +1 -0
- package/dist/framework/reporting.d.ts +10 -6
- package/dist/framework/secure-template.d.ts +5 -0
- package/dist/framework/stylesheet.d.ts +5 -2
- package/dist/framework/vm.d.ts +34 -17
- package/dist/index.cjs.js +266 -85
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +267 -86
- package/dist/index.js.map +1 -1
- package/dist/libs/mutation-tracker/index.d.ts +1 -0
- package/dist/libs/signal-tracker/index.d.ts +5 -0
- package/dist/shared/circular-module-dependencies.d.ts +1 -1
- package/package.json +5 -4
package/dist/index.cjs.js
CHANGED
|
@@ -27,8 +27,7 @@ let enabled$1 = false;
|
|
|
27
27
|
const reportingControl = {
|
|
28
28
|
/**
|
|
29
29
|
* Attach a new reporting control (aka dispatcher).
|
|
30
|
-
*
|
|
31
|
-
* @param dispatcher - reporting control
|
|
30
|
+
* @param dispatcher reporting control
|
|
32
31
|
*/
|
|
33
32
|
attachDispatcher(dispatcher) {
|
|
34
33
|
enabled$1 = true;
|
|
@@ -71,7 +70,7 @@ function onReportingEnabled(callback) {
|
|
|
71
70
|
/**
|
|
72
71
|
* Report to the current dispatcher, if there is one.
|
|
73
72
|
* @param reportingEventId
|
|
74
|
-
* @param payload
|
|
73
|
+
* @param payload data to report
|
|
75
74
|
*/
|
|
76
75
|
function report(reportingEventId, payload) {
|
|
77
76
|
if (enabled$1) {
|
|
@@ -236,6 +235,7 @@ class ReactiveObserver {
|
|
|
236
235
|
}
|
|
237
236
|
observe(job) {
|
|
238
237
|
const inceptionReactiveRecord = currentReactiveObserver;
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
239
239
|
currentReactiveObserver = this;
|
|
240
240
|
let error;
|
|
241
241
|
try {
|
|
@@ -285,6 +285,80 @@ class ReactiveObserver {
|
|
|
285
285
|
// we keep track of observing records where the observing record was added to so we can do some clean up later on
|
|
286
286
|
shared.ArrayPush.call(this.listeners, reactiveObservers);
|
|
287
287
|
}
|
|
288
|
+
isObserving() {
|
|
289
|
+
return currentReactiveObserver === this;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/*
|
|
294
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
295
|
+
* All rights reserved.
|
|
296
|
+
* SPDX-License-Identifier: MIT
|
|
297
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
298
|
+
*/
|
|
299
|
+
/**
|
|
300
|
+
* This map keeps track of objects to signals. There is an assumption that the signal is strongly referenced
|
|
301
|
+
* on the object which allows the SignalTracker to be garbage collected along with the object.
|
|
302
|
+
*/
|
|
303
|
+
const TargetToSignalTrackerMap = new WeakMap();
|
|
304
|
+
function getSignalTracker(target) {
|
|
305
|
+
let signalTracker = TargetToSignalTrackerMap.get(target);
|
|
306
|
+
if (shared.isUndefined(signalTracker)) {
|
|
307
|
+
signalTracker = new SignalTracker();
|
|
308
|
+
TargetToSignalTrackerMap.set(target, signalTracker);
|
|
309
|
+
}
|
|
310
|
+
return signalTracker;
|
|
311
|
+
}
|
|
312
|
+
function subscribeToSignal(target, signal, update) {
|
|
313
|
+
const signalTracker = getSignalTracker(target);
|
|
314
|
+
if (shared.isFalse(signalTracker.seen(signal))) {
|
|
315
|
+
signalTracker.subscribeToSignal(signal, update);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function unsubscribeFromSignals(target) {
|
|
319
|
+
if (TargetToSignalTrackerMap.has(target)) {
|
|
320
|
+
const signalTracker = getSignalTracker(target);
|
|
321
|
+
signalTracker.unsubscribeFromSignals();
|
|
322
|
+
signalTracker.reset();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* This class is used to keep track of the signals associated to a given object.
|
|
327
|
+
* It is used to prevent the LWC engine from subscribing duplicate callbacks multiple times
|
|
328
|
+
* to the same signal. Additionally, it keeps track of all signal unsubscribe callbacks, handles invoking
|
|
329
|
+
* them when necessary and discarding them.
|
|
330
|
+
*/
|
|
331
|
+
class SignalTracker {
|
|
332
|
+
constructor() {
|
|
333
|
+
this.signalToUnsubscribeMap = new Map();
|
|
334
|
+
}
|
|
335
|
+
seen(signal) {
|
|
336
|
+
return this.signalToUnsubscribeMap.has(signal);
|
|
337
|
+
}
|
|
338
|
+
subscribeToSignal(signal, update) {
|
|
339
|
+
try {
|
|
340
|
+
const unsubscribe = signal.subscribe(update);
|
|
341
|
+
if (shared.isFunction(unsubscribe)) {
|
|
342
|
+
// TODO [#3978]: Evaluate how we should handle the case when unsubscribe is not a function.
|
|
343
|
+
// Long term we should throw an error or log a warning.
|
|
344
|
+
this.signalToUnsubscribeMap.set(signal, unsubscribe);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
logWarnOnce(`Attempted to subscribe to an object that has the shape of a signal but received the following error: ${err?.stack ?? err}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
unsubscribeFromSignals() {
|
|
352
|
+
try {
|
|
353
|
+
this.signalToUnsubscribeMap.forEach((unsubscribe) => unsubscribe());
|
|
354
|
+
}
|
|
355
|
+
catch (err) {
|
|
356
|
+
logWarnOnce(`Attempted to call a signal's unsubscribe callback but received the following error: ${err?.stack ?? err}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
reset() {
|
|
360
|
+
this.signalToUnsubscribeMap.clear();
|
|
361
|
+
}
|
|
288
362
|
}
|
|
289
363
|
|
|
290
364
|
/*
|
|
@@ -306,10 +380,26 @@ function componentValueMutated(vm, key) {
|
|
|
306
380
|
valueMutated(vm.component, key);
|
|
307
381
|
}
|
|
308
382
|
}
|
|
309
|
-
function componentValueObserved(vm, key) {
|
|
383
|
+
function componentValueObserved(vm, key, target = {}) {
|
|
384
|
+
const { component, tro } = vm;
|
|
310
385
|
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
311
386
|
if (process.env.IS_BROWSER) {
|
|
312
|
-
valueObserved(
|
|
387
|
+
valueObserved(component, key);
|
|
388
|
+
}
|
|
389
|
+
// The portion of reactivity that's exposed to signals is to subscribe a callback to re-render the VM (templates).
|
|
390
|
+
// We check check the following to ensure re-render is subscribed at the correct time.
|
|
391
|
+
// 1. The template is currently being rendered (there is a template reactive observer)
|
|
392
|
+
// 2. There was a call to a getter to access the signal (happens during vnode generation)
|
|
393
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS &&
|
|
394
|
+
shared.isObject(target) &&
|
|
395
|
+
!shared.isNull(target) &&
|
|
396
|
+
'value' in target &&
|
|
397
|
+
'subscribe' in target &&
|
|
398
|
+
shared.isFunction(target.subscribe) &&
|
|
399
|
+
// Only subscribe if a template is being rendered by the engine
|
|
400
|
+
tro.isObserving()) {
|
|
401
|
+
// Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
|
|
402
|
+
subscribeToSignal(component, target, tro.notify.bind(tro));
|
|
313
403
|
}
|
|
314
404
|
}
|
|
315
405
|
function createReactiveObserver(callback) {
|
|
@@ -346,6 +436,7 @@ function addCallbackToNextTick(callback) {
|
|
|
346
436
|
}
|
|
347
437
|
}
|
|
348
438
|
if (nextTickCallbackQueue.length === 0) {
|
|
439
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
349
440
|
Promise.resolve().then(flushCallbackQueue);
|
|
350
441
|
}
|
|
351
442
|
shared.ArrayPush.call(nextTickCallbackQueue, callback);
|
|
@@ -427,7 +518,11 @@ function applyTemporaryCompilerV5SlotFix(data) {
|
|
|
427
518
|
if (!shared.isUndefined(attrs)) {
|
|
428
519
|
const { slot } = attrs;
|
|
429
520
|
if (!shared.isUndefined(slot) && !shared.isNull(slot)) {
|
|
430
|
-
return
|
|
521
|
+
return {
|
|
522
|
+
...data,
|
|
523
|
+
attrs: cloneAndOmitKey(attrs, 'slot'),
|
|
524
|
+
slotAssignment: String(slot),
|
|
525
|
+
};
|
|
431
526
|
}
|
|
432
527
|
}
|
|
433
528
|
return data;
|
|
@@ -441,15 +536,20 @@ function applyTemporaryCompilerV5SlotFix(data) {
|
|
|
441
536
|
*/
|
|
442
537
|
function resolveCircularModuleDependency(fn) {
|
|
443
538
|
const module = fn();
|
|
444
|
-
return
|
|
539
|
+
return module?.__esModule ? module.default : module;
|
|
445
540
|
}
|
|
446
541
|
function isCircularModuleDependency(obj) {
|
|
447
542
|
return shared.isFunction(obj) && shared.hasOwnProperty.call(obj, '__circular__');
|
|
448
543
|
}
|
|
449
544
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
545
|
+
/*
|
|
546
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
547
|
+
* All rights reserved.
|
|
548
|
+
* SPDX-License-Identifier: MIT
|
|
549
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
550
|
+
*/
|
|
551
|
+
const instrumentDef = globalThis.__lwc_instrument_cmp_def ?? shared.noop;
|
|
552
|
+
const instrumentInstance = globalThis.__lwc_instrument_cmp_instance ?? shared.noop;
|
|
453
553
|
|
|
454
554
|
/*
|
|
455
555
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1333,6 +1433,7 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1333
1433
|
* EXPERIMENTAL: This function implements an unwrap mechanism that
|
|
1334
1434
|
* works for observable membrane objects. This API is subject to
|
|
1335
1435
|
* change or being removed.
|
|
1436
|
+
* @param value
|
|
1336
1437
|
*/
|
|
1337
1438
|
function unwrap(value) {
|
|
1338
1439
|
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
@@ -1401,6 +1502,7 @@ function initGlobalStylesheet() {
|
|
|
1401
1502
|
}
|
|
1402
1503
|
return promise;
|
|
1403
1504
|
});
|
|
1505
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1404
1506
|
Promise.all(promises).then((stylesheetTexts) => {
|
|
1405
1507
|
// When replaceSync() is called, the entire contents of the constructable stylesheet are replaced
|
|
1406
1508
|
// with the copied+concatenated styles. This means that any shadow root's adoptedStyleSheets that
|
|
@@ -1445,6 +1547,8 @@ function applyShadowMigrateMode(shadowRoot) {
|
|
|
1445
1547
|
* that a Custom Element can support (including AOM properties), which
|
|
1446
1548
|
* determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
|
|
1447
1549
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1550
|
+
* @param propName
|
|
1551
|
+
* @param descriptor
|
|
1448
1552
|
*/
|
|
1449
1553
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1450
1554
|
const { get, set, enumerable, configurable } = descriptor;
|
|
@@ -1494,7 +1598,7 @@ const refsCache = new WeakMap();
|
|
|
1494
1598
|
/**
|
|
1495
1599
|
* This class is the base class for any LWC element.
|
|
1496
1600
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
1497
|
-
|
|
1601
|
+
*/
|
|
1498
1602
|
// @ts-ignore
|
|
1499
1603
|
const LightningElement = function () {
|
|
1500
1604
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
@@ -1512,7 +1616,6 @@ const LightningElement = function () {
|
|
|
1512
1616
|
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1513
1617
|
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1514
1618
|
}
|
|
1515
|
-
const component = this;
|
|
1516
1619
|
shared.setPrototypeOf(elm, bridge.prototype);
|
|
1517
1620
|
vm.component = this;
|
|
1518
1621
|
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
@@ -1527,7 +1630,7 @@ const LightningElement = function () {
|
|
|
1527
1630
|
}
|
|
1528
1631
|
markLockerLiveObject(this);
|
|
1529
1632
|
// Linking elm, shadow root and component with the VM.
|
|
1530
|
-
associateVM(
|
|
1633
|
+
associateVM(this, vm);
|
|
1531
1634
|
associateVM(elm, vm);
|
|
1532
1635
|
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1533
1636
|
vm.renderRoot = doAttachShadow(vm);
|
|
@@ -1951,8 +2054,9 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1951
2054
|
return {
|
|
1952
2055
|
get() {
|
|
1953
2056
|
const vm = getAssociatedVM(this);
|
|
1954
|
-
|
|
1955
|
-
|
|
2057
|
+
const val = vm.cmpFields[key];
|
|
2058
|
+
componentValueObserved(vm, key, val);
|
|
2059
|
+
return val;
|
|
1956
2060
|
},
|
|
1957
2061
|
set(newValue) {
|
|
1958
2062
|
const vm = getAssociatedVM(this);
|
|
@@ -2063,6 +2167,7 @@ function createConfigWatcher(component, configCallback, callbackWhenConfigIsRead
|
|
|
2063
2167
|
if (hasPendingConfig === false) {
|
|
2064
2168
|
hasPendingConfig = true;
|
|
2065
2169
|
// collect new config in the micro-task
|
|
2170
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2066
2171
|
Promise.resolve().then(() => {
|
|
2067
2172
|
hasPendingConfig = false;
|
|
2068
2173
|
// resetting current reactive params
|
|
@@ -2205,6 +2310,7 @@ function installWireAdapters(vm) {
|
|
|
2205
2310
|
connector.connect();
|
|
2206
2311
|
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2207
2312
|
if (hasDynamicParams) {
|
|
2313
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2208
2314
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
2209
2315
|
return;
|
|
2210
2316
|
}
|
|
@@ -2256,8 +2362,9 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2256
2362
|
}
|
|
2257
2363
|
return;
|
|
2258
2364
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2365
|
+
const val = vm.cmpProps[key];
|
|
2366
|
+
componentValueObserved(vm, key, val);
|
|
2367
|
+
return val;
|
|
2261
2368
|
},
|
|
2262
2369
|
set(newValue) {
|
|
2263
2370
|
const vm = getAssociatedVM(this);
|
|
@@ -2330,8 +2437,9 @@ function internalTrackDecorator(key) {
|
|
|
2330
2437
|
return {
|
|
2331
2438
|
get() {
|
|
2332
2439
|
const vm = getAssociatedVM(this);
|
|
2333
|
-
|
|
2334
|
-
|
|
2440
|
+
const val = vm.cmpFields[key];
|
|
2441
|
+
componentValueObserved(vm, key, val);
|
|
2442
|
+
return val;
|
|
2335
2443
|
},
|
|
2336
2444
|
set(newValue) {
|
|
2337
2445
|
const vm = getAssociatedVM(this);
|
|
@@ -2359,9 +2467,11 @@ function internalTrackDecorator(key) {
|
|
|
2359
2467
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2360
2468
|
*/
|
|
2361
2469
|
/**
|
|
2362
|
-
* @wire decorator
|
|
2470
|
+
* The @wire decorator wires fields and methods to a wire adapter in
|
|
2363
2471
|
* LWC Components. This function implements the internals of this
|
|
2364
2472
|
* decorator.
|
|
2473
|
+
* @param _adapter
|
|
2474
|
+
* @param _config
|
|
2365
2475
|
*/
|
|
2366
2476
|
function wire(_adapter, _config) {
|
|
2367
2477
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2472,6 +2582,8 @@ function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
|
|
|
2472
2582
|
/**
|
|
2473
2583
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2474
2584
|
* will prevent this function from being imported by user-land code.
|
|
2585
|
+
* @param Ctor
|
|
2586
|
+
* @param meta
|
|
2475
2587
|
*/
|
|
2476
2588
|
function registerDecorators(Ctor, meta) {
|
|
2477
2589
|
const proto = Ctor.prototype;
|
|
@@ -2660,6 +2772,7 @@ function isTemplateRegistered(tpl) {
|
|
|
2660
2772
|
/**
|
|
2661
2773
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2662
2774
|
* will prevent this function from being imported by userland code.
|
|
2775
|
+
* @param tpl
|
|
2663
2776
|
*/
|
|
2664
2777
|
function registerTemplate(tpl) {
|
|
2665
2778
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2673,6 +2786,10 @@ function registerTemplate(tpl) {
|
|
|
2673
2786
|
/**
|
|
2674
2787
|
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
2675
2788
|
* libraries to sanitize vulnerable attributes.
|
|
2789
|
+
* @param tagName
|
|
2790
|
+
* @param namespaceUri
|
|
2791
|
+
* @param attrName
|
|
2792
|
+
* @param attrValue
|
|
2676
2793
|
*/
|
|
2677
2794
|
function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
2678
2795
|
// locker-service patches this function during runtime to sanitize vulnerable attributes. When
|
|
@@ -3205,6 +3322,14 @@ function createComponentDef(Ctor) {
|
|
|
3205
3322
|
let shadowSupportMode = superDef.shadowSupportMode;
|
|
3206
3323
|
if (!shared.isUndefined(ctorShadowSupportMode)) {
|
|
3207
3324
|
shadowSupportMode = ctorShadowSupportMode;
|
|
3325
|
+
if (isReportingEnabled() &&
|
|
3326
|
+
(shadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
|
|
3327
|
+
shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
|
|
3328
|
+
report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
|
|
3329
|
+
tagName: Ctor.name,
|
|
3330
|
+
mode: shadowSupportMode,
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3208
3333
|
}
|
|
3209
3334
|
let renderMode = superDef.renderMode;
|
|
3210
3335
|
if (!shared.isUndefined(ctorRenderMode)) {
|
|
@@ -3250,6 +3375,7 @@ function createComponentDef(Ctor) {
|
|
|
3250
3375
|
/**
|
|
3251
3376
|
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
3252
3377
|
* subject to change or being removed.
|
|
3378
|
+
* @param ctor
|
|
3253
3379
|
*/
|
|
3254
3380
|
function isComponentConstructor(ctor) {
|
|
3255
3381
|
if (!shared.isFunction(ctor)) {
|
|
@@ -3323,6 +3449,7 @@ const lightingElementDef = {
|
|
|
3323
3449
|
/**
|
|
3324
3450
|
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
3325
3451
|
* subject to change or being removed.
|
|
3452
|
+
* @param Ctor
|
|
3326
3453
|
*/
|
|
3327
3454
|
function getComponentDef(Ctor) {
|
|
3328
3455
|
const def = getComponentInternalDef(Ctor);
|
|
@@ -3519,12 +3646,14 @@ function getNearestShadowComponent(vm) {
|
|
|
3519
3646
|
* If the component that is currently being rendered uses scoped styles,
|
|
3520
3647
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3521
3648
|
* it returns null.
|
|
3649
|
+
* @param owner
|
|
3650
|
+
* @param legacy
|
|
3522
3651
|
*/
|
|
3523
3652
|
// TODO [#3733]: remove support for legacy scope tokens
|
|
3524
3653
|
function getScopeTokenClass(owner, legacy) {
|
|
3525
3654
|
const { cmpTemplate, context } = owner;
|
|
3526
3655
|
return ((context.hasScopedStyles &&
|
|
3527
|
-
(legacy ? cmpTemplate
|
|
3656
|
+
(legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken)) ||
|
|
3528
3657
|
null);
|
|
3529
3658
|
}
|
|
3530
3659
|
/**
|
|
@@ -3532,6 +3661,7 @@ function getScopeTokenClass(owner, legacy) {
|
|
|
3532
3661
|
* exists. Otherwise it returns null.
|
|
3533
3662
|
*
|
|
3534
3663
|
* A host style token is applied to the component if scoped styles are used.
|
|
3664
|
+
* @param vnode
|
|
3535
3665
|
*/
|
|
3536
3666
|
function getStylesheetTokenHost(vnode) {
|
|
3537
3667
|
const { template } = getComponentInternalDef(vnode.ctor);
|
|
@@ -3651,7 +3781,7 @@ function patchAttributes(oldVnode, vnode, renderer) {
|
|
|
3651
3781
|
}
|
|
3652
3782
|
function patchSlotAssignment(oldVnode, vnode, renderer) {
|
|
3653
3783
|
const { slotAssignment } = vnode;
|
|
3654
|
-
if (
|
|
3784
|
+
if (oldVnode?.slotAssignment === slotAssignment) {
|
|
3655
3785
|
return;
|
|
3656
3786
|
}
|
|
3657
3787
|
const { elm } = vnode;
|
|
@@ -3728,6 +3858,8 @@ function getMapFromClassName(className) {
|
|
|
3728
3858
|
return EmptyObject;
|
|
3729
3859
|
}
|
|
3730
3860
|
// computed class names must be string
|
|
3861
|
+
// This will throw if className is a symbol or null-prototype object
|
|
3862
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
3731
3863
|
className = shared.isString(className) ? className : className + '';
|
|
3732
3864
|
let map = classNameToClassMap[className];
|
|
3733
3865
|
if (map) {
|
|
@@ -3808,9 +3940,8 @@ function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
|
3808
3940
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3809
3941
|
*/
|
|
3810
3942
|
function applyEventListeners(vnode, renderer) {
|
|
3811
|
-
var _a;
|
|
3812
3943
|
const { elm } = vnode;
|
|
3813
|
-
const on =
|
|
3944
|
+
const on = vnode.data?.on;
|
|
3814
3945
|
if (shared.isUndefined(on)) {
|
|
3815
3946
|
return;
|
|
3816
3947
|
}
|
|
@@ -3939,13 +4070,11 @@ function traverseAndSetElements(root, parts, renderer) {
|
|
|
3939
4070
|
}
|
|
3940
4071
|
/**
|
|
3941
4072
|
* Given an array of static parts, do all the mounting required for these parts.
|
|
3942
|
-
*
|
|
3943
|
-
* @param
|
|
3944
|
-
* @param
|
|
3945
|
-
* @param renderer - the renderer to use
|
|
3946
|
-
* @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
|
|
4073
|
+
* @param root the root element
|
|
4074
|
+
* @param vnode the parent VStatic
|
|
4075
|
+
* @param renderer the renderer to use
|
|
3947
4076
|
*/
|
|
3948
|
-
function
|
|
4077
|
+
function mountStaticParts(root, vnode, renderer) {
|
|
3949
4078
|
// On the server, we don't support ref (because it relies on renderedCallback), nor do we
|
|
3950
4079
|
// support event listeners (no interactivity), so traversing parts makes no sense
|
|
3951
4080
|
if (!process.env.IS_BROWSER) {
|
|
@@ -3955,20 +4084,45 @@ function applyStaticParts(root, vnode, renderer, mount) {
|
|
|
3955
4084
|
if (shared.isUndefined(parts)) {
|
|
3956
4085
|
return;
|
|
3957
4086
|
}
|
|
3958
|
-
// This adds `part.elm` to each `part`. We have to do this on every mount
|
|
4087
|
+
// This adds `part.elm` to each `part`. We have to do this on every mount because the `parts`
|
|
3959
4088
|
// array is recreated from scratch every time, so each `part.elm` is now undefined.
|
|
3960
|
-
// TODO [#3800]: avoid calling traverseAndSetElements on every re-render
|
|
3961
4089
|
traverseAndSetElements(root, parts, renderer);
|
|
3962
4090
|
// Currently only event listeners and refs are supported for static vnodes
|
|
3963
4091
|
for (const part of parts) {
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
applyEventListeners(part, renderer);
|
|
3967
|
-
}
|
|
4092
|
+
// Event listeners only need to be applied once when mounting
|
|
4093
|
+
applyEventListeners(part, renderer);
|
|
3968
4094
|
// Refs must be updated after every render due to refVNodes getting reset before every render
|
|
3969
4095
|
applyRefs(part, owner);
|
|
3970
4096
|
}
|
|
3971
4097
|
}
|
|
4098
|
+
/**
|
|
4099
|
+
* Mounts elements to the newly generated VStatic node
|
|
4100
|
+
* @param n1 the previous VStatic vnode
|
|
4101
|
+
* @param n2 the current VStatic vnode
|
|
4102
|
+
*/
|
|
4103
|
+
function patchStaticParts(n1, n2) {
|
|
4104
|
+
// On the server, we don't support ref (because it relies on renderedCallback), nor do we
|
|
4105
|
+
// support event listeners (no interactivity), so traversing parts makes no sense
|
|
4106
|
+
if (!process.env.IS_BROWSER) {
|
|
4107
|
+
return;
|
|
4108
|
+
}
|
|
4109
|
+
const { parts: currParts, owner: currPartsOwner } = n2;
|
|
4110
|
+
if (shared.isUndefined(currParts)) {
|
|
4111
|
+
return;
|
|
4112
|
+
}
|
|
4113
|
+
const { parts: prevParts } = n1;
|
|
4114
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4115
|
+
shared.assert.isTrue(currParts.length === prevParts?.length, 'Expected static parts to be the same for the same element. This is an error with the LWC framework itself.');
|
|
4116
|
+
}
|
|
4117
|
+
for (let i = 0; i < currParts.length; i++) {
|
|
4118
|
+
const part = currParts[i];
|
|
4119
|
+
// Patch only occurs if the vnode is newly generated, which means the part.elm is always undefined
|
|
4120
|
+
// Since the vnode and elements are the same we can safely assume that prevParts[i].elm is defined.
|
|
4121
|
+
part.elm = prevParts[i].elm;
|
|
4122
|
+
// Refs must be updated after every render due to refVNodes getting reset before every render
|
|
4123
|
+
applyRefs(part, currPartsOwner);
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
3972
4126
|
|
|
3973
4127
|
/*
|
|
3974
4128
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3985,7 +4139,6 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3985
4139
|
}
|
|
3986
4140
|
}
|
|
3987
4141
|
function patch(n1, n2, parent, renderer) {
|
|
3988
|
-
var _a, _b;
|
|
3989
4142
|
if (n1 === n2) {
|
|
3990
4143
|
return;
|
|
3991
4144
|
}
|
|
@@ -4018,15 +4171,14 @@ function patch(n1, n2, parent, renderer) {
|
|
|
4018
4171
|
patchFragment(n1, n2, parent, renderer);
|
|
4019
4172
|
break;
|
|
4020
4173
|
case 2 /* VNodeType.Element */:
|
|
4021
|
-
patchElement(n1, n2,
|
|
4174
|
+
patchElement(n1, n2, n2.data.renderer ?? renderer);
|
|
4022
4175
|
break;
|
|
4023
4176
|
case 3 /* VNodeType.CustomElement */:
|
|
4024
|
-
patchCustomElement(n1, n2, parent,
|
|
4177
|
+
patchCustomElement(n1, n2, parent, n2.data.renderer ?? renderer);
|
|
4025
4178
|
break;
|
|
4026
4179
|
}
|
|
4027
4180
|
}
|
|
4028
4181
|
function mount(node, parent, renderer, anchor) {
|
|
4029
|
-
var _a, _b;
|
|
4030
4182
|
switch (node.type) {
|
|
4031
4183
|
case 0 /* VNodeType.Text */:
|
|
4032
4184
|
// VText has no special capability, fallback to the owner's renderer
|
|
@@ -4045,11 +4197,11 @@ function mount(node, parent, renderer, anchor) {
|
|
|
4045
4197
|
break;
|
|
4046
4198
|
case 2 /* VNodeType.Element */:
|
|
4047
4199
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4048
|
-
mountElement(node, parent, anchor,
|
|
4200
|
+
mountElement(node, parent, anchor, node.data.renderer ?? renderer);
|
|
4049
4201
|
break;
|
|
4050
4202
|
case 3 /* VNodeType.CustomElement */:
|
|
4051
4203
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4052
|
-
mountCustomElement(node, parent, anchor,
|
|
4204
|
+
mountCustomElement(node, parent, anchor, node.data.renderer ?? renderer);
|
|
4053
4205
|
break;
|
|
4054
4206
|
}
|
|
4055
4207
|
}
|
|
@@ -4111,11 +4263,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
4111
4263
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
4112
4264
|
}
|
|
4113
4265
|
function patchStatic(n1, n2, renderer) {
|
|
4114
|
-
|
|
4266
|
+
n2.elm = n1.elm;
|
|
4115
4267
|
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4116
4268
|
patchSlotAssignment(n1, n2, renderer);
|
|
4117
4269
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
|
4118
|
-
|
|
4270
|
+
patchStaticParts(n1, n2);
|
|
4119
4271
|
}
|
|
4120
4272
|
function patchElement(n1, n2, renderer) {
|
|
4121
4273
|
const elm = (n2.elm = n1.elm);
|
|
@@ -4138,7 +4290,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
4138
4290
|
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4139
4291
|
patchSlotAssignment(null, vnode, renderer);
|
|
4140
4292
|
insertNode(elm, parent, anchor, renderer);
|
|
4141
|
-
|
|
4293
|
+
mountStaticParts(elm, vnode, renderer);
|
|
4142
4294
|
}
|
|
4143
4295
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
4144
4296
|
const { sel, owner, ctor } = vnode;
|
|
@@ -4400,17 +4552,15 @@ function applyStyleScoping(elm, owner, renderer) {
|
|
|
4400
4552
|
}
|
|
4401
4553
|
}
|
|
4402
4554
|
function applyDomManual(elm, vnode) {
|
|
4403
|
-
var _a;
|
|
4404
4555
|
const { owner, data: { context }, } = vnode;
|
|
4405
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ &&
|
|
4556
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === "manual" /* LwcDomMode.Manual */) {
|
|
4406
4557
|
elm.$domManual$ = true;
|
|
4407
4558
|
}
|
|
4408
4559
|
}
|
|
4409
4560
|
function applyElementRestrictions(elm, vnode) {
|
|
4410
|
-
var _a, _b;
|
|
4411
4561
|
if (process.env.NODE_ENV !== 'production') {
|
|
4412
4562
|
const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4413
|
-
const isPortal = vnode.type === 2 /* VNodeType.Element */ &&
|
|
4563
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === "manual" /* LwcDomMode.Manual */;
|
|
4414
4564
|
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4415
4565
|
patchElementWithRestrictions(elm, {
|
|
4416
4566
|
isPortal,
|
|
@@ -4463,6 +4613,7 @@ function allocateChildren(vnode, vm) {
|
|
|
4463
4613
|
* With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
|
|
4464
4614
|
*
|
|
4465
4615
|
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4616
|
+
* @param children
|
|
4466
4617
|
*/
|
|
4467
4618
|
function flattenFragmentsInChildren(children) {
|
|
4468
4619
|
const flattenedChildren = [];
|
|
@@ -4517,7 +4668,6 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4517
4668
|
return vm;
|
|
4518
4669
|
}
|
|
4519
4670
|
function allocateInSlot(vm, children, owner) {
|
|
4520
|
-
var _a;
|
|
4521
4671
|
const { cmpSlots: { slotAssignments: oldSlotsMapping }, } = vm;
|
|
4522
4672
|
const cmpSlotsMapping = shared.create(null);
|
|
4523
4673
|
// Collect all slots into cmpSlotsMapping
|
|
@@ -4528,7 +4678,7 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4528
4678
|
}
|
|
4529
4679
|
let slotName = '';
|
|
4530
4680
|
if (isVBaseElement(vnode) || isVStatic(vnode)) {
|
|
4531
|
-
slotName =
|
|
4681
|
+
slotName = vnode.slotAssignment ?? '';
|
|
4532
4682
|
}
|
|
4533
4683
|
else if (isVScopedSlotFragment(vnode)) {
|
|
4534
4684
|
slotName = vnode.slotName;
|
|
@@ -4537,6 +4687,7 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4537
4687
|
// but elm.setAttribute('slot', Symbol(1)) is an error.
|
|
4538
4688
|
// the following line also throws same error for symbols
|
|
4539
4689
|
// Similar for Object.create(null)
|
|
4690
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
4540
4691
|
const normalizedSlotName = '' + slotName;
|
|
4541
4692
|
const vnodes = (cmpSlotsMapping[normalizedSlotName] =
|
|
4542
4693
|
cmpSlotsMapping[normalizedSlotName] || []);
|
|
@@ -4934,11 +5085,11 @@ function s(slotName, data, children, slotset) {
|
|
|
4934
5085
|
// to the vnode because the current way the diffing algo works, it will replace the original reference
|
|
4935
5086
|
// to the host element with a new one. This means the new element will be mounted and immediately unmounted.
|
|
4936
5087
|
// Creating a copy of the vnode to preserve a reference to the previous host element.
|
|
4937
|
-
clonedVNode =
|
|
5088
|
+
clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
|
|
4938
5089
|
}
|
|
4939
5090
|
// If the slot content is standard type, the content is static, no additional
|
|
4940
5091
|
// processing needed on the vnode
|
|
4941
|
-
shared.ArrayPush.call(newChildren, clonedVNode
|
|
5092
|
+
shared.ArrayPush.call(newChildren, clonedVNode ?? vnode);
|
|
4942
5093
|
}
|
|
4943
5094
|
}
|
|
4944
5095
|
}
|
|
@@ -5076,6 +5227,7 @@ function i(iterable, factory) {
|
|
|
5076
5227
|
}
|
|
5077
5228
|
/**
|
|
5078
5229
|
* [f]lattening
|
|
5230
|
+
* @param items
|
|
5079
5231
|
*/
|
|
5080
5232
|
function f(items) {
|
|
5081
5233
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5192,6 +5344,10 @@ function fid(url) {
|
|
|
5192
5344
|
* [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
5193
5345
|
*
|
|
5194
5346
|
* TODO [#3331]: remove usage of lwc:dynamic in 246
|
|
5347
|
+
* @param sel
|
|
5348
|
+
* @param Ctor
|
|
5349
|
+
* @param data
|
|
5350
|
+
* @param children
|
|
5195
5351
|
*/
|
|
5196
5352
|
function ddc(sel, Ctor, data, children = EmptyArray) {
|
|
5197
5353
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5210,6 +5366,9 @@ function ddc(sel, Ctor, data, children = EmptyArray) {
|
|
|
5210
5366
|
}
|
|
5211
5367
|
/**
|
|
5212
5368
|
* [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
|
|
5369
|
+
* @param Ctor
|
|
5370
|
+
* @param data
|
|
5371
|
+
* @param children
|
|
5213
5372
|
*/
|
|
5214
5373
|
function dc(Ctor, data, children = EmptyArray) {
|
|
5215
5374
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5237,13 +5396,13 @@ function dc(Ctor, data, children = EmptyArray) {
|
|
|
5237
5396
|
* to the engine that a particular collection of children must be diffed using the slow
|
|
5238
5397
|
* algo based on keys due to the nature of the list. E.g.:
|
|
5239
5398
|
*
|
|
5240
|
-
*
|
|
5241
|
-
*
|
|
5242
|
-
*
|
|
5243
|
-
*
|
|
5244
|
-
*
|
|
5245
|
-
*
|
|
5246
|
-
*
|
|
5399
|
+
* - slot element's children: the content of the slot has to be dynamic when in synthetic
|
|
5400
|
+
* shadow mode because the `vnode.children` might be the slotted
|
|
5401
|
+
* content vs default content, in which case the size and the
|
|
5402
|
+
* keys are not matching.
|
|
5403
|
+
* - children that contain dynamic components
|
|
5404
|
+
* - children that are produced by iteration
|
|
5405
|
+
* @param vnodes
|
|
5247
5406
|
*/
|
|
5248
5407
|
function sc(vnodes) {
|
|
5249
5408
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5267,6 +5426,7 @@ let sanitizeHtmlContentHook = () => {
|
|
|
5267
5426
|
};
|
|
5268
5427
|
/**
|
|
5269
5428
|
* Sets the sanitizeHtmlContentHook.
|
|
5429
|
+
* @param newHookImpl
|
|
5270
5430
|
*/
|
|
5271
5431
|
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
5272
5432
|
sanitizeHtmlContentHook = newHookImpl;
|
|
@@ -5397,7 +5557,7 @@ function logGlobalOperationStart(opId, vm) {
|
|
|
5397
5557
|
start(markName);
|
|
5398
5558
|
}
|
|
5399
5559
|
if (isProfilerEnabled) {
|
|
5400
|
-
currentDispatcher(opId, 0 /* Phase.Start */, vm
|
|
5560
|
+
currentDispatcher(opId, 0 /* Phase.Start */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
|
|
5401
5561
|
}
|
|
5402
5562
|
}
|
|
5403
5563
|
function logGlobalOperationEnd(opId, vm) {
|
|
@@ -5407,7 +5567,7 @@ function logGlobalOperationEnd(opId, vm) {
|
|
|
5407
5567
|
end(opName, markName);
|
|
5408
5568
|
}
|
|
5409
5569
|
if (isProfilerEnabled) {
|
|
5410
|
-
currentDispatcher(opId, 1 /* Phase.Stop */, vm
|
|
5570
|
+
currentDispatcher(opId, 1 /* Phase.Stop */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
|
|
5411
5571
|
}
|
|
5412
5572
|
}
|
|
5413
5573
|
|
|
@@ -5429,7 +5589,6 @@ function validateSlots(vm) {
|
|
|
5429
5589
|
assertNotProd(); // this method should never leak to prod
|
|
5430
5590
|
const { cmpSlots } = vm;
|
|
5431
5591
|
for (const slotName in cmpSlots.slotAssignments) {
|
|
5432
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5433
5592
|
shared.assert.isTrue(shared.isArray(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${shared.toString(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
5434
5593
|
}
|
|
5435
5594
|
}
|
|
@@ -5709,6 +5868,8 @@ const registeredComponentMap = new Map();
|
|
|
5709
5868
|
/**
|
|
5710
5869
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
5711
5870
|
* will prevent this function from being imported by userland code.
|
|
5871
|
+
* @param Ctor
|
|
5872
|
+
* @param metadata
|
|
5712
5873
|
*/
|
|
5713
5874
|
function registerComponent(
|
|
5714
5875
|
// We typically expect a LightningElementConstructor, but technically you can call this with anything
|
|
@@ -5727,16 +5888,14 @@ Ctor, metadata) {
|
|
|
5727
5888
|
return Ctor;
|
|
5728
5889
|
}
|
|
5729
5890
|
function getComponentRegisteredTemplate(Ctor) {
|
|
5730
|
-
|
|
5731
|
-
return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
|
|
5891
|
+
return registeredComponentMap.get(Ctor)?.tmpl;
|
|
5732
5892
|
}
|
|
5733
5893
|
function getComponentRegisteredName(Ctor) {
|
|
5734
|
-
|
|
5735
|
-
return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
|
|
5894
|
+
return registeredComponentMap.get(Ctor)?.sel;
|
|
5736
5895
|
}
|
|
5737
5896
|
function getComponentAPIVersion(Ctor) {
|
|
5738
5897
|
const metadata = registeredComponentMap.get(Ctor);
|
|
5739
|
-
const apiVersion = metadata
|
|
5898
|
+
const apiVersion = metadata?.apiVersion;
|
|
5740
5899
|
if (shared.isUndefined(apiVersion)) {
|
|
5741
5900
|
// This should only occur in our Karma tests; in practice every component
|
|
5742
5901
|
// is registered, and so this code path should not get hit. But to be safe,
|
|
@@ -5754,11 +5913,27 @@ function getTemplateReactiveObserver(vm) {
|
|
|
5754
5913
|
}
|
|
5755
5914
|
});
|
|
5756
5915
|
}
|
|
5916
|
+
function resetTemplateObserverAndUnsubscribe(vm) {
|
|
5917
|
+
const { tro, component } = vm;
|
|
5918
|
+
tro.reset();
|
|
5919
|
+
// Unsubscribe every time the template reactive observer is reset.
|
|
5920
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS) {
|
|
5921
|
+
unsubscribeFromSignals(component);
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5757
5924
|
function renderComponent(vm) {
|
|
5758
5925
|
if (process.env.NODE_ENV !== 'production') {
|
|
5759
5926
|
shared.assert.invariant(vm.isDirty, `${vm} is not dirty.`);
|
|
5760
5927
|
}
|
|
5761
|
-
|
|
5928
|
+
// The engine should only hold a subscription to a signal if it is rendered in the template.
|
|
5929
|
+
// Because of the potential presence of conditional rendering logic, we unsubscribe on each render
|
|
5930
|
+
// in the scenario where it is present in one condition but not the other.
|
|
5931
|
+
// For example:
|
|
5932
|
+
// 1. There is an lwc:if=true conditional where the signal is present on the template.
|
|
5933
|
+
// 2. The lwc:if changes to false and the signal is no longer present on the template.
|
|
5934
|
+
// If the signal is still subscribed to, the template will re-render when it receives a notification
|
|
5935
|
+
// from the signal, even though we won't be using the new value.
|
|
5936
|
+
resetTemplateObserverAndUnsubscribe(vm);
|
|
5762
5937
|
const vnodes = invokeComponentRenderMethod(vm);
|
|
5763
5938
|
vm.isDirty = false;
|
|
5764
5939
|
vm.isScheduled = false;
|
|
@@ -5833,9 +6008,8 @@ function appendVM(vm) {
|
|
|
5833
6008
|
function resetComponentStateWhenRemoved(vm) {
|
|
5834
6009
|
const { state } = vm;
|
|
5835
6010
|
if (state !== 2 /* VMState.disconnected */) {
|
|
5836
|
-
const { tro } = vm;
|
|
5837
6011
|
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5838
|
-
|
|
6012
|
+
resetTemplateObserverAndUnsubscribe(vm);
|
|
5839
6013
|
runDisconnectedCallback(vm);
|
|
5840
6014
|
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5841
6015
|
runChildNodesDisconnectedCallback(vm);
|
|
@@ -6053,7 +6227,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
|
|
|
6053
6227
|
return shadowMode;
|
|
6054
6228
|
}
|
|
6055
6229
|
function assertIsVM(obj) {
|
|
6056
|
-
if (shared.
|
|
6230
|
+
if (!shared.isObject(obj) || shared.isNull(obj) || !('renderRoot' in obj)) {
|
|
6057
6231
|
throw new TypeError(`${obj} is not a VM.`);
|
|
6058
6232
|
}
|
|
6059
6233
|
}
|
|
@@ -6148,7 +6322,7 @@ function flushRehydrationQueue() {
|
|
|
6148
6322
|
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
6149
6323
|
// re-throwing the original error will break the current tick, but since the next tick is
|
|
6150
6324
|
// already scheduled, it should continue patching the rest.
|
|
6151
|
-
throw error;
|
|
6325
|
+
throw error;
|
|
6152
6326
|
}
|
|
6153
6327
|
}
|
|
6154
6328
|
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
@@ -6246,6 +6420,7 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
6246
6420
|
* need to continue into its children because by attempting to disconnect the
|
|
6247
6421
|
* custom element itself will trigger the removal of anything slotted or anything
|
|
6248
6422
|
* defined on its shadow.
|
|
6423
|
+
* @param vnodes
|
|
6249
6424
|
*/
|
|
6250
6425
|
function recursivelyDisconnectChildren(vnodes) {
|
|
6251
6426
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
@@ -6621,7 +6796,7 @@ function checkAndReportViolation(elm, prop, isSetter, setValue) {
|
|
|
6621
6796
|
setValueType = shared.isNull(setValue) ? 'null' : typeof setValue;
|
|
6622
6797
|
}
|
|
6623
6798
|
report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
|
|
6624
|
-
tagName: vm
|
|
6799
|
+
tagName: vm?.tagName,
|
|
6625
6800
|
propertyName: prop,
|
|
6626
6801
|
isSetter,
|
|
6627
6802
|
setValueType,
|
|
@@ -6699,7 +6874,6 @@ function hydrateVM(vm) {
|
|
|
6699
6874
|
runRenderedCallback(vm);
|
|
6700
6875
|
}
|
|
6701
6876
|
function hydrateNode(node, vnode, renderer) {
|
|
6702
|
-
var _a, _b;
|
|
6703
6877
|
let hydratedNode;
|
|
6704
6878
|
switch (vnode.type) {
|
|
6705
6879
|
case 0 /* VNodeType.Text */:
|
|
@@ -6719,10 +6893,10 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
6719
6893
|
hydratedNode = hydrateFragment(node, vnode, renderer);
|
|
6720
6894
|
break;
|
|
6721
6895
|
case 2 /* VNodeType.Element */:
|
|
6722
|
-
hydratedNode = hydrateElement(node, vnode,
|
|
6896
|
+
hydratedNode = hydrateElement(node, vnode, vnode.data.renderer ?? renderer);
|
|
6723
6897
|
break;
|
|
6724
6898
|
case 3 /* VNodeType.CustomElement */:
|
|
6725
|
-
hydratedNode = hydrateCustomElement(node, vnode,
|
|
6899
|
+
hydratedNode = hydrateCustomElement(node, vnode, vnode.data.renderer ?? renderer);
|
|
6726
6900
|
break;
|
|
6727
6901
|
}
|
|
6728
6902
|
return renderer.nextSibling(hydratedNode);
|
|
@@ -6765,7 +6939,6 @@ function getValidationPredicate(optOutStaticProp) {
|
|
|
6765
6939
|
return (_attrName) => true;
|
|
6766
6940
|
}
|
|
6767
6941
|
function hydrateText(node, vnode, renderer) {
|
|
6768
|
-
var _a;
|
|
6769
6942
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6770
6943
|
return handleMismatch(node, vnode, renderer);
|
|
6771
6944
|
}
|
|
@@ -6775,12 +6948,11 @@ function hydrateText(node, vnode, renderer) {
|
|
|
6775
6948
|
}
|
|
6776
6949
|
}
|
|
6777
6950
|
const { setText } = renderer;
|
|
6778
|
-
setText(node,
|
|
6951
|
+
setText(node, vnode.text ?? null);
|
|
6779
6952
|
vnode.elm = node;
|
|
6780
6953
|
return node;
|
|
6781
6954
|
}
|
|
6782
6955
|
function hydrateComment(node, vnode, renderer) {
|
|
6783
|
-
var _a;
|
|
6784
6956
|
if (!hasCorrectNodeType(vnode, node, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
6785
6957
|
return handleMismatch(node, vnode, renderer);
|
|
6786
6958
|
}
|
|
@@ -6792,7 +6964,7 @@ function hydrateComment(node, vnode, renderer) {
|
|
|
6792
6964
|
}
|
|
6793
6965
|
}
|
|
6794
6966
|
const { setProperty } = renderer;
|
|
6795
|
-
setProperty(node, NODE_VALUE_PROP,
|
|
6967
|
+
setProperty(node, NODE_VALUE_PROP, vnode.text ?? null);
|
|
6796
6968
|
vnode.elm = node;
|
|
6797
6969
|
return node;
|
|
6798
6970
|
}
|
|
@@ -6802,7 +6974,7 @@ function hydrateStaticElement(elm, vnode, renderer) {
|
|
|
6802
6974
|
return handleMismatch(elm, vnode, renderer);
|
|
6803
6975
|
}
|
|
6804
6976
|
vnode.elm = elm;
|
|
6805
|
-
|
|
6977
|
+
mountStaticParts(elm, vnode, renderer);
|
|
6806
6978
|
return elm;
|
|
6807
6979
|
}
|
|
6808
6980
|
function hydrateFragment(elm, vnode, renderer) {
|
|
@@ -6827,7 +6999,10 @@ function hydrateElement(elm, vnode, renderer) {
|
|
|
6827
6999
|
if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
|
|
6828
7000
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
6829
7001
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6830
|
-
vnode.data =
|
|
7002
|
+
vnode.data = {
|
|
7003
|
+
...vnode.data,
|
|
7004
|
+
props: cloneAndOmitKey(props, 'innerHTML'),
|
|
7005
|
+
};
|
|
6831
7006
|
}
|
|
6832
7007
|
else {
|
|
6833
7008
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7039,7 +7214,11 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
7039
7214
|
className = shared.ArrayJoin.call(classNames, ' ');
|
|
7040
7215
|
}
|
|
7041
7216
|
else if (!shared.isUndefined(classMap)) {
|
|
7042
|
-
classMap =
|
|
7217
|
+
classMap = {
|
|
7218
|
+
...classMap,
|
|
7219
|
+
...(!shared.isNull(scopedToken) ? { [scopedToken]: true } : {}),
|
|
7220
|
+
...(!shared.isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}),
|
|
7221
|
+
};
|
|
7043
7222
|
}
|
|
7044
7223
|
else {
|
|
7045
7224
|
// The order of the className should be scopedToken stylesheetTokenHost
|
|
@@ -7397,6 +7576,7 @@ function freezeTemplate(tmpl) {
|
|
|
7397
7576
|
/**
|
|
7398
7577
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
7399
7578
|
* This API is subject to change or being removed.
|
|
7579
|
+
* @param elm
|
|
7400
7580
|
*/
|
|
7401
7581
|
function getComponentConstructor(elm) {
|
|
7402
7582
|
let ctor = null;
|
|
@@ -7421,6 +7601,7 @@ function getComponentConstructor(elm) {
|
|
|
7421
7601
|
* EXPERIMENTAL: This function allows you to create a reactive readonly
|
|
7422
7602
|
* membrane around any object value. This API is subject to change or
|
|
7423
7603
|
* being removed.
|
|
7604
|
+
* @param obj
|
|
7424
7605
|
*/
|
|
7425
7606
|
function readonly(obj) {
|
|
7426
7607
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7475,5 +7656,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
7475
7656
|
exports.track = track;
|
|
7476
7657
|
exports.unwrap = unwrap;
|
|
7477
7658
|
exports.wire = wire;
|
|
7478
|
-
/** version: 6.
|
|
7659
|
+
/** version: 6.2.1 */
|
|
7479
7660
|
//# sourceMappingURL=index.cjs.js.map
|