@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.
@@ -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, 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
- throw new ReferenceError('Illegal constructor');
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
- const list = activeTemplates.get(tpl);
2532
-
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
- }); // resetting the Set to release the memory of those vm references
2541
- // since they are not longer related to this template, instead
2542
- // they will get re-associated once these instances are rehydrated.
2543
-
2544
- list.clear();
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
- const list = activeStyles.get(style);
2552
-
2553
- if (!isUndefined$1(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
- }); // resetting the Set to release the memory of those vm references
2559
- // since they are not longer related to this style, instead
2560
- // they will get re-associated once these instances are rehydrated.
2561
-
2562
- list.clear();
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
- const list = activeComponents.get(Ctor);
2570
- let canRefreshAllInstances = true;
2571
-
2572
- if (!isUndefined$1(list)) {
2573
- list.forEach(vm => {
2574
- const {
2575
- owner
2576
- } = vm;
2577
-
2578
- if (!isNull(owner)) {
2579
- // if a component class definition is swapped, we must reset
2580
- // owner's template content in the next micro-task:
2581
- forceRehydration(owner);
2582
- } else {
2583
- // the hot swapping for components only work for instances of components
2584
- // created from a template, root elements can't be swapped because we
2585
- // don't have a way to force the creation of the element with the same state
2586
- // of the current element.
2587
- // Instead, we can report the problem to the caller so it can take action,
2588
- // for example: reload the entire page.
2589
- canRefreshAllInstances = false;
2590
- }
2591
- }); // resetting the Set to release the memory of those vm references
2592
- // since they are not longer related to this constructor, instead
2593
- // they will get re-associated once these instances are rehydrated.
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
- if (process.env.NODE_ENV === 'production') {
2603
- // this method should never leak to prod
2604
- throw new ReferenceError();
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
- visited.add(tpl);
2612
- tpl = swappedTemplateMap.get(tpl);
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
- if (process.env.NODE_ENV === 'production') {
2620
- // this method should never leak to prod
2621
- throw new ReferenceError();
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
- visited.add(Ctor);
2629
- Ctor = swappedComponentMap.get(Ctor);
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
- if (process.env.NODE_ENV === 'production') {
2637
- // this method should never leak to prod
2638
- throw new ReferenceError();
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
- visited.add(style);
2646
- style = swappedStyleMap.get(style);
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
- if (process.env.NODE_ENV === 'production') {
2654
- // this method should never leak to prod
2655
- throw new ReferenceError();
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
- componentVMs = new Set();
2665
- activeComponents.set(Ctor, componentVMs);
2666
- } // this will allow us to keep track of the hot components
2667
-
2668
-
2669
- componentVMs.add(vm); // tracking active template
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
- let templateVMs = activeTemplates.get(tpl);
2675
-
2676
- if (isUndefined$1(templateVMs)) {
2677
- templateVMs = new Set();
2678
- activeTemplates.set(tpl, templateVMs);
2679
- } // this will allow us to keep track of the templates that are
2680
- // being used by a hot component
2681
-
2682
-
2683
- templateVMs.add(vm); // tracking active styles associated to template
2684
-
2685
- const stylesheets = tpl.stylesheets;
2686
-
2687
- if (!isUndefined$1(stylesheets)) {
2688
- flattenStylesheets(stylesheets).forEach(stylesheet => {
2689
- // this is necessary because we don't hold the list of styles
2690
- // in the vm, we only hold the selected (already swapped template)
2691
- // but the styles attached to the template might not be the actual
2692
- // active ones, but the swapped versions of those.
2693
- stylesheet = getStyleOrSwappedStyle(stylesheet);
2694
- let stylesheetVMs = activeStyles.get(stylesheet);
2695
-
2696
- if (isUndefined$1(stylesheetVMs)) {
2697
- stylesheetVMs = new Set();
2698
- activeStyles.set(stylesheet, stylesheetVMs);
2699
- } // this will allow us to keep track of the stylesheet that are
2700
- // being used by a hot component
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
- if (process.env.NODE_ENV === 'production') {
2711
- // this method should never leak to prod
2712
- throw new ReferenceError();
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
- } // removing active styles associated to template
2735
-
2736
-
2737
- const styles = tpl.stylesheets;
2738
-
2739
- if (!isUndefined$1(styles)) {
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
- if (process.env.NODE_ENV !== 'production') {
2754
- if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
2755
- swappedTemplateMap.set(oldTpl, newTpl);
2756
- return rehydrateHotTemplate(oldTpl);
2757
- } else {
2758
- throw new TypeError(`Invalid Template`);
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
- if (process.env.NODE_ENV !== 'production') {
2770
- if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
2771
- swappedComponentMap.set(oldComponent, newComponent);
2772
- return rehydrateHotComponent(oldComponent);
2773
- } else {
2774
- throw new TypeError(`Invalid Component`);
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
- if (process.env.NODE_ENV !== 'production') {
2786
- // TODO [#1887]: once the support for registering styles is implemented
2787
- // we can add the validation of both styles around this block.
2788
- swappedStyleMap.set(oldStyle, newStyle);
2789
- return rehydrateHotStyle(oldStyle);
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
- return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
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.
@@ -3848,7 +3723,9 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3848
3723
  sel,
3849
3724
  owner
3850
3725
  } = vnode;
3851
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3726
+ const {
3727
+ createCustomElement
3728
+ } = renderer;
3852
3729
  /**
3853
3730
  * Note: if the upgradable constructor does not expect, or throw when we new it
3854
3731
  * with a callback as the first argument, we could implement a more advanced
@@ -3857,10 +3734,25 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3857
3734
  */
3858
3735
 
3859
3736
  let vm;
3860
- const elm = new UpgradableConstructor(elm => {
3737
+
3738
+ const upgradeCallback = elm => {
3861
3739
  // the custom element from the registry is expecting an upgrade callback
3862
3740
  vm = createViewModelHook(elm, vnode, renderer);
3863
- });
3741
+ };
3742
+
3743
+ const connectedCallback = elm => {
3744
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3745
+ connectRootElement(elm);
3746
+ }
3747
+ };
3748
+
3749
+ const disconnectedCallback = elm => {
3750
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3751
+ disconnectRootElement(elm);
3752
+ }
3753
+ };
3754
+
3755
+ const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
3864
3756
  vnode.elm = elm;
3865
3757
  vnode.vm = vm;
3866
3758
  linkNodeToShadow(elm, owner, renderer);
@@ -3868,8 +3760,6 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3868
3760
 
3869
3761
  if (vm) {
3870
3762
  allocateChildren(vnode, vm);
3871
- } else if (vnode.ctor !== UpgradableConstructor) {
3872
- throw new TypeError(`Incorrect Component Constructor`);
3873
3763
  }
3874
3764
 
3875
3765
  patchElementPropsAndAttrs$1(null, vnode, renderer);
@@ -6651,19 +6541,23 @@ function validateClassAttr(vnode, elm, renderer) {
6651
6541
  //
6652
6542
  // Consequently, hydration mismatches will occur if scoped CSS token classnames
6653
6543
  // are rendered during SSR. This needs to be accounted for when validating.
6654
- if (scopedToken) {
6544
+ if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
6655
6545
  if (!isUndefined$1(className)) {
6656
- className = isNull(stylesheetTokenHost)
6657
- ? `${scopedToken} ${className}`
6658
- : `${scopedToken} ${className} ${stylesheetTokenHost}`;
6546
+ // The order of the className should be scopedToken className stylesheetTokenHost
6547
+ const classTokens = [scopedToken, className, stylesheetTokenHost];
6548
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
6549
+ className = ArrayJoin.call(classNames, ' ');
6659
6550
  }
6660
6551
  else if (!isUndefined$1(classMap)) {
6661
- classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {} : { [stylesheetTokenHost]: true }));
6552
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
6662
6553
  }
6663
6554
  else {
6664
- className = isNull(stylesheetTokenHost)
6665
- ? `${scopedToken}`
6666
- : `${scopedToken} ${stylesheetTokenHost}`;
6555
+ // The order of the className should be scopedToken stylesheetTokenHost
6556
+ const classTokens = [scopedToken, stylesheetTokenHost];
6557
+ const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
6558
+ if (classNames.length) {
6559
+ className = ArrayJoin.call(classNames, ' ');
6560
+ }
6667
6561
  }
6668
6562
  }
6669
6563
  let nodesAreCompatible = true;
@@ -6906,5 +6800,5 @@ function getComponentConstructor(elm) {
6906
6800
  return ctor;
6907
6801
  }
6908
6802
 
6909
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6910
- /* version: 2.25.1 */
6803
+ 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 };
6804
+ /* version: 2.26.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.25.1",
3
+ "version": "2.26.0",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.25.1",
28
- "@lwc/shared": "2.25.1"
27
+ "@lwc/features": "2.26.0",
28
+ "@lwc/shared": "2.26.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "2.0.0"