@lwc/engine-core 2.25.1 → 2.27.0
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/engine-core.cjs.js +269 -328
- package/dist/engine-core.js +271 -329
- package/package.json +3 -3
- package/types/framework/api.d.ts +3 -1
- package/types/framework/main.d.ts +1 -2
- package/types/framework/renderer.d.ts +2 -3
- package/types/framework/stylesheet.d.ts +2 -0
- package/types/framework/template.d.ts +1 -0
- package/types/framework/vm.d.ts +6 -2
- package/types/framework/vnodes.d.ts +10 -2
- package/types/framework/upgradable-element.d.ts +0 -7
package/dist/engine-core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
import { lwcRuntimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
-
import { seal, create, isUndefined as isUndefined$1, isFunction as isFunction$1, ArrayPush as ArrayPush$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, freeze, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
4
|
+
import { seal, create, isUndefined as isUndefined$1, isFunction as isFunction$1, ArrayPush as ArrayPush$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, freeze, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArrayConcat as ArrayConcat$1, isNumber, StringReplace, noop, ArrayUnshift, ArrayFilter, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1462,7 +1462,9 @@ const refsCache = new WeakMap();
|
|
|
1462
1462
|
const LightningElement = function () {
|
|
1463
1463
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1464
1464
|
if (isNull(vmBeingConstructed)) {
|
|
1465
|
-
|
|
1465
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1466
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1467
|
+
throw new TypeError('Illegal constructor');
|
|
1466
1468
|
}
|
|
1467
1469
|
const vm = vmBeingConstructed;
|
|
1468
1470
|
const { def, elm } = vm;
|
|
@@ -2526,274 +2528,213 @@ const swappedStyleMap = new WeakMap();
|
|
|
2526
2528
|
const activeTemplates = new WeakMap();
|
|
2527
2529
|
const activeComponents = new WeakMap();
|
|
2528
2530
|
const activeStyles = new WeakMap();
|
|
2529
|
-
|
|
2530
2531
|
function rehydrateHotTemplate(tpl) {
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
return true;
|
|
2532
|
+
const list = activeTemplates.get(tpl);
|
|
2533
|
+
if (!isUndefined$1(list)) {
|
|
2534
|
+
list.forEach((vm) => {
|
|
2535
|
+
if (isFalse(vm.isDirty)) {
|
|
2536
|
+
// forcing the vm to rehydrate in the micro-task:
|
|
2537
|
+
markComponentAsDirty(vm);
|
|
2538
|
+
scheduleRehydration(vm);
|
|
2539
|
+
}
|
|
2540
|
+
});
|
|
2541
|
+
// resetting the Set to release the memory of those vm references
|
|
2542
|
+
// since they are not longer related to this template, instead
|
|
2543
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2544
|
+
list.clear();
|
|
2545
|
+
}
|
|
2546
|
+
return true;
|
|
2548
2547
|
}
|
|
2549
|
-
|
|
2550
2548
|
function rehydrateHotStyle(style) {
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
return true;
|
|
2549
|
+
const list = activeStyles.get(style);
|
|
2550
|
+
if (!isUndefined$1(list)) {
|
|
2551
|
+
list.forEach((vm) => {
|
|
2552
|
+
// if a style definition is swapped, we must reset
|
|
2553
|
+
// vm's template content in the next micro-task:
|
|
2554
|
+
forceRehydration(vm);
|
|
2555
|
+
});
|
|
2556
|
+
// resetting the Set to release the memory of those vm references
|
|
2557
|
+
// since they are not longer related to this style, instead
|
|
2558
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2559
|
+
list.clear();
|
|
2560
|
+
}
|
|
2561
|
+
return true;
|
|
2566
2562
|
}
|
|
2567
|
-
|
|
2568
2563
|
function rehydrateHotComponent(Ctor) {
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
list.clear();
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
return canRefreshAllInstances;
|
|
2564
|
+
const list = activeComponents.get(Ctor);
|
|
2565
|
+
let canRefreshAllInstances = true;
|
|
2566
|
+
if (!isUndefined$1(list)) {
|
|
2567
|
+
list.forEach((vm) => {
|
|
2568
|
+
const { owner } = vm;
|
|
2569
|
+
if (!isNull(owner)) {
|
|
2570
|
+
// if a component class definition is swapped, we must reset
|
|
2571
|
+
// owner's template content in the next micro-task:
|
|
2572
|
+
forceRehydration(owner);
|
|
2573
|
+
}
|
|
2574
|
+
else {
|
|
2575
|
+
// the hot swapping for components only work for instances of components
|
|
2576
|
+
// created from a template, root elements can't be swapped because we
|
|
2577
|
+
// don't have a way to force the creation of the element with the same state
|
|
2578
|
+
// of the current element.
|
|
2579
|
+
// Instead, we can report the problem to the caller so it can take action,
|
|
2580
|
+
// for example: reload the entire page.
|
|
2581
|
+
canRefreshAllInstances = false;
|
|
2582
|
+
}
|
|
2583
|
+
});
|
|
2584
|
+
// resetting the Set to release the memory of those vm references
|
|
2585
|
+
// since they are not longer related to this constructor, instead
|
|
2586
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2587
|
+
list.clear();
|
|
2588
|
+
}
|
|
2589
|
+
return canRefreshAllInstances;
|
|
2599
2590
|
}
|
|
2600
|
-
|
|
2601
2591
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2592
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2593
|
+
// this method should never leak to prod
|
|
2594
|
+
throw new ReferenceError();
|
|
2595
|
+
}
|
|
2608
2596
|
const visited = new Set();
|
|
2609
|
-
|
|
2610
2597
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
2611
|
-
|
|
2612
|
-
|
|
2598
|
+
visited.add(tpl);
|
|
2599
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
2613
2600
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
return tpl;
|
|
2601
|
+
return tpl;
|
|
2617
2602
|
}
|
|
2618
2603
|
function getComponentOrSwappedComponent(Ctor) {
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2604
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2605
|
+
// this method should never leak to prod
|
|
2606
|
+
throw new ReferenceError();
|
|
2607
|
+
}
|
|
2625
2608
|
const visited = new Set();
|
|
2626
|
-
|
|
2627
2609
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
2628
|
-
|
|
2629
|
-
|
|
2610
|
+
visited.add(Ctor);
|
|
2611
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
2630
2612
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
return Ctor;
|
|
2613
|
+
return Ctor;
|
|
2634
2614
|
}
|
|
2635
2615
|
function getStyleOrSwappedStyle(style) {
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2616
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2617
|
+
// this method should never leak to prod
|
|
2618
|
+
throw new ReferenceError();
|
|
2619
|
+
}
|
|
2642
2620
|
const visited = new Set();
|
|
2643
|
-
|
|
2644
2621
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
2645
|
-
|
|
2646
|
-
|
|
2622
|
+
visited.add(style);
|
|
2623
|
+
style = swappedStyleMap.get(style);
|
|
2647
2624
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
return style;
|
|
2625
|
+
return style;
|
|
2651
2626
|
}
|
|
2652
2627
|
function setActiveVM(vm) {
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2628
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2629
|
+
// this method should never leak to prod
|
|
2630
|
+
throw new ReferenceError();
|
|
2631
|
+
}
|
|
2659
2632
|
// tracking active component
|
|
2660
2633
|
const Ctor = vm.def.ctor;
|
|
2661
2634
|
let componentVMs = activeComponents.get(Ctor);
|
|
2662
|
-
|
|
2663
2635
|
if (isUndefined$1(componentVMs)) {
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2636
|
+
componentVMs = new Set();
|
|
2637
|
+
activeComponents.set(Ctor, componentVMs);
|
|
2638
|
+
}
|
|
2639
|
+
// this will allow us to keep track of the hot components
|
|
2640
|
+
componentVMs.add(vm);
|
|
2641
|
+
// tracking active template
|
|
2671
2642
|
const tpl = vm.cmpTemplate;
|
|
2672
|
-
|
|
2673
2643
|
if (tpl) {
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
stylesheetVMs.add(vm);
|
|
2704
|
-
});
|
|
2705
|
-
}
|
|
2644
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
2645
|
+
if (isUndefined$1(templateVMs)) {
|
|
2646
|
+
templateVMs = new Set();
|
|
2647
|
+
activeTemplates.set(tpl, templateVMs);
|
|
2648
|
+
}
|
|
2649
|
+
// this will allow us to keep track of the templates that are
|
|
2650
|
+
// being used by a hot component
|
|
2651
|
+
templateVMs.add(vm);
|
|
2652
|
+
// tracking active styles associated to template
|
|
2653
|
+
const stylesheets = tpl.stylesheets;
|
|
2654
|
+
if (!isUndefined$1(stylesheets)) {
|
|
2655
|
+
flattenStylesheets(stylesheets).forEach((stylesheet) => {
|
|
2656
|
+
// this is necessary because we don't hold the list of styles
|
|
2657
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
2658
|
+
// but the styles attached to the template might not be the actual
|
|
2659
|
+
// active ones, but the swapped versions of those.
|
|
2660
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
2661
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
2662
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
2663
|
+
stylesheetVMs = new Set();
|
|
2664
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
2665
|
+
}
|
|
2666
|
+
// this will allow us to keep track of the stylesheet that are
|
|
2667
|
+
// being used by a hot component
|
|
2668
|
+
stylesheetVMs.add(vm);
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2706
2671
|
}
|
|
2707
|
-
}
|
|
2708
2672
|
}
|
|
2709
2673
|
function removeActiveVM(vm) {
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2674
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2675
|
+
// this method should never leak to prod
|
|
2676
|
+
throw new ReferenceError();
|
|
2677
|
+
}
|
|
2716
2678
|
// tracking inactive component
|
|
2717
2679
|
const Ctor = vm.def.ctor;
|
|
2718
2680
|
let list = activeComponents.get(Ctor);
|
|
2719
|
-
|
|
2720
2681
|
if (!isUndefined$1(list)) {
|
|
2721
|
-
// deleting the vm from the set to avoid leaking memory
|
|
2722
|
-
list.delete(vm);
|
|
2723
|
-
} // removing inactive template
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
const tpl = vm.cmpTemplate;
|
|
2727
|
-
|
|
2728
|
-
if (tpl) {
|
|
2729
|
-
list = activeTemplates.get(tpl);
|
|
2730
|
-
|
|
2731
|
-
if (!isUndefined$1(list)) {
|
|
2732
2682
|
// deleting the vm from the set to avoid leaking memory
|
|
2733
2683
|
list.delete(vm);
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
flattenStylesheets(styles).forEach(style => {
|
|
2741
|
-
list = activeStyles.get(style);
|
|
2742
|
-
|
|
2743
|
-
if (!isUndefined$1(list)) {
|
|
2684
|
+
}
|
|
2685
|
+
// removing inactive template
|
|
2686
|
+
const tpl = vm.cmpTemplate;
|
|
2687
|
+
if (tpl) {
|
|
2688
|
+
list = activeTemplates.get(tpl);
|
|
2689
|
+
if (!isUndefined$1(list)) {
|
|
2744
2690
|
// deleting the vm from the set to avoid leaking memory
|
|
2745
2691
|
list.delete(vm);
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2692
|
+
}
|
|
2693
|
+
// removing active styles associated to template
|
|
2694
|
+
const styles = tpl.stylesheets;
|
|
2695
|
+
if (!isUndefined$1(styles)) {
|
|
2696
|
+
flattenStylesheets(styles).forEach((style) => {
|
|
2697
|
+
list = activeStyles.get(style);
|
|
2698
|
+
if (!isUndefined$1(list)) {
|
|
2699
|
+
// deleting the vm from the set to avoid leaking memory
|
|
2700
|
+
list.delete(vm);
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2749
2704
|
}
|
|
2750
|
-
}
|
|
2751
2705
|
}
|
|
2752
2706
|
function swapTemplate(oldTpl, newTpl) {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2707
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2708
|
+
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
2709
|
+
swappedTemplateMap.set(oldTpl, newTpl);
|
|
2710
|
+
return rehydrateHotTemplate(oldTpl);
|
|
2711
|
+
}
|
|
2712
|
+
else {
|
|
2713
|
+
throw new TypeError(`Invalid Template`);
|
|
2714
|
+
}
|
|
2759
2715
|
}
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2763
|
-
throw new Error('HMR is not enabled');
|
|
2764
|
-
}
|
|
2765
|
-
|
|
2766
|
-
return false;
|
|
2716
|
+
return false;
|
|
2767
2717
|
}
|
|
2768
2718
|
function swapComponent(oldComponent, newComponent) {
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2719
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2720
|
+
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
2721
|
+
swappedComponentMap.set(oldComponent, newComponent);
|
|
2722
|
+
return rehydrateHotComponent(oldComponent);
|
|
2723
|
+
}
|
|
2724
|
+
else {
|
|
2725
|
+
throw new TypeError(`Invalid Component`);
|
|
2726
|
+
}
|
|
2775
2727
|
}
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2779
|
-
throw new Error('HMR is not enabled');
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
|
-
return false;
|
|
2728
|
+
return false;
|
|
2783
2729
|
}
|
|
2784
2730
|
function swapStyle(oldStyle, newStyle) {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2793
|
-
throw new Error('HMR is not enabled');
|
|
2794
|
-
}
|
|
2795
|
-
|
|
2796
|
-
return false;
|
|
2731
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2732
|
+
// TODO [#1887]: once the support for registering styles is implemented
|
|
2733
|
+
// we can add the validation of both styles around this block.
|
|
2734
|
+
swappedStyleMap.set(oldStyle, newStyle);
|
|
2735
|
+
return rehydrateHotStyle(oldStyle);
|
|
2736
|
+
}
|
|
2737
|
+
return false;
|
|
2797
2738
|
}
|
|
2798
2739
|
|
|
2799
2740
|
/*
|
|
@@ -3204,15 +3145,18 @@ function getScopeTokenClass(owner) {
|
|
|
3204
3145
|
/**
|
|
3205
3146
|
* This function returns the host style token for a custom element if it
|
|
3206
3147
|
* exists. Otherwise it returns null.
|
|
3148
|
+
*
|
|
3149
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3207
3150
|
*/
|
|
3208
3151
|
|
|
3209
3152
|
function getStylesheetTokenHost(vnode) {
|
|
3210
3153
|
const {
|
|
3211
|
-
template
|
|
3212
|
-
stylesheetToken
|
|
3213
|
-
}
|
|
3154
|
+
template
|
|
3214
3155
|
} = getComponentInternalDef(vnode.ctor);
|
|
3215
|
-
|
|
3156
|
+
const {
|
|
3157
|
+
stylesheetToken
|
|
3158
|
+
} = template;
|
|
3159
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3216
3160
|
}
|
|
3217
3161
|
|
|
3218
3162
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3266,75 +3210,6 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3266
3210
|
return null;
|
|
3267
3211
|
}
|
|
3268
3212
|
|
|
3269
|
-
/*
|
|
3270
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3271
|
-
* All rights reserved.
|
|
3272
|
-
* SPDX-License-Identifier: MIT
|
|
3273
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3274
|
-
*/
|
|
3275
|
-
|
|
3276
|
-
function checkHasVM(elm) {
|
|
3277
|
-
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3278
|
-
|
|
3279
|
-
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3280
|
-
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3281
|
-
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3282
|
-
logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
|
|
3283
|
-
}
|
|
3284
|
-
|
|
3285
|
-
return hasVM;
|
|
3286
|
-
}
|
|
3287
|
-
|
|
3288
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
3289
|
-
const {
|
|
3290
|
-
getCustomElement,
|
|
3291
|
-
HTMLElementExported: RendererHTMLElement,
|
|
3292
|
-
defineCustomElement
|
|
3293
|
-
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3294
|
-
// produce only tags with lowercase letters
|
|
3295
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3296
|
-
|
|
3297
|
-
tagName = tagName.toLowerCase();
|
|
3298
|
-
let CE = getCustomElement(tagName);
|
|
3299
|
-
|
|
3300
|
-
if (!isUndefined$1(CE)) {
|
|
3301
|
-
return CE;
|
|
3302
|
-
}
|
|
3303
|
-
/**
|
|
3304
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3305
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3306
|
-
*/
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3310
|
-
constructor(upgradeCallback) {
|
|
3311
|
-
super();
|
|
3312
|
-
|
|
3313
|
-
if (isFunction$1(upgradeCallback)) {
|
|
3314
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3315
|
-
}
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
};
|
|
3319
|
-
|
|
3320
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3321
|
-
CE.prototype.connectedCallback = function () {
|
|
3322
|
-
if (checkHasVM(this)) {
|
|
3323
|
-
connectRootElement(this);
|
|
3324
|
-
}
|
|
3325
|
-
};
|
|
3326
|
-
|
|
3327
|
-
CE.prototype.disconnectedCallback = function () {
|
|
3328
|
-
if (checkHasVM(this)) {
|
|
3329
|
-
disconnectRootElement(this);
|
|
3330
|
-
}
|
|
3331
|
-
};
|
|
3332
|
-
}
|
|
3333
|
-
|
|
3334
|
-
defineCustomElement(tagName, CE);
|
|
3335
|
-
return CE;
|
|
3336
|
-
}
|
|
3337
|
-
|
|
3338
3213
|
/*
|
|
3339
3214
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3340
3215
|
* All rights reserved.
|
|
@@ -3351,6 +3226,9 @@ function isSameVnode(vnode1, vnode2) {
|
|
|
3351
3226
|
function isVCustomElement(vnode) {
|
|
3352
3227
|
return vnode.type === 3 /* VNodeType.CustomElement */;
|
|
3353
3228
|
}
|
|
3229
|
+
function isVScopedSlotFragment(vnode) {
|
|
3230
|
+
return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
|
|
3231
|
+
}
|
|
3354
3232
|
|
|
3355
3233
|
/*
|
|
3356
3234
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3848,7 +3726,9 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3848
3726
|
sel,
|
|
3849
3727
|
owner
|
|
3850
3728
|
} = vnode;
|
|
3851
|
-
const
|
|
3729
|
+
const {
|
|
3730
|
+
createCustomElement
|
|
3731
|
+
} = renderer;
|
|
3852
3732
|
/**
|
|
3853
3733
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3854
3734
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3857,10 +3737,25 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3857
3737
|
*/
|
|
3858
3738
|
|
|
3859
3739
|
let vm;
|
|
3860
|
-
|
|
3740
|
+
|
|
3741
|
+
const upgradeCallback = elm => {
|
|
3861
3742
|
// the custom element from the registry is expecting an upgrade callback
|
|
3862
3743
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3863
|
-
}
|
|
3744
|
+
};
|
|
3745
|
+
|
|
3746
|
+
const connectedCallback = elm => {
|
|
3747
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3748
|
+
connectRootElement(elm);
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3752
|
+
const disconnectedCallback = elm => {
|
|
3753
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3754
|
+
disconnectRootElement(elm);
|
|
3755
|
+
}
|
|
3756
|
+
};
|
|
3757
|
+
|
|
3758
|
+
const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3864
3759
|
vnode.elm = elm;
|
|
3865
3760
|
vnode.vm = vm;
|
|
3866
3761
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3868,8 +3763,6 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3868
3763
|
|
|
3869
3764
|
if (vm) {
|
|
3870
3765
|
allocateChildren(vnode, vm);
|
|
3871
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3872
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
3873
3766
|
}
|
|
3874
3767
|
|
|
3875
3768
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -4174,7 +4067,7 @@ function allocateChildren(vnode, vm) {
|
|
|
4174
4067
|
/* RenderMode.Light */
|
|
4175
4068
|
) {
|
|
4176
4069
|
// slow path
|
|
4177
|
-
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4070
|
+
allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
|
|
4178
4071
|
|
|
4179
4072
|
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4180
4073
|
|
|
@@ -4210,13 +4103,19 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4210
4103
|
return vm;
|
|
4211
4104
|
}
|
|
4212
4105
|
|
|
4213
|
-
function allocateInSlot(vm, children) {
|
|
4214
|
-
var _a;
|
|
4106
|
+
function allocateInSlot(vm, children, owner) {
|
|
4107
|
+
var _a, _b;
|
|
4215
4108
|
|
|
4216
4109
|
const {
|
|
4217
|
-
cmpSlots:
|
|
4110
|
+
cmpSlots: {
|
|
4111
|
+
slotAssignments: oldSlotsMapping
|
|
4112
|
+
}
|
|
4218
4113
|
} = vm;
|
|
4219
|
-
const
|
|
4114
|
+
const cmpSlotsMapping = create(null);
|
|
4115
|
+
vm.cmpSlots = {
|
|
4116
|
+
owner,
|
|
4117
|
+
slotAssignments: cmpSlotsMapping
|
|
4118
|
+
};
|
|
4220
4119
|
|
|
4221
4120
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4222
4121
|
const vnode = children[i];
|
|
@@ -4228,19 +4127,21 @@ function allocateInSlot(vm, children) {
|
|
|
4228
4127
|
let slotName = '';
|
|
4229
4128
|
|
|
4230
4129
|
if (isVBaseElement(vnode)) {
|
|
4231
|
-
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot)
|
|
4130
|
+
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4131
|
+
} else if (isVScopedSlotFragment(vnode)) {
|
|
4132
|
+
slotName = vnode.slotName;
|
|
4232
4133
|
}
|
|
4233
4134
|
|
|
4234
|
-
const vnodes =
|
|
4135
|
+
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4235
4136
|
ArrayPush$1.call(vnodes, vnode);
|
|
4236
4137
|
}
|
|
4237
4138
|
|
|
4238
4139
|
if (isFalse(vm.isDirty)) {
|
|
4239
4140
|
// We need to determine if the old allocation is really different from the new one
|
|
4240
4141
|
// and mark the vm as dirty
|
|
4241
|
-
const oldKeys = keys(
|
|
4142
|
+
const oldKeys = keys(oldSlotsMapping);
|
|
4242
4143
|
|
|
4243
|
-
if (oldKeys.length !== keys(
|
|
4144
|
+
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4244
4145
|
markComponentAsDirty(vm);
|
|
4245
4146
|
return;
|
|
4246
4147
|
}
|
|
@@ -4248,15 +4149,15 @@ function allocateInSlot(vm, children) {
|
|
|
4248
4149
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4249
4150
|
const key = oldKeys[i];
|
|
4250
4151
|
|
|
4251
|
-
if (isUndefined$1(
|
|
4152
|
+
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4252
4153
|
markComponentAsDirty(vm);
|
|
4253
4154
|
return;
|
|
4254
4155
|
}
|
|
4255
4156
|
|
|
4256
|
-
const oldVNodes =
|
|
4257
|
-
const vnodes =
|
|
4157
|
+
const oldVNodes = oldSlotsMapping[key];
|
|
4158
|
+
const vnodes = cmpSlotsMapping[key];
|
|
4258
4159
|
|
|
4259
|
-
for (let j = 0, a =
|
|
4160
|
+
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4260
4161
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
4261
4162
|
markComponentAsDirty(vm);
|
|
4262
4163
|
return;
|
|
@@ -4456,6 +4357,18 @@ const SymbolIterator = Symbol.iterator;
|
|
|
4456
4357
|
function addVNodeToChildLWC(vnode) {
|
|
4457
4358
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
4458
4359
|
}
|
|
4360
|
+
// [s]coped [s]lot [f]actory
|
|
4361
|
+
function ssf(slotName, factory) {
|
|
4362
|
+
return {
|
|
4363
|
+
type: 6 /* VNodeType.ScopedSlotFragment */,
|
|
4364
|
+
factory,
|
|
4365
|
+
owner: getVMBeingRendered(),
|
|
4366
|
+
elm: undefined,
|
|
4367
|
+
sel: undefined,
|
|
4368
|
+
key: undefined,
|
|
4369
|
+
slotName,
|
|
4370
|
+
};
|
|
4371
|
+
}
|
|
4459
4372
|
// [st]atic node
|
|
4460
4373
|
function st(fragment, key) {
|
|
4461
4374
|
return {
|
|
@@ -4539,9 +4452,31 @@ function s(slotName, data, children, slotset) {
|
|
|
4539
4452
|
assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
|
|
4540
4453
|
}
|
|
4541
4454
|
if (!isUndefined$1(slotset) &&
|
|
4542
|
-
!isUndefined$1(slotset
|
|
4543
|
-
slotset[slotName]
|
|
4544
|
-
|
|
4455
|
+
!isUndefined$1(slotset.slotAssignments) &&
|
|
4456
|
+
!isUndefined$1(slotset.slotAssignments[slotName]) &&
|
|
4457
|
+
slotset.slotAssignments[slotName].length !== 0) {
|
|
4458
|
+
children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
|
|
4459
|
+
// If the passed slot content is factory, evaluate it and use the produced vnodes
|
|
4460
|
+
if (vnode && isVScopedSlotFragment(vnode)) {
|
|
4461
|
+
const vmBeingRenderedInception = getVMBeingRendered();
|
|
4462
|
+
let children = [];
|
|
4463
|
+
// Evaluate in the scope of the slot content's owner
|
|
4464
|
+
// if a slotset is provided, there will always be an owner. The only case where owner is
|
|
4465
|
+
// undefined is for root components, but root components cannot accept slotted content
|
|
4466
|
+
setVMBeingRendered(slotset.owner);
|
|
4467
|
+
try {
|
|
4468
|
+
children = vnode.factory(data.slotData);
|
|
4469
|
+
}
|
|
4470
|
+
finally {
|
|
4471
|
+
setVMBeingRendered(vmBeingRenderedInception);
|
|
4472
|
+
}
|
|
4473
|
+
return ArrayConcat$1.call(acc, children);
|
|
4474
|
+
}
|
|
4475
|
+
else {
|
|
4476
|
+
// If the slot content is a static list of child nodes provided by the parent, nothing to do
|
|
4477
|
+
return ArrayConcat$1.call(acc, vnode);
|
|
4478
|
+
}
|
|
4479
|
+
}, []);
|
|
4545
4480
|
}
|
|
4546
4481
|
const vmBeingRendered = getVMBeingRendered();
|
|
4547
4482
|
const { renderMode, shadowMode } = vmBeingRendered;
|
|
@@ -4861,6 +4796,7 @@ const api = freeze({
|
|
|
4861
4796
|
gid,
|
|
4862
4797
|
fid,
|
|
4863
4798
|
shc,
|
|
4799
|
+
ssf,
|
|
4864
4800
|
});
|
|
4865
4801
|
|
|
4866
4802
|
/*
|
|
@@ -4997,9 +4933,9 @@ function validateSlots(vm, html) {
|
|
|
4997
4933
|
}
|
|
4998
4934
|
const { cmpSlots } = vm;
|
|
4999
4935
|
const { slots = EmptyArray } = html;
|
|
5000
|
-
for (const slotName in cmpSlots) {
|
|
4936
|
+
for (const slotName in cmpSlots.slotAssignments) {
|
|
5001
4937
|
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5002
|
-
assert.isTrue(isArray$1(cmpSlots[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
4938
|
+
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}.`);
|
|
5003
4939
|
if (slotName !== '' && ArrayIndexOf.call(slots, slotName) === -1) {
|
|
5004
4940
|
// TODO [#1297]: this should never really happen because the compiler should always validate
|
|
5005
4941
|
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
@@ -5496,7 +5432,9 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5496
5432
|
velements: EmptyArray,
|
|
5497
5433
|
cmpProps: create(null),
|
|
5498
5434
|
cmpFields: create(null),
|
|
5499
|
-
cmpSlots:
|
|
5435
|
+
cmpSlots: {
|
|
5436
|
+
slotAssignments: create(null)
|
|
5437
|
+
},
|
|
5500
5438
|
oar: create(null),
|
|
5501
5439
|
cmpTemplate: null,
|
|
5502
5440
|
hydrated: Boolean(hydrated),
|
|
@@ -6651,19 +6589,23 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6651
6589
|
//
|
|
6652
6590
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6653
6591
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6654
|
-
if (scopedToken) {
|
|
6592
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
6655
6593
|
if (!isUndefined$1(className)) {
|
|
6656
|
-
className
|
|
6657
|
-
|
|
6658
|
-
|
|
6594
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
6595
|
+
const classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
6596
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
6597
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
6659
6598
|
}
|
|
6660
6599
|
else if (!isUndefined$1(classMap)) {
|
|
6661
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {
|
|
6600
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
|
|
6662
6601
|
}
|
|
6663
6602
|
else {
|
|
6664
|
-
className
|
|
6665
|
-
|
|
6666
|
-
|
|
6603
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
6604
|
+
const classTokens = [scopedToken, stylesheetTokenHost];
|
|
6605
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
6606
|
+
if (classNames.length) {
|
|
6607
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
6608
|
+
}
|
|
6667
6609
|
}
|
|
6668
6610
|
}
|
|
6669
6611
|
let nodesAreCompatible = true;
|
|
@@ -6906,5 +6848,5 @@ function getComponentConstructor(elm) {
|
|
|
6906
6848
|
return ctor;
|
|
6907
6849
|
}
|
|
6908
6850
|
|
|
6909
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype,
|
|
6910
|
-
/* version: 2.
|
|
6851
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6852
|
+
/* version: 2.27.0 */
|