@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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2024 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
|
-
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create,
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, isFalse, isFunction as isFunction$1, isObject, seal, isAPIFeatureEnabled, isArray as isArray$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, KEY__SYNTHETIC_MODE, isString, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse } from '@lwc/shared';
|
|
5
5
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -23,8 +23,7 @@ let enabled$1 = false;
|
|
|
23
23
|
const reportingControl = {
|
|
24
24
|
/**
|
|
25
25
|
* Attach a new reporting control (aka dispatcher).
|
|
26
|
-
*
|
|
27
|
-
* @param dispatcher - reporting control
|
|
26
|
+
* @param dispatcher reporting control
|
|
28
27
|
*/
|
|
29
28
|
attachDispatcher(dispatcher) {
|
|
30
29
|
enabled$1 = true;
|
|
@@ -67,7 +66,7 @@ function onReportingEnabled(callback) {
|
|
|
67
66
|
/**
|
|
68
67
|
* Report to the current dispatcher, if there is one.
|
|
69
68
|
* @param reportingEventId
|
|
70
|
-
* @param payload
|
|
69
|
+
* @param payload data to report
|
|
71
70
|
*/
|
|
72
71
|
function report(reportingEventId, payload) {
|
|
73
72
|
if (enabled$1) {
|
|
@@ -232,6 +231,7 @@ class ReactiveObserver {
|
|
|
232
231
|
}
|
|
233
232
|
observe(job) {
|
|
234
233
|
const inceptionReactiveRecord = currentReactiveObserver;
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
235
235
|
currentReactiveObserver = this;
|
|
236
236
|
let error;
|
|
237
237
|
try {
|
|
@@ -281,6 +281,80 @@ class ReactiveObserver {
|
|
|
281
281
|
// we keep track of observing records where the observing record was added to so we can do some clean up later on
|
|
282
282
|
ArrayPush$1.call(this.listeners, reactiveObservers);
|
|
283
283
|
}
|
|
284
|
+
isObserving() {
|
|
285
|
+
return currentReactiveObserver === this;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/*
|
|
290
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
291
|
+
* All rights reserved.
|
|
292
|
+
* SPDX-License-Identifier: MIT
|
|
293
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
294
|
+
*/
|
|
295
|
+
/**
|
|
296
|
+
* This map keeps track of objects to signals. There is an assumption that the signal is strongly referenced
|
|
297
|
+
* on the object which allows the SignalTracker to be garbage collected along with the object.
|
|
298
|
+
*/
|
|
299
|
+
const TargetToSignalTrackerMap = new WeakMap();
|
|
300
|
+
function getSignalTracker(target) {
|
|
301
|
+
let signalTracker = TargetToSignalTrackerMap.get(target);
|
|
302
|
+
if (isUndefined$1(signalTracker)) {
|
|
303
|
+
signalTracker = new SignalTracker();
|
|
304
|
+
TargetToSignalTrackerMap.set(target, signalTracker);
|
|
305
|
+
}
|
|
306
|
+
return signalTracker;
|
|
307
|
+
}
|
|
308
|
+
function subscribeToSignal(target, signal, update) {
|
|
309
|
+
const signalTracker = getSignalTracker(target);
|
|
310
|
+
if (isFalse(signalTracker.seen(signal))) {
|
|
311
|
+
signalTracker.subscribeToSignal(signal, update);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function unsubscribeFromSignals(target) {
|
|
315
|
+
if (TargetToSignalTrackerMap.has(target)) {
|
|
316
|
+
const signalTracker = getSignalTracker(target);
|
|
317
|
+
signalTracker.unsubscribeFromSignals();
|
|
318
|
+
signalTracker.reset();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* This class is used to keep track of the signals associated to a given object.
|
|
323
|
+
* It is used to prevent the LWC engine from subscribing duplicate callbacks multiple times
|
|
324
|
+
* to the same signal. Additionally, it keeps track of all signal unsubscribe callbacks, handles invoking
|
|
325
|
+
* them when necessary and discarding them.
|
|
326
|
+
*/
|
|
327
|
+
class SignalTracker {
|
|
328
|
+
constructor() {
|
|
329
|
+
this.signalToUnsubscribeMap = new Map();
|
|
330
|
+
}
|
|
331
|
+
seen(signal) {
|
|
332
|
+
return this.signalToUnsubscribeMap.has(signal);
|
|
333
|
+
}
|
|
334
|
+
subscribeToSignal(signal, update) {
|
|
335
|
+
try {
|
|
336
|
+
const unsubscribe = signal.subscribe(update);
|
|
337
|
+
if (isFunction$1(unsubscribe)) {
|
|
338
|
+
// TODO [#3978]: Evaluate how we should handle the case when unsubscribe is not a function.
|
|
339
|
+
// Long term we should throw an error or log a warning.
|
|
340
|
+
this.signalToUnsubscribeMap.set(signal, unsubscribe);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
logWarnOnce(`Attempted to subscribe to an object that has the shape of a signal but received the following error: ${err?.stack ?? err}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
unsubscribeFromSignals() {
|
|
348
|
+
try {
|
|
349
|
+
this.signalToUnsubscribeMap.forEach((unsubscribe) => unsubscribe());
|
|
350
|
+
}
|
|
351
|
+
catch (err) {
|
|
352
|
+
logWarnOnce(`Attempted to call a signal's unsubscribe callback but received the following error: ${err?.stack ?? err}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
reset() {
|
|
356
|
+
this.signalToUnsubscribeMap.clear();
|
|
357
|
+
}
|
|
284
358
|
}
|
|
285
359
|
|
|
286
360
|
/*
|
|
@@ -302,10 +376,26 @@ function componentValueMutated(vm, key) {
|
|
|
302
376
|
valueMutated(vm.component, key);
|
|
303
377
|
}
|
|
304
378
|
}
|
|
305
|
-
function componentValueObserved(vm, key) {
|
|
379
|
+
function componentValueObserved(vm, key, target = {}) {
|
|
380
|
+
const { component, tro } = vm;
|
|
306
381
|
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
307
382
|
if (process.env.IS_BROWSER) {
|
|
308
|
-
valueObserved(
|
|
383
|
+
valueObserved(component, key);
|
|
384
|
+
}
|
|
385
|
+
// The portion of reactivity that's exposed to signals is to subscribe a callback to re-render the VM (templates).
|
|
386
|
+
// We check check the following to ensure re-render is subscribed at the correct time.
|
|
387
|
+
// 1. The template is currently being rendered (there is a template reactive observer)
|
|
388
|
+
// 2. There was a call to a getter to access the signal (happens during vnode generation)
|
|
389
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS &&
|
|
390
|
+
isObject(target) &&
|
|
391
|
+
!isNull(target) &&
|
|
392
|
+
'value' in target &&
|
|
393
|
+
'subscribe' in target &&
|
|
394
|
+
isFunction$1(target.subscribe) &&
|
|
395
|
+
// Only subscribe if a template is being rendered by the engine
|
|
396
|
+
tro.isObserving()) {
|
|
397
|
+
// Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
|
|
398
|
+
subscribeToSignal(component, target, tro.notify.bind(tro));
|
|
309
399
|
}
|
|
310
400
|
}
|
|
311
401
|
function createReactiveObserver(callback) {
|
|
@@ -342,6 +432,7 @@ function addCallbackToNextTick(callback) {
|
|
|
342
432
|
}
|
|
343
433
|
}
|
|
344
434
|
if (nextTickCallbackQueue.length === 0) {
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
345
436
|
Promise.resolve().then(flushCallbackQueue);
|
|
346
437
|
}
|
|
347
438
|
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
@@ -423,7 +514,11 @@ function applyTemporaryCompilerV5SlotFix(data) {
|
|
|
423
514
|
if (!isUndefined$1(attrs)) {
|
|
424
515
|
const { slot } = attrs;
|
|
425
516
|
if (!isUndefined$1(slot) && !isNull(slot)) {
|
|
426
|
-
return
|
|
517
|
+
return {
|
|
518
|
+
...data,
|
|
519
|
+
attrs: cloneAndOmitKey(attrs, 'slot'),
|
|
520
|
+
slotAssignment: String(slot),
|
|
521
|
+
};
|
|
427
522
|
}
|
|
428
523
|
}
|
|
429
524
|
return data;
|
|
@@ -437,15 +532,20 @@ function applyTemporaryCompilerV5SlotFix(data) {
|
|
|
437
532
|
*/
|
|
438
533
|
function resolveCircularModuleDependency(fn) {
|
|
439
534
|
const module = fn();
|
|
440
|
-
return
|
|
535
|
+
return module?.__esModule ? module.default : module;
|
|
441
536
|
}
|
|
442
537
|
function isCircularModuleDependency(obj) {
|
|
443
538
|
return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
|
|
444
539
|
}
|
|
445
540
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
541
|
+
/*
|
|
542
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
543
|
+
* All rights reserved.
|
|
544
|
+
* SPDX-License-Identifier: MIT
|
|
545
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
546
|
+
*/
|
|
547
|
+
const instrumentDef = globalThis.__lwc_instrument_cmp_def ?? noop;
|
|
548
|
+
const instrumentInstance = globalThis.__lwc_instrument_cmp_instance ?? noop;
|
|
449
549
|
|
|
450
550
|
/*
|
|
451
551
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1329,6 +1429,7 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1329
1429
|
* EXPERIMENTAL: This function implements an unwrap mechanism that
|
|
1330
1430
|
* works for observable membrane objects. This API is subject to
|
|
1331
1431
|
* change or being removed.
|
|
1432
|
+
* @param value
|
|
1332
1433
|
*/
|
|
1333
1434
|
function unwrap(value) {
|
|
1334
1435
|
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
@@ -1397,6 +1498,7 @@ function initGlobalStylesheet() {
|
|
|
1397
1498
|
}
|
|
1398
1499
|
return promise;
|
|
1399
1500
|
});
|
|
1501
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1400
1502
|
Promise.all(promises).then((stylesheetTexts) => {
|
|
1401
1503
|
// When replaceSync() is called, the entire contents of the constructable stylesheet are replaced
|
|
1402
1504
|
// with the copied+concatenated styles. This means that any shadow root's adoptedStyleSheets that
|
|
@@ -1441,6 +1543,8 @@ function applyShadowMigrateMode(shadowRoot) {
|
|
|
1441
1543
|
* that a Custom Element can support (including AOM properties), which
|
|
1442
1544
|
* determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
|
|
1443
1545
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1546
|
+
* @param propName
|
|
1547
|
+
* @param descriptor
|
|
1444
1548
|
*/
|
|
1445
1549
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1446
1550
|
const { get, set, enumerable, configurable } = descriptor;
|
|
@@ -1490,7 +1594,7 @@ const refsCache = new WeakMap();
|
|
|
1490
1594
|
/**
|
|
1491
1595
|
* This class is the base class for any LWC element.
|
|
1492
1596
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
1493
|
-
|
|
1597
|
+
*/
|
|
1494
1598
|
// @ts-ignore
|
|
1495
1599
|
const LightningElement = function () {
|
|
1496
1600
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
@@ -1508,7 +1612,6 @@ const LightningElement = function () {
|
|
|
1508
1612
|
const { assertInstanceOfHTMLElement } = vm.renderer;
|
|
1509
1613
|
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1510
1614
|
}
|
|
1511
|
-
const component = this;
|
|
1512
1615
|
setPrototypeOf(elm, bridge.prototype);
|
|
1513
1616
|
vm.component = this;
|
|
1514
1617
|
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
@@ -1523,7 +1626,7 @@ const LightningElement = function () {
|
|
|
1523
1626
|
}
|
|
1524
1627
|
markLockerLiveObject(this);
|
|
1525
1628
|
// Linking elm, shadow root and component with the VM.
|
|
1526
|
-
associateVM(
|
|
1629
|
+
associateVM(this, vm);
|
|
1527
1630
|
associateVM(elm, vm);
|
|
1528
1631
|
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
1529
1632
|
vm.renderRoot = doAttachShadow(vm);
|
|
@@ -1947,8 +2050,9 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1947
2050
|
return {
|
|
1948
2051
|
get() {
|
|
1949
2052
|
const vm = getAssociatedVM(this);
|
|
1950
|
-
|
|
1951
|
-
|
|
2053
|
+
const val = vm.cmpFields[key];
|
|
2054
|
+
componentValueObserved(vm, key, val);
|
|
2055
|
+
return val;
|
|
1952
2056
|
},
|
|
1953
2057
|
set(newValue) {
|
|
1954
2058
|
const vm = getAssociatedVM(this);
|
|
@@ -2059,6 +2163,7 @@ function createConfigWatcher(component, configCallback, callbackWhenConfigIsRead
|
|
|
2059
2163
|
if (hasPendingConfig === false) {
|
|
2060
2164
|
hasPendingConfig = true;
|
|
2061
2165
|
// collect new config in the micro-task
|
|
2166
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2062
2167
|
Promise.resolve().then(() => {
|
|
2063
2168
|
hasPendingConfig = false;
|
|
2064
2169
|
// resetting current reactive params
|
|
@@ -2201,6 +2306,7 @@ function installWireAdapters(vm) {
|
|
|
2201
2306
|
connector.connect();
|
|
2202
2307
|
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2203
2308
|
if (hasDynamicParams) {
|
|
2309
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2204
2310
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
2205
2311
|
return;
|
|
2206
2312
|
}
|
|
@@ -2252,8 +2358,9 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2252
2358
|
}
|
|
2253
2359
|
return;
|
|
2254
2360
|
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2361
|
+
const val = vm.cmpProps[key];
|
|
2362
|
+
componentValueObserved(vm, key, val);
|
|
2363
|
+
return val;
|
|
2257
2364
|
},
|
|
2258
2365
|
set(newValue) {
|
|
2259
2366
|
const vm = getAssociatedVM(this);
|
|
@@ -2326,8 +2433,9 @@ function internalTrackDecorator(key) {
|
|
|
2326
2433
|
return {
|
|
2327
2434
|
get() {
|
|
2328
2435
|
const vm = getAssociatedVM(this);
|
|
2329
|
-
|
|
2330
|
-
|
|
2436
|
+
const val = vm.cmpFields[key];
|
|
2437
|
+
componentValueObserved(vm, key, val);
|
|
2438
|
+
return val;
|
|
2331
2439
|
},
|
|
2332
2440
|
set(newValue) {
|
|
2333
2441
|
const vm = getAssociatedVM(this);
|
|
@@ -2355,9 +2463,11 @@ function internalTrackDecorator(key) {
|
|
|
2355
2463
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2356
2464
|
*/
|
|
2357
2465
|
/**
|
|
2358
|
-
* @wire decorator
|
|
2466
|
+
* The @wire decorator wires fields and methods to a wire adapter in
|
|
2359
2467
|
* LWC Components. This function implements the internals of this
|
|
2360
2468
|
* decorator.
|
|
2469
|
+
* @param _adapter
|
|
2470
|
+
* @param _config
|
|
2361
2471
|
*/
|
|
2362
2472
|
function wire(_adapter, _config) {
|
|
2363
2473
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2468,6 +2578,8 @@ function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
|
|
|
2468
2578
|
/**
|
|
2469
2579
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2470
2580
|
* will prevent this function from being imported by user-land code.
|
|
2581
|
+
* @param Ctor
|
|
2582
|
+
* @param meta
|
|
2471
2583
|
*/
|
|
2472
2584
|
function registerDecorators(Ctor, meta) {
|
|
2473
2585
|
const proto = Ctor.prototype;
|
|
@@ -2656,6 +2768,7 @@ function isTemplateRegistered(tpl) {
|
|
|
2656
2768
|
/**
|
|
2657
2769
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
2658
2770
|
* will prevent this function from being imported by userland code.
|
|
2771
|
+
* @param tpl
|
|
2659
2772
|
*/
|
|
2660
2773
|
function registerTemplate(tpl) {
|
|
2661
2774
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2669,6 +2782,10 @@ function registerTemplate(tpl) {
|
|
|
2669
2782
|
/**
|
|
2670
2783
|
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
2671
2784
|
* libraries to sanitize vulnerable attributes.
|
|
2785
|
+
* @param tagName
|
|
2786
|
+
* @param namespaceUri
|
|
2787
|
+
* @param attrName
|
|
2788
|
+
* @param attrValue
|
|
2672
2789
|
*/
|
|
2673
2790
|
function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
2674
2791
|
// locker-service patches this function during runtime to sanitize vulnerable attributes. When
|
|
@@ -3201,6 +3318,14 @@ function createComponentDef(Ctor) {
|
|
|
3201
3318
|
let shadowSupportMode = superDef.shadowSupportMode;
|
|
3202
3319
|
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
3203
3320
|
shadowSupportMode = ctorShadowSupportMode;
|
|
3321
|
+
if (isReportingEnabled() &&
|
|
3322
|
+
(shadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
|
|
3323
|
+
shadowSupportMode === "native" /* ShadowSupportMode.Native */)) {
|
|
3324
|
+
report("ShadowSupportModeUsage" /* ReportingEventId.ShadowSupportModeUsage */, {
|
|
3325
|
+
tagName: Ctor.name,
|
|
3326
|
+
mode: shadowSupportMode,
|
|
3327
|
+
});
|
|
3328
|
+
}
|
|
3204
3329
|
}
|
|
3205
3330
|
let renderMode = superDef.renderMode;
|
|
3206
3331
|
if (!isUndefined$1(ctorRenderMode)) {
|
|
@@ -3246,6 +3371,7 @@ function createComponentDef(Ctor) {
|
|
|
3246
3371
|
/**
|
|
3247
3372
|
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
3248
3373
|
* subject to change or being removed.
|
|
3374
|
+
* @param ctor
|
|
3249
3375
|
*/
|
|
3250
3376
|
function isComponentConstructor(ctor) {
|
|
3251
3377
|
if (!isFunction$1(ctor)) {
|
|
@@ -3319,6 +3445,7 @@ const lightingElementDef = {
|
|
|
3319
3445
|
/**
|
|
3320
3446
|
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
3321
3447
|
* subject to change or being removed.
|
|
3448
|
+
* @param Ctor
|
|
3322
3449
|
*/
|
|
3323
3450
|
function getComponentDef(Ctor) {
|
|
3324
3451
|
const def = getComponentInternalDef(Ctor);
|
|
@@ -3515,12 +3642,14 @@ function getNearestShadowComponent(vm) {
|
|
|
3515
3642
|
* If the component that is currently being rendered uses scoped styles,
|
|
3516
3643
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3517
3644
|
* it returns null.
|
|
3645
|
+
* @param owner
|
|
3646
|
+
* @param legacy
|
|
3518
3647
|
*/
|
|
3519
3648
|
// TODO [#3733]: remove support for legacy scope tokens
|
|
3520
3649
|
function getScopeTokenClass(owner, legacy) {
|
|
3521
3650
|
const { cmpTemplate, context } = owner;
|
|
3522
3651
|
return ((context.hasScopedStyles &&
|
|
3523
|
-
(legacy ? cmpTemplate
|
|
3652
|
+
(legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken)) ||
|
|
3524
3653
|
null);
|
|
3525
3654
|
}
|
|
3526
3655
|
/**
|
|
@@ -3528,6 +3657,7 @@ function getScopeTokenClass(owner, legacy) {
|
|
|
3528
3657
|
* exists. Otherwise it returns null.
|
|
3529
3658
|
*
|
|
3530
3659
|
* A host style token is applied to the component if scoped styles are used.
|
|
3660
|
+
* @param vnode
|
|
3531
3661
|
*/
|
|
3532
3662
|
function getStylesheetTokenHost(vnode) {
|
|
3533
3663
|
const { template } = getComponentInternalDef(vnode.ctor);
|
|
@@ -3647,7 +3777,7 @@ function patchAttributes(oldVnode, vnode, renderer) {
|
|
|
3647
3777
|
}
|
|
3648
3778
|
function patchSlotAssignment(oldVnode, vnode, renderer) {
|
|
3649
3779
|
const { slotAssignment } = vnode;
|
|
3650
|
-
if (
|
|
3780
|
+
if (oldVnode?.slotAssignment === slotAssignment) {
|
|
3651
3781
|
return;
|
|
3652
3782
|
}
|
|
3653
3783
|
const { elm } = vnode;
|
|
@@ -3724,6 +3854,8 @@ function getMapFromClassName(className) {
|
|
|
3724
3854
|
return EmptyObject;
|
|
3725
3855
|
}
|
|
3726
3856
|
// computed class names must be string
|
|
3857
|
+
// This will throw if className is a symbol or null-prototype object
|
|
3858
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
3727
3859
|
className = isString(className) ? className : className + '';
|
|
3728
3860
|
let map = classNameToClassMap[className];
|
|
3729
3861
|
if (map) {
|
|
@@ -3804,9 +3936,8 @@ function patchStyleAttribute(oldVnode, vnode, renderer) {
|
|
|
3804
3936
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3805
3937
|
*/
|
|
3806
3938
|
function applyEventListeners(vnode, renderer) {
|
|
3807
|
-
var _a;
|
|
3808
3939
|
const { elm } = vnode;
|
|
3809
|
-
const on =
|
|
3940
|
+
const on = vnode.data?.on;
|
|
3810
3941
|
if (isUndefined$1(on)) {
|
|
3811
3942
|
return;
|
|
3812
3943
|
}
|
|
@@ -3935,13 +4066,11 @@ function traverseAndSetElements(root, parts, renderer) {
|
|
|
3935
4066
|
}
|
|
3936
4067
|
/**
|
|
3937
4068
|
* Given an array of static parts, do all the mounting required for these parts.
|
|
3938
|
-
*
|
|
3939
|
-
* @param
|
|
3940
|
-
* @param
|
|
3941
|
-
* @param renderer - the renderer to use
|
|
3942
|
-
* @param mount - true this is a first (mount) render as opposed to a subsequent (patch) render
|
|
4069
|
+
* @param root the root element
|
|
4070
|
+
* @param vnode the parent VStatic
|
|
4071
|
+
* @param renderer the renderer to use
|
|
3943
4072
|
*/
|
|
3944
|
-
function
|
|
4073
|
+
function mountStaticParts(root, vnode, renderer) {
|
|
3945
4074
|
// On the server, we don't support ref (because it relies on renderedCallback), nor do we
|
|
3946
4075
|
// support event listeners (no interactivity), so traversing parts makes no sense
|
|
3947
4076
|
if (!process.env.IS_BROWSER) {
|
|
@@ -3951,20 +4080,45 @@ function applyStaticParts(root, vnode, renderer, mount) {
|
|
|
3951
4080
|
if (isUndefined$1(parts)) {
|
|
3952
4081
|
return;
|
|
3953
4082
|
}
|
|
3954
|
-
// This adds `part.elm` to each `part`. We have to do this on every mount
|
|
4083
|
+
// This adds `part.elm` to each `part`. We have to do this on every mount because the `parts`
|
|
3955
4084
|
// array is recreated from scratch every time, so each `part.elm` is now undefined.
|
|
3956
|
-
// TODO [#3800]: avoid calling traverseAndSetElements on every re-render
|
|
3957
4085
|
traverseAndSetElements(root, parts, renderer);
|
|
3958
4086
|
// Currently only event listeners and refs are supported for static vnodes
|
|
3959
4087
|
for (const part of parts) {
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
applyEventListeners(part, renderer);
|
|
3963
|
-
}
|
|
4088
|
+
// Event listeners only need to be applied once when mounting
|
|
4089
|
+
applyEventListeners(part, renderer);
|
|
3964
4090
|
// Refs must be updated after every render due to refVNodes getting reset before every render
|
|
3965
4091
|
applyRefs(part, owner);
|
|
3966
4092
|
}
|
|
3967
4093
|
}
|
|
4094
|
+
/**
|
|
4095
|
+
* Mounts elements to the newly generated VStatic node
|
|
4096
|
+
* @param n1 the previous VStatic vnode
|
|
4097
|
+
* @param n2 the current VStatic vnode
|
|
4098
|
+
*/
|
|
4099
|
+
function patchStaticParts(n1, n2) {
|
|
4100
|
+
// On the server, we don't support ref (because it relies on renderedCallback), nor do we
|
|
4101
|
+
// support event listeners (no interactivity), so traversing parts makes no sense
|
|
4102
|
+
if (!process.env.IS_BROWSER) {
|
|
4103
|
+
return;
|
|
4104
|
+
}
|
|
4105
|
+
const { parts: currParts, owner: currPartsOwner } = n2;
|
|
4106
|
+
if (isUndefined$1(currParts)) {
|
|
4107
|
+
return;
|
|
4108
|
+
}
|
|
4109
|
+
const { parts: prevParts } = n1;
|
|
4110
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4111
|
+
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.');
|
|
4112
|
+
}
|
|
4113
|
+
for (let i = 0; i < currParts.length; i++) {
|
|
4114
|
+
const part = currParts[i];
|
|
4115
|
+
// Patch only occurs if the vnode is newly generated, which means the part.elm is always undefined
|
|
4116
|
+
// Since the vnode and elements are the same we can safely assume that prevParts[i].elm is defined.
|
|
4117
|
+
part.elm = prevParts[i].elm;
|
|
4118
|
+
// Refs must be updated after every render due to refVNodes getting reset before every render
|
|
4119
|
+
applyRefs(part, currPartsOwner);
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
3968
4122
|
|
|
3969
4123
|
/*
|
|
3970
4124
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3981,7 +4135,6 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3981
4135
|
}
|
|
3982
4136
|
}
|
|
3983
4137
|
function patch(n1, n2, parent, renderer) {
|
|
3984
|
-
var _a, _b;
|
|
3985
4138
|
if (n1 === n2) {
|
|
3986
4139
|
return;
|
|
3987
4140
|
}
|
|
@@ -4014,15 +4167,14 @@ function patch(n1, n2, parent, renderer) {
|
|
|
4014
4167
|
patchFragment(n1, n2, parent, renderer);
|
|
4015
4168
|
break;
|
|
4016
4169
|
case 2 /* VNodeType.Element */:
|
|
4017
|
-
patchElement(n1, n2,
|
|
4170
|
+
patchElement(n1, n2, n2.data.renderer ?? renderer);
|
|
4018
4171
|
break;
|
|
4019
4172
|
case 3 /* VNodeType.CustomElement */:
|
|
4020
|
-
patchCustomElement(n1, n2, parent,
|
|
4173
|
+
patchCustomElement(n1, n2, parent, n2.data.renderer ?? renderer);
|
|
4021
4174
|
break;
|
|
4022
4175
|
}
|
|
4023
4176
|
}
|
|
4024
4177
|
function mount(node, parent, renderer, anchor) {
|
|
4025
|
-
var _a, _b;
|
|
4026
4178
|
switch (node.type) {
|
|
4027
4179
|
case 0 /* VNodeType.Text */:
|
|
4028
4180
|
// VText has no special capability, fallback to the owner's renderer
|
|
@@ -4041,11 +4193,11 @@ function mount(node, parent, renderer, anchor) {
|
|
|
4041
4193
|
break;
|
|
4042
4194
|
case 2 /* VNodeType.Element */:
|
|
4043
4195
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4044
|
-
mountElement(node, parent, anchor,
|
|
4196
|
+
mountElement(node, parent, anchor, node.data.renderer ?? renderer);
|
|
4045
4197
|
break;
|
|
4046
4198
|
case 3 /* VNodeType.CustomElement */:
|
|
4047
4199
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4048
|
-
mountCustomElement(node, parent, anchor,
|
|
4200
|
+
mountCustomElement(node, parent, anchor, node.data.renderer ?? renderer);
|
|
4049
4201
|
break;
|
|
4050
4202
|
}
|
|
4051
4203
|
}
|
|
@@ -4107,11 +4259,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
4107
4259
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
4108
4260
|
}
|
|
4109
4261
|
function patchStatic(n1, n2, renderer) {
|
|
4110
|
-
|
|
4262
|
+
n2.elm = n1.elm;
|
|
4111
4263
|
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4112
4264
|
patchSlotAssignment(n1, n2, renderer);
|
|
4113
4265
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
|
4114
|
-
|
|
4266
|
+
patchStaticParts(n1, n2);
|
|
4115
4267
|
}
|
|
4116
4268
|
function patchElement(n1, n2, renderer) {
|
|
4117
4269
|
const elm = (n2.elm = n1.elm);
|
|
@@ -4134,7 +4286,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
4134
4286
|
// slotAssignments can only apply to the top level element, never to a static part.
|
|
4135
4287
|
patchSlotAssignment(null, vnode, renderer);
|
|
4136
4288
|
insertNode(elm, parent, anchor, renderer);
|
|
4137
|
-
|
|
4289
|
+
mountStaticParts(elm, vnode, renderer);
|
|
4138
4290
|
}
|
|
4139
4291
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
4140
4292
|
const { sel, owner, ctor } = vnode;
|
|
@@ -4396,17 +4548,15 @@ function applyStyleScoping(elm, owner, renderer) {
|
|
|
4396
4548
|
}
|
|
4397
4549
|
}
|
|
4398
4550
|
function applyDomManual(elm, vnode) {
|
|
4399
|
-
var _a;
|
|
4400
4551
|
const { owner, data: { context }, } = vnode;
|
|
4401
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ &&
|
|
4552
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && context?.lwc?.dom === "manual" /* LwcDomMode.Manual */) {
|
|
4402
4553
|
elm.$domManual$ = true;
|
|
4403
4554
|
}
|
|
4404
4555
|
}
|
|
4405
4556
|
function applyElementRestrictions(elm, vnode) {
|
|
4406
|
-
var _a, _b;
|
|
4407
4557
|
if (process.env.NODE_ENV !== 'production') {
|
|
4408
4558
|
const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4409
|
-
const isPortal = vnode.type === 2 /* VNodeType.Element */ &&
|
|
4559
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && vnode.data.context?.lwc?.dom === "manual" /* LwcDomMode.Manual */;
|
|
4410
4560
|
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4411
4561
|
patchElementWithRestrictions(elm, {
|
|
4412
4562
|
isPortal,
|
|
@@ -4459,6 +4609,7 @@ function allocateChildren(vnode, vm) {
|
|
|
4459
4609
|
* With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
|
|
4460
4610
|
*
|
|
4461
4611
|
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4612
|
+
* @param children
|
|
4462
4613
|
*/
|
|
4463
4614
|
function flattenFragmentsInChildren(children) {
|
|
4464
4615
|
const flattenedChildren = [];
|
|
@@ -4513,7 +4664,6 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4513
4664
|
return vm;
|
|
4514
4665
|
}
|
|
4515
4666
|
function allocateInSlot(vm, children, owner) {
|
|
4516
|
-
var _a;
|
|
4517
4667
|
const { cmpSlots: { slotAssignments: oldSlotsMapping }, } = vm;
|
|
4518
4668
|
const cmpSlotsMapping = create(null);
|
|
4519
4669
|
// Collect all slots into cmpSlotsMapping
|
|
@@ -4524,7 +4674,7 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4524
4674
|
}
|
|
4525
4675
|
let slotName = '';
|
|
4526
4676
|
if (isVBaseElement(vnode) || isVStatic(vnode)) {
|
|
4527
|
-
slotName =
|
|
4677
|
+
slotName = vnode.slotAssignment ?? '';
|
|
4528
4678
|
}
|
|
4529
4679
|
else if (isVScopedSlotFragment(vnode)) {
|
|
4530
4680
|
slotName = vnode.slotName;
|
|
@@ -4533,6 +4683,7 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4533
4683
|
// but elm.setAttribute('slot', Symbol(1)) is an error.
|
|
4534
4684
|
// the following line also throws same error for symbols
|
|
4535
4685
|
// Similar for Object.create(null)
|
|
4686
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
4536
4687
|
const normalizedSlotName = '' + slotName;
|
|
4537
4688
|
const vnodes = (cmpSlotsMapping[normalizedSlotName] =
|
|
4538
4689
|
cmpSlotsMapping[normalizedSlotName] || []);
|
|
@@ -4930,11 +5081,11 @@ function s(slotName, data, children, slotset) {
|
|
|
4930
5081
|
// to the vnode because the current way the diffing algo works, it will replace the original reference
|
|
4931
5082
|
// to the host element with a new one. This means the new element will be mounted and immediately unmounted.
|
|
4932
5083
|
// Creating a copy of the vnode to preserve a reference to the previous host element.
|
|
4933
|
-
clonedVNode =
|
|
5084
|
+
clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
|
|
4934
5085
|
}
|
|
4935
5086
|
// If the slot content is standard type, the content is static, no additional
|
|
4936
5087
|
// processing needed on the vnode
|
|
4937
|
-
ArrayPush$1.call(newChildren, clonedVNode
|
|
5088
|
+
ArrayPush$1.call(newChildren, clonedVNode ?? vnode);
|
|
4938
5089
|
}
|
|
4939
5090
|
}
|
|
4940
5091
|
}
|
|
@@ -5072,6 +5223,7 @@ function i(iterable, factory) {
|
|
|
5072
5223
|
}
|
|
5073
5224
|
/**
|
|
5074
5225
|
* [f]lattening
|
|
5226
|
+
* @param items
|
|
5075
5227
|
*/
|
|
5076
5228
|
function f(items) {
|
|
5077
5229
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5188,6 +5340,10 @@ function fid(url) {
|
|
|
5188
5340
|
* [ddc] - create a (deprecated) dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
5189
5341
|
*
|
|
5190
5342
|
* TODO [#3331]: remove usage of lwc:dynamic in 246
|
|
5343
|
+
* @param sel
|
|
5344
|
+
* @param Ctor
|
|
5345
|
+
* @param data
|
|
5346
|
+
* @param children
|
|
5191
5347
|
*/
|
|
5192
5348
|
function ddc(sel, Ctor, data, children = EmptyArray) {
|
|
5193
5349
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5206,6 +5362,9 @@ function ddc(sel, Ctor, data, children = EmptyArray) {
|
|
|
5206
5362
|
}
|
|
5207
5363
|
/**
|
|
5208
5364
|
* [dc] - create a dynamic component via `<lwc:component lwc:is={Ctor}>`
|
|
5365
|
+
* @param Ctor
|
|
5366
|
+
* @param data
|
|
5367
|
+
* @param children
|
|
5209
5368
|
*/
|
|
5210
5369
|
function dc(Ctor, data, children = EmptyArray) {
|
|
5211
5370
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5233,13 +5392,13 @@ function dc(Ctor, data, children = EmptyArray) {
|
|
|
5233
5392
|
* to the engine that a particular collection of children must be diffed using the slow
|
|
5234
5393
|
* algo based on keys due to the nature of the list. E.g.:
|
|
5235
5394
|
*
|
|
5236
|
-
*
|
|
5237
|
-
*
|
|
5238
|
-
*
|
|
5239
|
-
*
|
|
5240
|
-
*
|
|
5241
|
-
*
|
|
5242
|
-
*
|
|
5395
|
+
* - slot element's children: the content of the slot has to be dynamic when in synthetic
|
|
5396
|
+
* shadow mode because the `vnode.children` might be the slotted
|
|
5397
|
+
* content vs default content, in which case the size and the
|
|
5398
|
+
* keys are not matching.
|
|
5399
|
+
* - children that contain dynamic components
|
|
5400
|
+
* - children that are produced by iteration
|
|
5401
|
+
* @param vnodes
|
|
5243
5402
|
*/
|
|
5244
5403
|
function sc(vnodes) {
|
|
5245
5404
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5263,6 +5422,7 @@ let sanitizeHtmlContentHook = () => {
|
|
|
5263
5422
|
};
|
|
5264
5423
|
/**
|
|
5265
5424
|
* Sets the sanitizeHtmlContentHook.
|
|
5425
|
+
* @param newHookImpl
|
|
5266
5426
|
*/
|
|
5267
5427
|
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
5268
5428
|
sanitizeHtmlContentHook = newHookImpl;
|
|
@@ -5393,7 +5553,7 @@ function logGlobalOperationStart(opId, vm) {
|
|
|
5393
5553
|
start(markName);
|
|
5394
5554
|
}
|
|
5395
5555
|
if (isProfilerEnabled) {
|
|
5396
|
-
currentDispatcher(opId, 0 /* Phase.Start */, vm
|
|
5556
|
+
currentDispatcher(opId, 0 /* Phase.Start */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
|
|
5397
5557
|
}
|
|
5398
5558
|
}
|
|
5399
5559
|
function logGlobalOperationEnd(opId, vm) {
|
|
@@ -5403,7 +5563,7 @@ function logGlobalOperationEnd(opId, vm) {
|
|
|
5403
5563
|
end(opName, markName);
|
|
5404
5564
|
}
|
|
5405
5565
|
if (isProfilerEnabled) {
|
|
5406
|
-
currentDispatcher(opId, 1 /* Phase.Stop */, vm
|
|
5566
|
+
currentDispatcher(opId, 1 /* Phase.Stop */, vm?.tagName, vm?.idx, vm?.renderMode, vm?.shadowMode);
|
|
5407
5567
|
}
|
|
5408
5568
|
}
|
|
5409
5569
|
|
|
@@ -5425,7 +5585,6 @@ function validateSlots(vm) {
|
|
|
5425
5585
|
assertNotProd(); // this method should never leak to prod
|
|
5426
5586
|
const { cmpSlots } = vm;
|
|
5427
5587
|
for (const slotName in cmpSlots.slotAssignments) {
|
|
5428
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5429
5588
|
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
5430
5589
|
}
|
|
5431
5590
|
}
|
|
@@ -5705,6 +5864,8 @@ const registeredComponentMap = new Map();
|
|
|
5705
5864
|
/**
|
|
5706
5865
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
5707
5866
|
* will prevent this function from being imported by userland code.
|
|
5867
|
+
* @param Ctor
|
|
5868
|
+
* @param metadata
|
|
5708
5869
|
*/
|
|
5709
5870
|
function registerComponent(
|
|
5710
5871
|
// We typically expect a LightningElementConstructor, but technically you can call this with anything
|
|
@@ -5723,16 +5884,14 @@ Ctor, metadata) {
|
|
|
5723
5884
|
return Ctor;
|
|
5724
5885
|
}
|
|
5725
5886
|
function getComponentRegisteredTemplate(Ctor) {
|
|
5726
|
-
|
|
5727
|
-
return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.tmpl;
|
|
5887
|
+
return registeredComponentMap.get(Ctor)?.tmpl;
|
|
5728
5888
|
}
|
|
5729
5889
|
function getComponentRegisteredName(Ctor) {
|
|
5730
|
-
|
|
5731
|
-
return (_a = registeredComponentMap.get(Ctor)) === null || _a === void 0 ? void 0 : _a.sel;
|
|
5890
|
+
return registeredComponentMap.get(Ctor)?.sel;
|
|
5732
5891
|
}
|
|
5733
5892
|
function getComponentAPIVersion(Ctor) {
|
|
5734
5893
|
const metadata = registeredComponentMap.get(Ctor);
|
|
5735
|
-
const apiVersion = metadata
|
|
5894
|
+
const apiVersion = metadata?.apiVersion;
|
|
5736
5895
|
if (isUndefined$1(apiVersion)) {
|
|
5737
5896
|
// This should only occur in our Karma tests; in practice every component
|
|
5738
5897
|
// is registered, and so this code path should not get hit. But to be safe,
|
|
@@ -5750,11 +5909,27 @@ function getTemplateReactiveObserver(vm) {
|
|
|
5750
5909
|
}
|
|
5751
5910
|
});
|
|
5752
5911
|
}
|
|
5912
|
+
function resetTemplateObserverAndUnsubscribe(vm) {
|
|
5913
|
+
const { tro, component } = vm;
|
|
5914
|
+
tro.reset();
|
|
5915
|
+
// Unsubscribe every time the template reactive observer is reset.
|
|
5916
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS) {
|
|
5917
|
+
unsubscribeFromSignals(component);
|
|
5918
|
+
}
|
|
5919
|
+
}
|
|
5753
5920
|
function renderComponent(vm) {
|
|
5754
5921
|
if (process.env.NODE_ENV !== 'production') {
|
|
5755
5922
|
assert.invariant(vm.isDirty, `${vm} is not dirty.`);
|
|
5756
5923
|
}
|
|
5757
|
-
|
|
5924
|
+
// The engine should only hold a subscription to a signal if it is rendered in the template.
|
|
5925
|
+
// Because of the potential presence of conditional rendering logic, we unsubscribe on each render
|
|
5926
|
+
// in the scenario where it is present in one condition but not the other.
|
|
5927
|
+
// For example:
|
|
5928
|
+
// 1. There is an lwc:if=true conditional where the signal is present on the template.
|
|
5929
|
+
// 2. The lwc:if changes to false and the signal is no longer present on the template.
|
|
5930
|
+
// If the signal is still subscribed to, the template will re-render when it receives a notification
|
|
5931
|
+
// from the signal, even though we won't be using the new value.
|
|
5932
|
+
resetTemplateObserverAndUnsubscribe(vm);
|
|
5758
5933
|
const vnodes = invokeComponentRenderMethod(vm);
|
|
5759
5934
|
vm.isDirty = false;
|
|
5760
5935
|
vm.isScheduled = false;
|
|
@@ -5829,9 +6004,8 @@ function appendVM(vm) {
|
|
|
5829
6004
|
function resetComponentStateWhenRemoved(vm) {
|
|
5830
6005
|
const { state } = vm;
|
|
5831
6006
|
if (state !== 2 /* VMState.disconnected */) {
|
|
5832
|
-
const { tro } = vm;
|
|
5833
6007
|
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5834
|
-
|
|
6008
|
+
resetTemplateObserverAndUnsubscribe(vm);
|
|
5835
6009
|
runDisconnectedCallback(vm);
|
|
5836
6010
|
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5837
6011
|
runChildNodesDisconnectedCallback(vm);
|
|
@@ -6049,7 +6223,7 @@ function computeShadowMode(def, owner, renderer, hydrated) {
|
|
|
6049
6223
|
return shadowMode;
|
|
6050
6224
|
}
|
|
6051
6225
|
function assertIsVM(obj) {
|
|
6052
|
-
if (
|
|
6226
|
+
if (!isObject(obj) || isNull(obj) || !('renderRoot' in obj)) {
|
|
6053
6227
|
throw new TypeError(`${obj} is not a VM.`);
|
|
6054
6228
|
}
|
|
6055
6229
|
}
|
|
@@ -6144,7 +6318,7 @@ function flushRehydrationQueue() {
|
|
|
6144
6318
|
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
6145
6319
|
// re-throwing the original error will break the current tick, but since the next tick is
|
|
6146
6320
|
// already scheduled, it should continue patching the rest.
|
|
6147
|
-
throw error;
|
|
6321
|
+
throw error;
|
|
6148
6322
|
}
|
|
6149
6323
|
}
|
|
6150
6324
|
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
@@ -6242,6 +6416,7 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
6242
6416
|
* need to continue into its children because by attempting to disconnect the
|
|
6243
6417
|
* custom element itself will trigger the removal of anything slotted or anything
|
|
6244
6418
|
* defined on its shadow.
|
|
6419
|
+
* @param vnodes
|
|
6245
6420
|
*/
|
|
6246
6421
|
function recursivelyDisconnectChildren(vnodes) {
|
|
6247
6422
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
@@ -6617,7 +6792,7 @@ function checkAndReportViolation(elm, prop, isSetter, setValue) {
|
|
|
6617
6792
|
setValueType = isNull(setValue) ? 'null' : typeof setValue;
|
|
6618
6793
|
}
|
|
6619
6794
|
report("NonStandardAriaReflection" /* ReportingEventId.NonStandardAriaReflection */, {
|
|
6620
|
-
tagName: vm
|
|
6795
|
+
tagName: vm?.tagName,
|
|
6621
6796
|
propertyName: prop,
|
|
6622
6797
|
isSetter,
|
|
6623
6798
|
setValueType,
|
|
@@ -6695,7 +6870,6 @@ function hydrateVM(vm) {
|
|
|
6695
6870
|
runRenderedCallback(vm);
|
|
6696
6871
|
}
|
|
6697
6872
|
function hydrateNode(node, vnode, renderer) {
|
|
6698
|
-
var _a, _b;
|
|
6699
6873
|
let hydratedNode;
|
|
6700
6874
|
switch (vnode.type) {
|
|
6701
6875
|
case 0 /* VNodeType.Text */:
|
|
@@ -6715,10 +6889,10 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
6715
6889
|
hydratedNode = hydrateFragment(node, vnode, renderer);
|
|
6716
6890
|
break;
|
|
6717
6891
|
case 2 /* VNodeType.Element */:
|
|
6718
|
-
hydratedNode = hydrateElement(node, vnode,
|
|
6892
|
+
hydratedNode = hydrateElement(node, vnode, vnode.data.renderer ?? renderer);
|
|
6719
6893
|
break;
|
|
6720
6894
|
case 3 /* VNodeType.CustomElement */:
|
|
6721
|
-
hydratedNode = hydrateCustomElement(node, vnode,
|
|
6895
|
+
hydratedNode = hydrateCustomElement(node, vnode, vnode.data.renderer ?? renderer);
|
|
6722
6896
|
break;
|
|
6723
6897
|
}
|
|
6724
6898
|
return renderer.nextSibling(hydratedNode);
|
|
@@ -6761,7 +6935,6 @@ function getValidationPredicate(optOutStaticProp) {
|
|
|
6761
6935
|
return (_attrName) => true;
|
|
6762
6936
|
}
|
|
6763
6937
|
function hydrateText(node, vnode, renderer) {
|
|
6764
|
-
var _a;
|
|
6765
6938
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6766
6939
|
return handleMismatch(node, vnode, renderer);
|
|
6767
6940
|
}
|
|
@@ -6771,12 +6944,11 @@ function hydrateText(node, vnode, renderer) {
|
|
|
6771
6944
|
}
|
|
6772
6945
|
}
|
|
6773
6946
|
const { setText } = renderer;
|
|
6774
|
-
setText(node,
|
|
6947
|
+
setText(node, vnode.text ?? null);
|
|
6775
6948
|
vnode.elm = node;
|
|
6776
6949
|
return node;
|
|
6777
6950
|
}
|
|
6778
6951
|
function hydrateComment(node, vnode, renderer) {
|
|
6779
|
-
var _a;
|
|
6780
6952
|
if (!hasCorrectNodeType(vnode, node, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
6781
6953
|
return handleMismatch(node, vnode, renderer);
|
|
6782
6954
|
}
|
|
@@ -6788,7 +6960,7 @@ function hydrateComment(node, vnode, renderer) {
|
|
|
6788
6960
|
}
|
|
6789
6961
|
}
|
|
6790
6962
|
const { setProperty } = renderer;
|
|
6791
|
-
setProperty(node, NODE_VALUE_PROP,
|
|
6963
|
+
setProperty(node, NODE_VALUE_PROP, vnode.text ?? null);
|
|
6792
6964
|
vnode.elm = node;
|
|
6793
6965
|
return node;
|
|
6794
6966
|
}
|
|
@@ -6798,7 +6970,7 @@ function hydrateStaticElement(elm, vnode, renderer) {
|
|
|
6798
6970
|
return handleMismatch(elm, vnode, renderer);
|
|
6799
6971
|
}
|
|
6800
6972
|
vnode.elm = elm;
|
|
6801
|
-
|
|
6973
|
+
mountStaticParts(elm, vnode, renderer);
|
|
6802
6974
|
return elm;
|
|
6803
6975
|
}
|
|
6804
6976
|
function hydrateFragment(elm, vnode, renderer) {
|
|
@@ -6823,7 +6995,10 @@ function hydrateElement(elm, vnode, renderer) {
|
|
|
6823
6995
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6824
6996
|
if (getProperty(elm, 'innerHTML') === props.innerHTML) {
|
|
6825
6997
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6826
|
-
vnode.data =
|
|
6998
|
+
vnode.data = {
|
|
6999
|
+
...vnode.data,
|
|
7000
|
+
props: cloneAndOmitKey(props, 'innerHTML'),
|
|
7001
|
+
};
|
|
6827
7002
|
}
|
|
6828
7003
|
else {
|
|
6829
7004
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7035,7 +7210,11 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
7035
7210
|
className = ArrayJoin.call(classNames, ' ');
|
|
7036
7211
|
}
|
|
7037
7212
|
else if (!isUndefined$1(classMap)) {
|
|
7038
|
-
classMap =
|
|
7213
|
+
classMap = {
|
|
7214
|
+
...classMap,
|
|
7215
|
+
...(!isNull(scopedToken) ? { [scopedToken]: true } : {}),
|
|
7216
|
+
...(!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}),
|
|
7217
|
+
};
|
|
7039
7218
|
}
|
|
7040
7219
|
else {
|
|
7041
7220
|
// The order of the className should be scopedToken stylesheetTokenHost
|
|
@@ -7393,6 +7572,7 @@ function freezeTemplate(tmpl) {
|
|
|
7393
7572
|
/**
|
|
7394
7573
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
7395
7574
|
* This API is subject to change or being removed.
|
|
7575
|
+
* @param elm
|
|
7396
7576
|
*/
|
|
7397
7577
|
function getComponentConstructor(elm) {
|
|
7398
7578
|
let ctor = null;
|
|
@@ -7417,6 +7597,7 @@ function getComponentConstructor(elm) {
|
|
|
7417
7597
|
* EXPERIMENTAL: This function allows you to create a reactive readonly
|
|
7418
7598
|
* membrane around any object value. This API is subject to change or
|
|
7419
7599
|
* being removed.
|
|
7600
|
+
* @param obj
|
|
7420
7601
|
*/
|
|
7421
7602
|
function readonly(obj) {
|
|
7422
7603
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7429,5 +7610,5 @@ function readonly(obj) {
|
|
|
7429
7610
|
}
|
|
7430
7611
|
|
|
7431
7612
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
7432
|
-
/** version: 6.
|
|
7613
|
+
/** version: 6.2.1 */
|
|
7433
7614
|
//# sourceMappingURL=index.js.map
|