@lwc/engine-core 2.25.1 → 2.26.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 +202 -309
- package/dist/engine-core.js +204 -310
- package/package.json +3 -3
- 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/upgradable-element.d.ts +0 -7
package/dist/engine-core.cjs.js
CHANGED
|
@@ -1465,7 +1465,9 @@ const refsCache = new WeakMap();
|
|
|
1465
1465
|
const LightningElement = function () {
|
|
1466
1466
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1467
1467
|
if (shared.isNull(vmBeingConstructed)) {
|
|
1468
|
-
|
|
1468
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1469
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1470
|
+
throw new TypeError('Illegal constructor');
|
|
1469
1471
|
}
|
|
1470
1472
|
const vm = vmBeingConstructed;
|
|
1471
1473
|
const { def, elm } = vm;
|
|
@@ -2529,274 +2531,213 @@ const swappedStyleMap = new WeakMap();
|
|
|
2529
2531
|
const activeTemplates = new WeakMap();
|
|
2530
2532
|
const activeComponents = new WeakMap();
|
|
2531
2533
|
const activeStyles = new WeakMap();
|
|
2532
|
-
|
|
2533
2534
|
function rehydrateHotTemplate(tpl) {
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
return true;
|
|
2535
|
+
const list = activeTemplates.get(tpl);
|
|
2536
|
+
if (!shared.isUndefined(list)) {
|
|
2537
|
+
list.forEach((vm) => {
|
|
2538
|
+
if (shared.isFalse(vm.isDirty)) {
|
|
2539
|
+
// forcing the vm to rehydrate in the micro-task:
|
|
2540
|
+
markComponentAsDirty(vm);
|
|
2541
|
+
scheduleRehydration(vm);
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
// resetting the Set to release the memory of those vm references
|
|
2545
|
+
// since they are not longer related to this template, instead
|
|
2546
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2547
|
+
list.clear();
|
|
2548
|
+
}
|
|
2549
|
+
return true;
|
|
2551
2550
|
}
|
|
2552
|
-
|
|
2553
2551
|
function rehydrateHotStyle(style) {
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
return true;
|
|
2552
|
+
const list = activeStyles.get(style);
|
|
2553
|
+
if (!shared.isUndefined(list)) {
|
|
2554
|
+
list.forEach((vm) => {
|
|
2555
|
+
// if a style definition is swapped, we must reset
|
|
2556
|
+
// vm's template content in the next micro-task:
|
|
2557
|
+
forceRehydration(vm);
|
|
2558
|
+
});
|
|
2559
|
+
// resetting the Set to release the memory of those vm references
|
|
2560
|
+
// since they are not longer related to this style, instead
|
|
2561
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2562
|
+
list.clear();
|
|
2563
|
+
}
|
|
2564
|
+
return true;
|
|
2569
2565
|
}
|
|
2570
|
-
|
|
2571
2566
|
function rehydrateHotComponent(Ctor) {
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
list.clear();
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2601
|
-
return canRefreshAllInstances;
|
|
2567
|
+
const list = activeComponents.get(Ctor);
|
|
2568
|
+
let canRefreshAllInstances = true;
|
|
2569
|
+
if (!shared.isUndefined(list)) {
|
|
2570
|
+
list.forEach((vm) => {
|
|
2571
|
+
const { owner } = vm;
|
|
2572
|
+
if (!shared.isNull(owner)) {
|
|
2573
|
+
// if a component class definition is swapped, we must reset
|
|
2574
|
+
// owner's template content in the next micro-task:
|
|
2575
|
+
forceRehydration(owner);
|
|
2576
|
+
}
|
|
2577
|
+
else {
|
|
2578
|
+
// the hot swapping for components only work for instances of components
|
|
2579
|
+
// created from a template, root elements can't be swapped because we
|
|
2580
|
+
// don't have a way to force the creation of the element with the same state
|
|
2581
|
+
// of the current element.
|
|
2582
|
+
// Instead, we can report the problem to the caller so it can take action,
|
|
2583
|
+
// for example: reload the entire page.
|
|
2584
|
+
canRefreshAllInstances = false;
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
// resetting the Set to release the memory of those vm references
|
|
2588
|
+
// since they are not longer related to this constructor, instead
|
|
2589
|
+
// they will get re-associated once these instances are rehydrated.
|
|
2590
|
+
list.clear();
|
|
2591
|
+
}
|
|
2592
|
+
return canRefreshAllInstances;
|
|
2602
2593
|
}
|
|
2603
|
-
|
|
2604
2594
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2595
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2596
|
+
// this method should never leak to prod
|
|
2597
|
+
throw new ReferenceError();
|
|
2598
|
+
}
|
|
2611
2599
|
const visited = new Set();
|
|
2612
|
-
|
|
2613
2600
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
2614
|
-
|
|
2615
|
-
|
|
2601
|
+
visited.add(tpl);
|
|
2602
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
2616
2603
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
return tpl;
|
|
2604
|
+
return tpl;
|
|
2620
2605
|
}
|
|
2621
2606
|
function getComponentOrSwappedComponent(Ctor) {
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2607
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2608
|
+
// this method should never leak to prod
|
|
2609
|
+
throw new ReferenceError();
|
|
2610
|
+
}
|
|
2628
2611
|
const visited = new Set();
|
|
2629
|
-
|
|
2630
2612
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
2631
|
-
|
|
2632
|
-
|
|
2613
|
+
visited.add(Ctor);
|
|
2614
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
2633
2615
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
return Ctor;
|
|
2616
|
+
return Ctor;
|
|
2637
2617
|
}
|
|
2638
2618
|
function getStyleOrSwappedStyle(style) {
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2619
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2620
|
+
// this method should never leak to prod
|
|
2621
|
+
throw new ReferenceError();
|
|
2622
|
+
}
|
|
2645
2623
|
const visited = new Set();
|
|
2646
|
-
|
|
2647
2624
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
2648
|
-
|
|
2649
|
-
|
|
2625
|
+
visited.add(style);
|
|
2626
|
+
style = swappedStyleMap.get(style);
|
|
2650
2627
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
return style;
|
|
2628
|
+
return style;
|
|
2654
2629
|
}
|
|
2655
2630
|
function setActiveVM(vm) {
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2631
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2632
|
+
// this method should never leak to prod
|
|
2633
|
+
throw new ReferenceError();
|
|
2634
|
+
}
|
|
2662
2635
|
// tracking active component
|
|
2663
2636
|
const Ctor = vm.def.ctor;
|
|
2664
2637
|
let componentVMs = activeComponents.get(Ctor);
|
|
2665
|
-
|
|
2666
2638
|
if (shared.isUndefined(componentVMs)) {
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
}
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2639
|
+
componentVMs = new Set();
|
|
2640
|
+
activeComponents.set(Ctor, componentVMs);
|
|
2641
|
+
}
|
|
2642
|
+
// this will allow us to keep track of the hot components
|
|
2643
|
+
componentVMs.add(vm);
|
|
2644
|
+
// tracking active template
|
|
2674
2645
|
const tpl = vm.cmpTemplate;
|
|
2675
|
-
|
|
2676
2646
|
if (tpl) {
|
|
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
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
stylesheetVMs.add(vm);
|
|
2707
|
-
});
|
|
2708
|
-
}
|
|
2647
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
2648
|
+
if (shared.isUndefined(templateVMs)) {
|
|
2649
|
+
templateVMs = new Set();
|
|
2650
|
+
activeTemplates.set(tpl, templateVMs);
|
|
2651
|
+
}
|
|
2652
|
+
// this will allow us to keep track of the templates that are
|
|
2653
|
+
// being used by a hot component
|
|
2654
|
+
templateVMs.add(vm);
|
|
2655
|
+
// tracking active styles associated to template
|
|
2656
|
+
const stylesheets = tpl.stylesheets;
|
|
2657
|
+
if (!shared.isUndefined(stylesheets)) {
|
|
2658
|
+
flattenStylesheets(stylesheets).forEach((stylesheet) => {
|
|
2659
|
+
// this is necessary because we don't hold the list of styles
|
|
2660
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
2661
|
+
// but the styles attached to the template might not be the actual
|
|
2662
|
+
// active ones, but the swapped versions of those.
|
|
2663
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
2664
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
2665
|
+
if (shared.isUndefined(stylesheetVMs)) {
|
|
2666
|
+
stylesheetVMs = new Set();
|
|
2667
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
2668
|
+
}
|
|
2669
|
+
// this will allow us to keep track of the stylesheet that are
|
|
2670
|
+
// being used by a hot component
|
|
2671
|
+
stylesheetVMs.add(vm);
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2709
2674
|
}
|
|
2710
|
-
}
|
|
2711
2675
|
}
|
|
2712
2676
|
function removeActiveVM(vm) {
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2677
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2678
|
+
// this method should never leak to prod
|
|
2679
|
+
throw new ReferenceError();
|
|
2680
|
+
}
|
|
2719
2681
|
// tracking inactive component
|
|
2720
2682
|
const Ctor = vm.def.ctor;
|
|
2721
2683
|
let list = activeComponents.get(Ctor);
|
|
2722
|
-
|
|
2723
2684
|
if (!shared.isUndefined(list)) {
|
|
2724
|
-
// deleting the vm from the set to avoid leaking memory
|
|
2725
|
-
list.delete(vm);
|
|
2726
|
-
} // removing inactive template
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
const tpl = vm.cmpTemplate;
|
|
2730
|
-
|
|
2731
|
-
if (tpl) {
|
|
2732
|
-
list = activeTemplates.get(tpl);
|
|
2733
|
-
|
|
2734
|
-
if (!shared.isUndefined(list)) {
|
|
2735
2685
|
// deleting the vm from the set to avoid leaking memory
|
|
2736
2686
|
list.delete(vm);
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
flattenStylesheets(styles).forEach(style => {
|
|
2744
|
-
list = activeStyles.get(style);
|
|
2745
|
-
|
|
2746
|
-
if (!shared.isUndefined(list)) {
|
|
2687
|
+
}
|
|
2688
|
+
// removing inactive template
|
|
2689
|
+
const tpl = vm.cmpTemplate;
|
|
2690
|
+
if (tpl) {
|
|
2691
|
+
list = activeTemplates.get(tpl);
|
|
2692
|
+
if (!shared.isUndefined(list)) {
|
|
2747
2693
|
// deleting the vm from the set to avoid leaking memory
|
|
2748
2694
|
list.delete(vm);
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2695
|
+
}
|
|
2696
|
+
// removing active styles associated to template
|
|
2697
|
+
const styles = tpl.stylesheets;
|
|
2698
|
+
if (!shared.isUndefined(styles)) {
|
|
2699
|
+
flattenStylesheets(styles).forEach((style) => {
|
|
2700
|
+
list = activeStyles.get(style);
|
|
2701
|
+
if (!shared.isUndefined(list)) {
|
|
2702
|
+
// deleting the vm from the set to avoid leaking memory
|
|
2703
|
+
list.delete(vm);
|
|
2704
|
+
}
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2752
2707
|
}
|
|
2753
|
-
}
|
|
2754
2708
|
}
|
|
2755
2709
|
function swapTemplate(oldTpl, newTpl) {
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2710
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2711
|
+
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
2712
|
+
swappedTemplateMap.set(oldTpl, newTpl);
|
|
2713
|
+
return rehydrateHotTemplate(oldTpl);
|
|
2714
|
+
}
|
|
2715
|
+
else {
|
|
2716
|
+
throw new TypeError(`Invalid Template`);
|
|
2717
|
+
}
|
|
2762
2718
|
}
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2766
|
-
throw new Error('HMR is not enabled');
|
|
2767
|
-
}
|
|
2768
|
-
|
|
2769
|
-
return false;
|
|
2719
|
+
return false;
|
|
2770
2720
|
}
|
|
2771
2721
|
function swapComponent(oldComponent, newComponent) {
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2722
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2723
|
+
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
2724
|
+
swappedComponentMap.set(oldComponent, newComponent);
|
|
2725
|
+
return rehydrateHotComponent(oldComponent);
|
|
2726
|
+
}
|
|
2727
|
+
else {
|
|
2728
|
+
throw new TypeError(`Invalid Component`);
|
|
2729
|
+
}
|
|
2778
2730
|
}
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2782
|
-
throw new Error('HMR is not enabled');
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
return false;
|
|
2731
|
+
return false;
|
|
2786
2732
|
}
|
|
2787
2733
|
function swapStyle(oldStyle, newStyle) {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2796
|
-
throw new Error('HMR is not enabled');
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2799
|
-
return false;
|
|
2734
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2735
|
+
// TODO [#1887]: once the support for registering styles is implemented
|
|
2736
|
+
// we can add the validation of both styles around this block.
|
|
2737
|
+
swappedStyleMap.set(oldStyle, newStyle);
|
|
2738
|
+
return rehydrateHotStyle(oldStyle);
|
|
2739
|
+
}
|
|
2740
|
+
return false;
|
|
2800
2741
|
}
|
|
2801
2742
|
|
|
2802
2743
|
/*
|
|
@@ -3207,15 +3148,18 @@ function getScopeTokenClass(owner) {
|
|
|
3207
3148
|
/**
|
|
3208
3149
|
* This function returns the host style token for a custom element if it
|
|
3209
3150
|
* exists. Otherwise it returns null.
|
|
3151
|
+
*
|
|
3152
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3210
3153
|
*/
|
|
3211
3154
|
|
|
3212
3155
|
function getStylesheetTokenHost(vnode) {
|
|
3213
3156
|
const {
|
|
3214
|
-
template
|
|
3215
|
-
stylesheetToken
|
|
3216
|
-
}
|
|
3157
|
+
template
|
|
3217
3158
|
} = getComponentInternalDef(vnode.ctor);
|
|
3218
|
-
|
|
3159
|
+
const {
|
|
3160
|
+
stylesheetToken
|
|
3161
|
+
} = template;
|
|
3162
|
+
return !shared.isUndefined(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3219
3163
|
}
|
|
3220
3164
|
|
|
3221
3165
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3269,75 +3213,6 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3269
3213
|
return null;
|
|
3270
3214
|
}
|
|
3271
3215
|
|
|
3272
|
-
/*
|
|
3273
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3274
|
-
* All rights reserved.
|
|
3275
|
-
* SPDX-License-Identifier: MIT
|
|
3276
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3277
|
-
*/
|
|
3278
|
-
|
|
3279
|
-
function checkHasVM(elm) {
|
|
3280
|
-
const hasVM = !shared.isUndefined(getAssociatedVMIfPresent(elm));
|
|
3281
|
-
|
|
3282
|
-
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3283
|
-
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3284
|
-
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3285
|
-
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.`);
|
|
3286
|
-
}
|
|
3287
|
-
|
|
3288
|
-
return hasVM;
|
|
3289
|
-
}
|
|
3290
|
-
|
|
3291
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
3292
|
-
const {
|
|
3293
|
-
getCustomElement,
|
|
3294
|
-
HTMLElementExported: RendererHTMLElement,
|
|
3295
|
-
defineCustomElement
|
|
3296
|
-
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3297
|
-
// produce only tags with lowercase letters
|
|
3298
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3299
|
-
|
|
3300
|
-
tagName = tagName.toLowerCase();
|
|
3301
|
-
let CE = getCustomElement(tagName);
|
|
3302
|
-
|
|
3303
|
-
if (!shared.isUndefined(CE)) {
|
|
3304
|
-
return CE;
|
|
3305
|
-
}
|
|
3306
|
-
/**
|
|
3307
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3308
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3309
|
-
*/
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3313
|
-
constructor(upgradeCallback) {
|
|
3314
|
-
super();
|
|
3315
|
-
|
|
3316
|
-
if (shared.isFunction(upgradeCallback)) {
|
|
3317
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3318
|
-
}
|
|
3319
|
-
}
|
|
3320
|
-
|
|
3321
|
-
};
|
|
3322
|
-
|
|
3323
|
-
if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3324
|
-
CE.prototype.connectedCallback = function () {
|
|
3325
|
-
if (checkHasVM(this)) {
|
|
3326
|
-
connectRootElement(this);
|
|
3327
|
-
}
|
|
3328
|
-
};
|
|
3329
|
-
|
|
3330
|
-
CE.prototype.disconnectedCallback = function () {
|
|
3331
|
-
if (checkHasVM(this)) {
|
|
3332
|
-
disconnectRootElement(this);
|
|
3333
|
-
}
|
|
3334
|
-
};
|
|
3335
|
-
}
|
|
3336
|
-
|
|
3337
|
-
defineCustomElement(tagName, CE);
|
|
3338
|
-
return CE;
|
|
3339
|
-
}
|
|
3340
|
-
|
|
3341
3216
|
/*
|
|
3342
3217
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3343
3218
|
* All rights reserved.
|
|
@@ -3851,7 +3726,9 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3851
3726
|
sel,
|
|
3852
3727
|
owner
|
|
3853
3728
|
} = vnode;
|
|
3854
|
-
const
|
|
3729
|
+
const {
|
|
3730
|
+
createCustomElement
|
|
3731
|
+
} = renderer;
|
|
3855
3732
|
/**
|
|
3856
3733
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3857
3734
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3860,10 +3737,25 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3860
3737
|
*/
|
|
3861
3738
|
|
|
3862
3739
|
let vm;
|
|
3863
|
-
|
|
3740
|
+
|
|
3741
|
+
const upgradeCallback = elm => {
|
|
3864
3742
|
// the custom element from the registry is expecting an upgrade callback
|
|
3865
3743
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3866
|
-
}
|
|
3744
|
+
};
|
|
3745
|
+
|
|
3746
|
+
const connectedCallback = elm => {
|
|
3747
|
+
if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3748
|
+
connectRootElement(elm);
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3752
|
+
const disconnectedCallback = elm => {
|
|
3753
|
+
if (features.lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3754
|
+
disconnectRootElement(elm);
|
|
3755
|
+
}
|
|
3756
|
+
};
|
|
3757
|
+
|
|
3758
|
+
const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3867
3759
|
vnode.elm = elm;
|
|
3868
3760
|
vnode.vm = vm;
|
|
3869
3761
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3871,8 +3763,6 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3871
3763
|
|
|
3872
3764
|
if (vm) {
|
|
3873
3765
|
allocateChildren(vnode, vm);
|
|
3874
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3875
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
3876
3766
|
}
|
|
3877
3767
|
|
|
3878
3768
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -6654,19 +6544,23 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6654
6544
|
//
|
|
6655
6545
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6656
6546
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6657
|
-
if (scopedToken) {
|
|
6547
|
+
if (!shared.isNull(scopedToken) || !shared.isNull(stylesheetTokenHost)) {
|
|
6658
6548
|
if (!shared.isUndefined(className)) {
|
|
6659
|
-
className
|
|
6660
|
-
|
|
6661
|
-
|
|
6549
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
6550
|
+
const classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
6551
|
+
const classNames = shared.ArrayFilter.call(classTokens, (token) => !shared.isNull(token));
|
|
6552
|
+
className = shared.ArrayJoin.call(classNames, ' ');
|
|
6662
6553
|
}
|
|
6663
6554
|
else if (!shared.isUndefined(classMap)) {
|
|
6664
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (shared.isNull(stylesheetTokenHost) ? {
|
|
6555
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!shared.isNull(scopedToken) ? { [scopedToken]: true } : {})), (!shared.isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
|
|
6665
6556
|
}
|
|
6666
6557
|
else {
|
|
6667
|
-
className
|
|
6668
|
-
|
|
6669
|
-
|
|
6558
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
6559
|
+
const classTokens = [scopedToken, stylesheetTokenHost];
|
|
6560
|
+
const classNames = shared.ArrayFilter.call(classTokens, (token) => !shared.isNull(token));
|
|
6561
|
+
if (classNames.length) {
|
|
6562
|
+
className = shared.ArrayJoin.call(classNames, ' ');
|
|
6563
|
+
}
|
|
6670
6564
|
}
|
|
6671
6565
|
}
|
|
6672
6566
|
let nodesAreCompatible = true;
|
|
@@ -6929,7 +6823,6 @@ exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
|
|
|
6929
6823
|
exports.getComponentConstructor = getComponentConstructor;
|
|
6930
6824
|
exports.getComponentDef = getComponentDef;
|
|
6931
6825
|
exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
|
|
6932
|
-
exports.getUpgradableConstructor = getUpgradableConstructor;
|
|
6933
6826
|
exports.hydrateRoot = hydrateRoot;
|
|
6934
6827
|
exports.isComponentConstructor = isComponentConstructor;
|
|
6935
6828
|
exports.parseFragment = parseFragment;
|
|
@@ -6947,4 +6840,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6947
6840
|
exports.track = track;
|
|
6948
6841
|
exports.unwrap = unwrap;
|
|
6949
6842
|
exports.wire = wire;
|
|
6950
|
-
/* version: 2.
|
|
6843
|
+
/* version: 2.26.0 */
|