lwc 2.23.1 → 2.23.2

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.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +1182 -856
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1182 -855
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1101 -803
  5. package/dist/engine-dom/iife/es5/engine-dom.js +449 -368
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +409 -335
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1182 -855
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1101 -803
  11. package/dist/engine-dom/umd/es5/engine-dom.js +449 -368
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +409 -335
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +782 -521
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +782 -521
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -313,24 +313,36 @@ function isBooleanAttribute(attrName, tagName) {
313
313
  return (allowedTagNames !== undefined &&
314
314
  (allowedTagNames.size === 0 || allowedTagNames.has(tagName)));
315
315
  }
316
+ // This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
316
317
  const GLOBAL_ATTRIBUTE = new Set([
317
- 'role',
318
318
  'accesskey',
319
+ 'autocapitalize',
320
+ 'autofocus',
319
321
  'class',
320
322
  'contenteditable',
321
323
  'contextmenu',
322
324
  'dir',
323
325
  'draggable',
324
- 'dropzone',
326
+ 'enterkeyhint',
327
+ 'exportparts',
325
328
  'hidden',
326
329
  'id',
330
+ 'inputmode',
331
+ 'is',
332
+ 'itemid',
327
333
  'itemprop',
334
+ 'itemref',
335
+ 'itemscope',
336
+ 'itemtype',
328
337
  'lang',
338
+ 'nonce',
339
+ 'part',
329
340
  'slot',
330
341
  'spellcheck',
331
342
  'style',
332
343
  'tabindex',
333
344
  'title',
345
+ 'translate',
334
346
  ]);
335
347
  function isGlobalHtmlAttribute(attrName) {
336
348
  return GLOBAL_ATTRIBUTE.has(attrName);
@@ -415,9 +427,9 @@ function htmlEscape(str, attrMode = false) {
415
427
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
416
428
  */
417
429
  // Increment whenever the LWC template compiler changes
418
- const LWC_VERSION = "2.23.1";
430
+ const LWC_VERSION = "2.23.2";
419
431
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
420
- /** version: 2.23.1 */
432
+ /** version: 2.23.2 */
421
433
 
422
434
  /*
423
435
  * Copyright (c) 2020, salesforce.com, inc.
@@ -469,6 +481,7 @@ const features = {
469
481
  ENABLE_HTML_COLLECTIONS_PATCH: null,
470
482
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
471
483
  ENABLE_MIXED_SHADOW_MODE: null,
484
+ ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
472
485
  ENABLE_NODE_LIST_PATCH: null,
473
486
  ENABLE_NODE_PATCH: null,
474
487
  ENABLE_REACTIVE_SETTER: null,
@@ -526,7 +539,7 @@ function setFeatureFlagForTest(name, value) {
526
539
  setFeatureFlag(name, value);
527
540
  }
528
541
  }
529
- /** version: 2.23.1 */
542
+ /** version: 2.23.2 */
530
543
 
531
544
  /* proxy-compat-disable */
532
545
 
@@ -3280,30 +3293,67 @@ function createStylesheet(vm, stylesheets) {
3280
3293
  * SPDX-License-Identifier: MIT
3281
3294
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3282
3295
  */
3296
+
3297
+ function checkHasVM(elm) {
3298
+ const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3299
+
3300
+ if (process.env.NODE_ENV !== 'production' && !hasVM) {
3301
+ // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
3302
+ // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
3303
+ 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.`);
3304
+ }
3305
+
3306
+ return hasVM;
3307
+ }
3308
+
3283
3309
  function getUpgradableConstructor(tagName, renderer) {
3284
- const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3285
- // Should never get a tag with upper case letter at this point, the compiler should
3286
- // produce only tags with lowercase letters
3287
- // But, for backwards compatibility, we will lower case the tagName
3288
- tagName = tagName.toLowerCase();
3289
- let CE = getCustomElement(tagName);
3290
- if (!isUndefined$1(CE)) {
3291
- return CE;
3310
+ const {
3311
+ getCustomElement,
3312
+ HTMLElementExported: RendererHTMLElement,
3313
+ defineCustomElement
3314
+ } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
3315
+ // produce only tags with lowercase letters
3316
+ // But, for backwards compatibility, we will lower case the tagName
3317
+
3318
+ tagName = tagName.toLowerCase();
3319
+ let CE = getCustomElement(tagName);
3320
+
3321
+ if (!isUndefined$1(CE)) {
3322
+ return CE;
3323
+ }
3324
+ /**
3325
+ * LWC Upgradable Element reference to an element that was created
3326
+ * via the scoped registry mechanism, and that is ready to be upgraded.
3327
+ */
3328
+
3329
+
3330
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3331
+ constructor(upgradeCallback) {
3332
+ super();
3333
+
3334
+ if (isFunction$1(upgradeCallback)) {
3335
+ upgradeCallback(this); // nothing to do with the result for now
3336
+ }
3292
3337
  }
3293
- /**
3294
- * LWC Upgradable Element reference to an element that was created
3295
- * via the scoped registry mechanism, and that is ready to be upgraded.
3296
- */
3297
- CE = class LWCUpgradableElement extends RendererHTMLElement {
3298
- constructor(upgradeCallback) {
3299
- super();
3300
- if (isFunction$1(upgradeCallback)) {
3301
- upgradeCallback(this); // nothing to do with the result for now
3302
- }
3303
- }
3338
+
3339
+ };
3340
+
3341
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3342
+ CE.prototype.connectedCallback = function () {
3343
+ if (checkHasVM(this)) {
3344
+ connectRootElement(this);
3345
+ }
3304
3346
  };
3305
- defineCustomElement(tagName, CE);
3306
- return CE;
3347
+
3348
+ CE.prototype.disconnectedCallback = function () {
3349
+ if (checkHasVM(this)) {
3350
+ disconnectRootElement(this);
3351
+ }
3352
+ };
3353
+ }
3354
+
3355
+ defineCustomElement(tagName, CE);
3356
+ return CE;
3307
3357
  }
3308
3358
 
3309
3359
  /*
@@ -3549,579 +3599,790 @@ function applyStaticStyleAttribute(vnode, renderer) {
3549
3599
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3550
3600
  */
3551
3601
  function patchChildren(c1, c2, parent, renderer) {
3552
- if (hasDynamicChildren(c2)) {
3553
- updateDynamicChildren(c1, c2, parent, renderer);
3554
- }
3555
- else {
3556
- updateStaticChildren(c1, c2, parent, renderer);
3557
- }
3602
+ if (hasDynamicChildren(c2)) {
3603
+ updateDynamicChildren(c1, c2, parent, renderer);
3604
+ } else {
3605
+ updateStaticChildren(c1, c2, parent, renderer);
3606
+ }
3558
3607
  }
3608
+
3559
3609
  function patch(n1, n2, parent, renderer) {
3560
- var _a, _b;
3561
- if (n1 === n2) {
3562
- return;
3563
- }
3564
- if (process.env.NODE_ENV !== 'production') {
3565
- if (!isSameVnode(n1, n2)) {
3566
- throw new Error('Expected these VNodes to be the same: ' +
3567
- JSON.stringify({ sel: n1.sel, key: n1.key }) +
3568
- ', ' +
3569
- JSON.stringify({ sel: n2.sel, key: n2.key }));
3570
- }
3571
- }
3572
- switch (n2.type) {
3573
- case 0 /* VNodeType.Text */:
3574
- // VText has no special capability, fallback to the owner's renderer
3575
- patchText(n1, n2, renderer);
3576
- break;
3577
- case 1 /* VNodeType.Comment */:
3578
- // VComment has no special capability, fallback to the owner's renderer
3579
- patchComment(n1, n2, renderer);
3580
- break;
3581
- case 4 /* VNodeType.Static */:
3582
- n2.elm = n1.elm;
3583
- break;
3584
- case 2 /* VNodeType.Element */:
3585
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3586
- break;
3587
- case 3 /* VNodeType.CustomElement */:
3588
- patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3589
- break;
3610
+ var _a, _b;
3611
+
3612
+ if (n1 === n2) {
3613
+ return;
3614
+ }
3615
+
3616
+ if (process.env.NODE_ENV !== 'production') {
3617
+ if (!isSameVnode(n1, n2)) {
3618
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
3619
+ sel: n1.sel,
3620
+ key: n1.key
3621
+ }) + ', ' + JSON.stringify({
3622
+ sel: n2.sel,
3623
+ key: n2.key
3624
+ }));
3590
3625
  }
3626
+ }
3627
+
3628
+ switch (n2.type) {
3629
+ case 0
3630
+ /* VNodeType.Text */
3631
+ :
3632
+ // VText has no special capability, fallback to the owner's renderer
3633
+ patchText(n1, n2, renderer);
3634
+ break;
3635
+
3636
+ case 1
3637
+ /* VNodeType.Comment */
3638
+ :
3639
+ // VComment has no special capability, fallback to the owner's renderer
3640
+ patchComment(n1, n2, renderer);
3641
+ break;
3642
+
3643
+ case 4
3644
+ /* VNodeType.Static */
3645
+ :
3646
+ n2.elm = n1.elm;
3647
+ break;
3648
+
3649
+ case 2
3650
+ /* VNodeType.Element */
3651
+ :
3652
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3653
+ break;
3654
+
3655
+ case 3
3656
+ /* VNodeType.CustomElement */
3657
+ :
3658
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3659
+ break;
3660
+ }
3591
3661
  }
3662
+
3592
3663
  function mount(node, parent, renderer, anchor) {
3593
- var _a, _b;
3594
- switch (node.type) {
3595
- case 0 /* VNodeType.Text */:
3596
- // VText has no special capability, fallback to the owner's renderer
3597
- mountText(node, parent, anchor, renderer);
3598
- break;
3599
- case 1 /* VNodeType.Comment */:
3600
- // VComment has no special capability, fallback to the owner's renderer
3601
- mountComment(node, parent, anchor, renderer);
3602
- break;
3603
- case 4 /* VNodeType.Static */:
3604
- // VStatic cannot have a custom renderer associated to them, using owner's renderer
3605
- mountStatic(node, parent, anchor, renderer);
3606
- break;
3607
- case 2 /* VNodeType.Element */:
3608
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3609
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3610
- break;
3611
- case 3 /* VNodeType.CustomElement */:
3612
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3613
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3614
- break;
3615
- }
3664
+ var _a, _b;
3665
+
3666
+ switch (node.type) {
3667
+ case 0
3668
+ /* VNodeType.Text */
3669
+ :
3670
+ // VText has no special capability, fallback to the owner's renderer
3671
+ mountText(node, parent, anchor, renderer);
3672
+ break;
3673
+
3674
+ case 1
3675
+ /* VNodeType.Comment */
3676
+ :
3677
+ // VComment has no special capability, fallback to the owner's renderer
3678
+ mountComment(node, parent, anchor, renderer);
3679
+ break;
3680
+
3681
+ case 4
3682
+ /* VNodeType.Static */
3683
+ :
3684
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3685
+ mountStatic(node, parent, anchor, renderer);
3686
+ break;
3687
+
3688
+ case 2
3689
+ /* VNodeType.Element */
3690
+ :
3691
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3692
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3693
+ break;
3694
+
3695
+ case 3
3696
+ /* VNodeType.CustomElement */
3697
+ :
3698
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3699
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3700
+ break;
3701
+ }
3616
3702
  }
3703
+
3617
3704
  function patchText(n1, n2, renderer) {
3618
- n2.elm = n1.elm;
3619
- if (n2.text !== n1.text) {
3620
- updateTextContent(n2, renderer);
3621
- }
3705
+ n2.elm = n1.elm;
3706
+
3707
+ if (n2.text !== n1.text) {
3708
+ updateTextContent(n2, renderer);
3709
+ }
3622
3710
  }
3711
+
3623
3712
  function mountText(vnode, parent, anchor, renderer) {
3624
- const { owner } = vnode;
3625
- const { createText } = renderer;
3626
- const textNode = (vnode.elm = createText(vnode.text));
3627
- linkNodeToShadow(textNode, owner, renderer);
3628
- insertNode(textNode, parent, anchor, renderer);
3713
+ const {
3714
+ owner
3715
+ } = vnode;
3716
+ const {
3717
+ createText
3718
+ } = renderer;
3719
+ const textNode = vnode.elm = createText(vnode.text);
3720
+ linkNodeToShadow(textNode, owner, renderer);
3721
+ insertNode(textNode, parent, anchor, renderer);
3629
3722
  }
3723
+
3630
3724
  function patchComment(n1, n2, renderer) {
3631
- n2.elm = n1.elm;
3632
- // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3633
- // it is the case today.
3634
- if (n2.text !== n1.text) {
3635
- updateTextContent(n2, renderer);
3636
- }
3725
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3726
+ // it is the case today.
3727
+
3728
+ if (n2.text !== n1.text) {
3729
+ updateTextContent(n2, renderer);
3730
+ }
3637
3731
  }
3732
+
3638
3733
  function mountComment(vnode, parent, anchor, renderer) {
3639
- const { owner } = vnode;
3640
- const { createComment } = renderer;
3641
- const commentNode = (vnode.elm = createComment(vnode.text));
3642
- linkNodeToShadow(commentNode, owner, renderer);
3643
- insertNode(commentNode, parent, anchor, renderer);
3734
+ const {
3735
+ owner
3736
+ } = vnode;
3737
+ const {
3738
+ createComment
3739
+ } = renderer;
3740
+ const commentNode = vnode.elm = createComment(vnode.text);
3741
+ linkNodeToShadow(commentNode, owner, renderer);
3742
+ insertNode(commentNode, parent, anchor, renderer);
3644
3743
  }
3744
+
3645
3745
  function mountElement(vnode, parent, anchor, renderer) {
3646
- const { sel, owner, data: { svg }, } = vnode;
3647
- const { createElement } = renderer;
3648
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3649
- const elm = (vnode.elm = createElement(sel, namespace));
3650
- linkNodeToShadow(elm, owner, renderer);
3651
- applyStyleScoping(elm, owner, renderer);
3652
- applyDomManual(elm, vnode);
3653
- applyElementRestrictions(elm, vnode);
3654
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3655
- insertNode(elm, parent, anchor, renderer);
3656
- mountVNodes(vnode.children, elm, renderer, null);
3746
+ const {
3747
+ sel,
3748
+ owner,
3749
+ data: {
3750
+ svg
3751
+ }
3752
+ } = vnode;
3753
+ const {
3754
+ createElement
3755
+ } = renderer;
3756
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3757
+ const elm = vnode.elm = createElement(sel, namespace);
3758
+ linkNodeToShadow(elm, owner, renderer);
3759
+ applyStyleScoping(elm, owner, renderer);
3760
+ applyDomManual(elm, vnode);
3761
+ applyElementRestrictions(elm, vnode);
3762
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3763
+ insertNode(elm, parent, anchor, renderer);
3764
+ mountVNodes(vnode.children, elm, renderer, null);
3657
3765
  }
3766
+
3658
3767
  function patchElement(n1, n2, renderer) {
3659
- const elm = (n2.elm = n1.elm);
3660
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3661
- patchChildren(n1.children, n2.children, elm, renderer);
3768
+ const elm = n2.elm = n1.elm;
3769
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3770
+ patchChildren(n1.children, n2.children, elm, renderer);
3662
3771
  }
3772
+
3663
3773
  function mountStatic(vnode, parent, anchor, renderer) {
3664
- const { owner } = vnode;
3665
- const { cloneNode, isSyntheticShadowDefined } = renderer;
3666
- const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3667
- linkNodeToShadow(elm, owner, renderer);
3668
- applyElementRestrictions(elm, vnode);
3669
- // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3670
- const { renderMode, shadowMode } = owner;
3671
- if (isSyntheticShadowDefined) {
3672
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3673
- elm[KEY__SHADOW_STATIC] = true;
3674
- }
3774
+ const {
3775
+ owner
3776
+ } = vnode;
3777
+ const {
3778
+ cloneNode,
3779
+ isSyntheticShadowDefined
3780
+ } = renderer;
3781
+ const elm = vnode.elm = cloneNode(vnode.fragment, true);
3782
+ linkNodeToShadow(elm, owner, renderer);
3783
+ applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3784
+
3785
+ const {
3786
+ renderMode,
3787
+ shadowMode
3788
+ } = owner;
3789
+
3790
+ if (isSyntheticShadowDefined) {
3791
+ if (shadowMode === 1
3792
+ /* ShadowMode.Synthetic */
3793
+ || renderMode === 0
3794
+ /* RenderMode.Light */
3795
+ ) {
3796
+ elm[KEY__SHADOW_STATIC] = true;
3675
3797
  }
3676
- insertNode(elm, parent, anchor, renderer);
3798
+ }
3799
+
3800
+ insertNode(elm, parent, anchor, renderer);
3677
3801
  }
3802
+
3678
3803
  function mountCustomElement(vnode, parent, anchor, renderer) {
3679
- const { sel, owner } = vnode;
3680
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3681
- /**
3682
- * Note: if the upgradable constructor does not expect, or throw when we new it
3683
- * with a callback as the first argument, we could implement a more advanced
3684
- * mechanism that only passes that argument if the constructor is known to be
3685
- * an upgradable custom element.
3686
- */
3687
- let vm;
3688
- const elm = new UpgradableConstructor((elm) => {
3689
- // the custom element from the registry is expecting an upgrade callback
3690
- vm = createViewModelHook(elm, vnode, renderer);
3691
- });
3692
- vnode.elm = elm;
3693
- vnode.vm = vm;
3694
- linkNodeToShadow(elm, owner, renderer);
3695
- applyStyleScoping(elm, owner, renderer);
3696
- if (vm) {
3697
- allocateChildren(vnode, vm);
3698
- }
3699
- else if (vnode.ctor !== UpgradableConstructor) {
3700
- throw new TypeError(`Incorrect Component Constructor`);
3701
- }
3702
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3703
- insertNode(elm, parent, anchor, renderer);
3704
- if (vm) {
3705
- if (process.env.NODE_ENV !== 'production') {
3706
- assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
3707
- }
3708
- runConnectedCallback(vm);
3709
- }
3710
- mountVNodes(vnode.children, elm, renderer, null);
3711
- if (vm) {
3712
- appendVM(vm);
3804
+ const {
3805
+ sel,
3806
+ owner
3807
+ } = vnode;
3808
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3809
+ /**
3810
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3811
+ * with a callback as the first argument, we could implement a more advanced
3812
+ * mechanism that only passes that argument if the constructor is known to be
3813
+ * an upgradable custom element.
3814
+ */
3815
+
3816
+ let vm;
3817
+ const elm = new UpgradableConstructor(elm => {
3818
+ // the custom element from the registry is expecting an upgrade callback
3819
+ vm = createViewModelHook(elm, vnode, renderer);
3820
+ });
3821
+ vnode.elm = elm;
3822
+ vnode.vm = vm;
3823
+ linkNodeToShadow(elm, owner, renderer);
3824
+ applyStyleScoping(elm, owner, renderer);
3825
+
3826
+ if (vm) {
3827
+ allocateChildren(vnode, vm);
3828
+ } else if (vnode.ctor !== UpgradableConstructor) {
3829
+ throw new TypeError(`Incorrect Component Constructor`);
3830
+ }
3831
+
3832
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3833
+ insertNode(elm, parent, anchor, renderer);
3834
+
3835
+ if (vm) {
3836
+ {
3837
+ // On the server, we don't have native custom element lifecycle callbacks, so we must
3838
+ // manually invoke the connectedCallback for a child component.
3839
+ runConnectedCallback(vm);
3713
3840
  }
3841
+ }
3842
+
3843
+ mountVNodes(vnode.children, elm, renderer, null);
3844
+
3845
+ if (vm) {
3846
+ appendVM(vm);
3847
+ }
3714
3848
  }
3849
+
3715
3850
  function patchCustomElement(n1, n2, parent, renderer) {
3716
- if (n1.ctor !== n2.ctor) {
3717
- // If the constructor, unmount the current component and mount a new one using the new
3718
- // constructor.
3719
- const anchor = renderer.nextSibling(n1.elm);
3720
- unmount(n1, parent, renderer, true);
3721
- mountCustomElement(n2, parent, anchor, renderer);
3722
- }
3723
- else {
3724
- // Otherwise patch the existing component with new props/attrs/etc.
3725
- const elm = (n2.elm = n1.elm);
3726
- const vm = (n2.vm = n1.vm);
3727
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3728
- if (!isUndefined$1(vm)) {
3729
- // in fallback mode, the allocation will always set children to
3730
- // empty and delegate the real allocation to the slot elements
3731
- allocateChildren(n2, vm);
3732
- }
3733
- // in fallback mode, the children will be always empty, so, nothing
3734
- // will happen, but in native, it does allocate the light dom
3735
- patchChildren(n1.children, n2.children, elm, renderer);
3736
- if (!isUndefined$1(vm)) {
3737
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3738
- // this is important to preserve the top to bottom synchronous rendering phase.
3739
- rerenderVM(vm);
3740
- }
3851
+ if (n1.ctor !== n2.ctor) {
3852
+ // If the constructor, unmount the current component and mount a new one using the new
3853
+ // constructor.
3854
+ const anchor = renderer.nextSibling(n1.elm);
3855
+ unmount(n1, parent, renderer, true);
3856
+ mountCustomElement(n2, parent, anchor, renderer);
3857
+ } else {
3858
+ // Otherwise patch the existing component with new props/attrs/etc.
3859
+ const elm = n2.elm = n1.elm;
3860
+ const vm = n2.vm = n1.vm;
3861
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3862
+
3863
+ if (!isUndefined$1(vm)) {
3864
+ // in fallback mode, the allocation will always set children to
3865
+ // empty and delegate the real allocation to the slot elements
3866
+ allocateChildren(n2, vm);
3867
+ } // in fallback mode, the children will be always empty, so, nothing
3868
+ // will happen, but in native, it does allocate the light dom
3869
+
3870
+
3871
+ patchChildren(n1.children, n2.children, elm, renderer);
3872
+
3873
+ if (!isUndefined$1(vm)) {
3874
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3875
+ // this is important to preserve the top to bottom synchronous rendering phase.
3876
+ rerenderVM(vm);
3741
3877
  }
3878
+ }
3742
3879
  }
3880
+
3743
3881
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3744
- for (; start < end; ++start) {
3745
- const vnode = vnodes[start];
3746
- if (isVNode(vnode)) {
3747
- mount(vnode, parent, renderer, anchor);
3748
- }
3882
+ for (; start < end; ++start) {
3883
+ const vnode = vnodes[start];
3884
+
3885
+ if (isVNode(vnode)) {
3886
+ mount(vnode, parent, renderer, anchor);
3749
3887
  }
3888
+ }
3750
3889
  }
3890
+
3751
3891
  function unmount(vnode, parent, renderer, doRemove = false) {
3752
- const { type, elm, sel } = vnode;
3753
- // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3754
- // subtree root, is the only element worth unmounting from the subtree.
3755
- if (doRemove) {
3756
- // The vnode might or might not have a data.renderer associated to it
3757
- // but the removal used here is from the owner instead.
3758
- removeNode(elm, parent, renderer);
3759
- }
3760
- switch (type) {
3761
- case 2 /* VNodeType.Element */: {
3762
- // Slot content is removed to trigger slotchange event when removing slot.
3763
- // Only required for synthetic shadow.
3764
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
3765
- unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3766
- break;
3767
- }
3768
- case 3 /* VNodeType.CustomElement */: {
3769
- const { vm } = vnode;
3770
- // No need to unmount the children here, `removeVM` will take care of removing the
3771
- // children.
3772
- if (!isUndefined$1(vm)) {
3773
- removeVM(vm);
3774
- }
3892
+ const {
3893
+ type,
3894
+ elm,
3895
+ sel
3896
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3897
+ // subtree root, is the only element worth unmounting from the subtree.
3898
+
3899
+ if (doRemove) {
3900
+ // The vnode might or might not have a data.renderer associated to it
3901
+ // but the removal used here is from the owner instead.
3902
+ removeNode(elm, parent, renderer);
3903
+ }
3904
+
3905
+ switch (type) {
3906
+ case 2
3907
+ /* VNodeType.Element */
3908
+ :
3909
+ {
3910
+ // Slot content is removed to trigger slotchange event when removing slot.
3911
+ // Only required for synthetic shadow.
3912
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
3913
+ /* ShadowMode.Synthetic */
3914
+ ;
3915
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3916
+ break;
3917
+ }
3918
+
3919
+ case 3
3920
+ /* VNodeType.CustomElement */
3921
+ :
3922
+ {
3923
+ const {
3924
+ vm
3925
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3926
+ // children.
3927
+
3928
+ if (!isUndefined$1(vm)) {
3929
+ removeVM(vm);
3775
3930
  }
3776
- }
3931
+ }
3932
+ }
3777
3933
  }
3934
+
3778
3935
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3779
- for (; start < end; ++start) {
3780
- const ch = vnodes[start];
3781
- if (isVNode(ch)) {
3782
- unmount(ch, parent, renderer, doRemove);
3783
- }
3936
+ for (; start < end; ++start) {
3937
+ const ch = vnodes[start];
3938
+
3939
+ if (isVNode(ch)) {
3940
+ unmount(ch, parent, renderer, doRemove);
3784
3941
  }
3942
+ }
3785
3943
  }
3944
+
3786
3945
  function isVNode(vnode) {
3787
- return vnode != null;
3946
+ return vnode != null;
3788
3947
  }
3948
+
3789
3949
  function linkNodeToShadow(elm, owner, renderer) {
3790
- const { renderRoot, renderMode, shadowMode } = owner;
3791
- const { isSyntheticShadowDefined } = renderer;
3792
- // TODO [#1164]: this should eventually be done by the polyfill directly
3793
- if (isSyntheticShadowDefined) {
3794
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3795
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3796
- }
3950
+ const {
3951
+ renderRoot,
3952
+ renderMode,
3953
+ shadowMode
3954
+ } = owner;
3955
+ const {
3956
+ isSyntheticShadowDefined
3957
+ } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
3958
+
3959
+ if (isSyntheticShadowDefined) {
3960
+ if (shadowMode === 1
3961
+ /* ShadowMode.Synthetic */
3962
+ || renderMode === 0
3963
+ /* RenderMode.Light */
3964
+ ) {
3965
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3797
3966
  }
3967
+ }
3798
3968
  }
3969
+
3799
3970
  function updateTextContent(vnode, renderer) {
3800
- const { elm, text } = vnode;
3801
- const { setText } = renderer;
3802
- if (process.env.NODE_ENV !== 'production') {
3803
- unlockDomMutation();
3804
- }
3805
- setText(elm, text);
3806
- if (process.env.NODE_ENV !== 'production') {
3807
- lockDomMutation();
3808
- }
3971
+ const {
3972
+ elm,
3973
+ text
3974
+ } = vnode;
3975
+ const {
3976
+ setText
3977
+ } = renderer;
3978
+
3979
+ if (process.env.NODE_ENV !== 'production') {
3980
+ unlockDomMutation();
3981
+ }
3982
+
3983
+ setText(elm, text);
3984
+
3985
+ if (process.env.NODE_ENV !== 'production') {
3986
+ lockDomMutation();
3987
+ }
3809
3988
  }
3989
+
3810
3990
  function insertNode(node, parent, anchor, renderer) {
3811
- if (process.env.NODE_ENV !== 'production') {
3812
- unlockDomMutation();
3813
- }
3814
- renderer.insert(node, parent, anchor);
3815
- if (process.env.NODE_ENV !== 'production') {
3816
- lockDomMutation();
3817
- }
3991
+ if (process.env.NODE_ENV !== 'production') {
3992
+ unlockDomMutation();
3993
+ }
3994
+
3995
+ renderer.insert(node, parent, anchor);
3996
+
3997
+ if (process.env.NODE_ENV !== 'production') {
3998
+ lockDomMutation();
3999
+ }
3818
4000
  }
4001
+
3819
4002
  function removeNode(node, parent, renderer) {
3820
- if (process.env.NODE_ENV !== 'production') {
3821
- unlockDomMutation();
3822
- }
3823
- renderer.remove(node, parent);
3824
- if (process.env.NODE_ENV !== 'production') {
3825
- lockDomMutation();
3826
- }
4003
+ if (process.env.NODE_ENV !== 'production') {
4004
+ unlockDomMutation();
4005
+ }
4006
+
4007
+ renderer.remove(node, parent);
4008
+
4009
+ if (process.env.NODE_ENV !== 'production') {
4010
+ lockDomMutation();
4011
+ }
3827
4012
  }
4013
+
3828
4014
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3829
- if (isNull(oldVnode)) {
3830
- applyEventListeners(vnode, renderer);
3831
- applyStaticClassAttribute(vnode, renderer);
3832
- applyStaticStyleAttribute(vnode, renderer);
3833
- }
3834
- // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3835
- // value is set before type=radio.
3836
- patchClassAttribute(oldVnode, vnode, renderer);
3837
- patchStyleAttribute(oldVnode, vnode, renderer);
3838
- patchAttributes(oldVnode, vnode, renderer);
3839
- patchProps(oldVnode, vnode, renderer);
4015
+ if (isNull(oldVnode)) {
4016
+ applyEventListeners(vnode, renderer);
4017
+ applyStaticClassAttribute(vnode, renderer);
4018
+ applyStaticStyleAttribute(vnode, renderer);
4019
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4020
+ // value is set before type=radio.
4021
+
4022
+
4023
+ patchClassAttribute(oldVnode, vnode, renderer);
4024
+ patchStyleAttribute(oldVnode, vnode, renderer);
4025
+ patchAttributes(oldVnode, vnode, renderer);
4026
+ patchProps(oldVnode, vnode, renderer);
3840
4027
  }
4028
+
3841
4029
  function applyStyleScoping(elm, owner, renderer) {
3842
- // Set the class name for `*.scoped.css` style scoping.
3843
- const scopeToken = getScopeTokenClass(owner);
3844
- if (!isNull(scopeToken)) {
3845
- const { getClassList } = renderer;
3846
- // TODO [#2762]: this dot notation with add is probably problematic
3847
- // probably we should have a renderer api for just the add operation
3848
- getClassList(elm).add(scopeToken);
3849
- }
3850
- // Set property element for synthetic shadow DOM style scoping.
3851
- const { stylesheetToken: syntheticToken } = owner.context;
3852
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3853
- elm.$shadowToken$ = syntheticToken;
3854
- }
4030
+ // Set the class name for `*.scoped.css` style scoping.
4031
+ const scopeToken = getScopeTokenClass(owner);
4032
+
4033
+ if (!isNull(scopeToken)) {
4034
+ const {
4035
+ getClassList
4036
+ } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
4037
+ // probably we should have a renderer api for just the add operation
4038
+
4039
+ getClassList(elm).add(scopeToken);
4040
+ } // Set property element for synthetic shadow DOM style scoping.
4041
+
4042
+
4043
+ const {
4044
+ stylesheetToken: syntheticToken
4045
+ } = owner.context;
4046
+
4047
+ if (owner.shadowMode === 1
4048
+ /* ShadowMode.Synthetic */
4049
+ && !isUndefined$1(syntheticToken)) {
4050
+ elm.$shadowToken$ = syntheticToken;
4051
+ }
3855
4052
  }
4053
+
3856
4054
  function applyDomManual(elm, vnode) {
3857
- var _a;
3858
- const { owner, data: { context }, } = vnode;
3859
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
3860
- elm.$domManual$ = true;
4055
+ var _a;
4056
+
4057
+ const {
4058
+ owner,
4059
+ data: {
4060
+ context
3861
4061
  }
4062
+ } = vnode;
4063
+
4064
+ if (owner.shadowMode === 1
4065
+ /* ShadowMode.Synthetic */
4066
+ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
4067
+ /* LwcDomMode.Manual */
4068
+ ) {
4069
+ elm.$domManual$ = true;
4070
+ }
3862
4071
  }
4072
+
3863
4073
  function applyElementRestrictions(elm, vnode) {
3864
- var _a, _b;
3865
- if (process.env.NODE_ENV !== 'production') {
3866
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
3867
- const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
3868
- patchElementWithRestrictions(elm, {
3869
- isPortal,
3870
- isLight,
3871
- });
3872
- }
4074
+ var _a, _b;
4075
+
4076
+ if (process.env.NODE_ENV !== 'production') {
4077
+ const isPortal = vnode.type === 2
4078
+ /* VNodeType.Element */
4079
+ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
4080
+ /* LwcDomMode.Manual */
4081
+ ;
4082
+ const isLight = vnode.owner.renderMode === 0
4083
+ /* RenderMode.Light */
4084
+ ;
4085
+ patchElementWithRestrictions(elm, {
4086
+ isPortal,
4087
+ isLight
4088
+ });
4089
+ }
3873
4090
  }
4091
+
3874
4092
  function allocateChildren(vnode, vm) {
3875
- // A component with slots will re-render because:
3876
- // 1- There is a change of the internal state.
3877
- // 2- There is a change on the external api (ex: slots)
3878
- //
3879
- // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3880
- // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3881
- // in a reused VCustomElement, there won't be any slotted children.
3882
- // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3883
- //
3884
- // In case #2, we will always get a fresh VCustomElement.
3885
- const children = vnode.aChildren || vnode.children;
3886
- vm.aChildren = children;
3887
- const { renderMode, shadowMode } = vm;
3888
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3889
- // slow path
3890
- allocateInSlot(vm, children);
3891
- // save the allocated children in case this vnode is reused.
3892
- vnode.aChildren = children;
3893
- // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3894
- vnode.children = EmptyArray;
3895
- }
4093
+ // A component with slots will re-render because:
4094
+ // 1- There is a change of the internal state.
4095
+ // 2- There is a change on the external api (ex: slots)
4096
+ //
4097
+ // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
4098
+ // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
4099
+ // in a reused VCustomElement, there won't be any slotted children.
4100
+ // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
4101
+ //
4102
+ // In case #2, we will always get a fresh VCustomElement.
4103
+ const children = vnode.aChildren || vnode.children;
4104
+ vm.aChildren = children;
4105
+ const {
4106
+ renderMode,
4107
+ shadowMode
4108
+ } = vm;
4109
+
4110
+ if (shadowMode === 1
4111
+ /* ShadowMode.Synthetic */
4112
+ || renderMode === 0
4113
+ /* RenderMode.Light */
4114
+ ) {
4115
+ // slow path
4116
+ allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4117
+
4118
+ vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4119
+
4120
+ vnode.children = EmptyArray;
4121
+ }
3896
4122
  }
4123
+
3897
4124
  function createViewModelHook(elm, vnode, renderer) {
3898
- let vm = getAssociatedVMIfPresent(elm);
3899
- // There is a possibility that a custom element is registered under tagName, in which case, the
3900
- // initialization is already carry on, and there is nothing else to do here since this hook is
3901
- // called right after invoking `document.createElement`.
3902
- if (!isUndefined$1(vm)) {
3903
- return vm;
3904
- }
3905
- const { sel, mode, ctor, owner } = vnode;
3906
- vm = createVM(elm, ctor, renderer, {
3907
- mode,
3908
- owner,
3909
- tagName: sel,
3910
- });
3911
- if (process.env.NODE_ENV !== 'production') {
3912
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
3913
- }
4125
+ let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
4126
+ // initialization is already carry on, and there is nothing else to do here since this hook is
4127
+ // called right after invoking `document.createElement`.
4128
+
4129
+ if (!isUndefined$1(vm)) {
3914
4130
  return vm;
4131
+ }
4132
+
4133
+ const {
4134
+ sel,
4135
+ mode,
4136
+ ctor,
4137
+ owner
4138
+ } = vnode;
4139
+ vm = createVM(elm, ctor, renderer, {
4140
+ mode,
4141
+ owner,
4142
+ tagName: sel
4143
+ });
4144
+
4145
+ if (process.env.NODE_ENV !== 'production') {
4146
+ assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4147
+ }
4148
+
4149
+ return vm;
3915
4150
  }
4151
+
3916
4152
  function allocateInSlot(vm, children) {
3917
- var _a;
3918
- const { cmpSlots: oldSlots } = vm;
3919
- const cmpSlots = (vm.cmpSlots = create(null));
3920
- for (let i = 0, len = children.length; i < len; i += 1) {
3921
- const vnode = children[i];
3922
- if (isNull(vnode)) {
3923
- continue;
3924
- }
3925
- let slotName = '';
3926
- if (isVBaseElement(vnode)) {
3927
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3928
- }
3929
- const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3930
- ArrayPush$1.call(vnodes, vnode);
3931
- }
3932
- if (isFalse(vm.isDirty)) {
3933
- // We need to determine if the old allocation is really different from the new one
3934
- // and mark the vm as dirty
3935
- const oldKeys = keys(oldSlots);
3936
- if (oldKeys.length !== keys(cmpSlots).length) {
3937
- markComponentAsDirty(vm);
3938
- return;
3939
- }
3940
- for (let i = 0, len = oldKeys.length; i < len; i += 1) {
3941
- const key = oldKeys[i];
3942
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3943
- markComponentAsDirty(vm);
3944
- return;
3945
- }
3946
- const oldVNodes = oldSlots[key];
3947
- const vnodes = cmpSlots[key];
3948
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3949
- if (oldVNodes[j] !== vnodes[j]) {
3950
- markComponentAsDirty(vm);
3951
- return;
3952
- }
3953
- }
4153
+ var _a;
4154
+
4155
+ const {
4156
+ cmpSlots: oldSlots
4157
+ } = vm;
4158
+ const cmpSlots = vm.cmpSlots = create(null);
4159
+
4160
+ for (let i = 0, len = children.length; i < len; i += 1) {
4161
+ const vnode = children[i];
4162
+
4163
+ if (isNull(vnode)) {
4164
+ continue;
4165
+ }
4166
+
4167
+ let slotName = '';
4168
+
4169
+ if (isVBaseElement(vnode)) {
4170
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4171
+ }
4172
+
4173
+ const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4174
+ ArrayPush$1.call(vnodes, vnode);
4175
+ }
4176
+
4177
+ if (isFalse(vm.isDirty)) {
4178
+ // We need to determine if the old allocation is really different from the new one
4179
+ // and mark the vm as dirty
4180
+ const oldKeys = keys(oldSlots);
4181
+
4182
+ if (oldKeys.length !== keys(cmpSlots).length) {
4183
+ markComponentAsDirty(vm);
4184
+ return;
4185
+ }
4186
+
4187
+ for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4188
+ const key = oldKeys[i];
4189
+
4190
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4191
+ markComponentAsDirty(vm);
4192
+ return;
4193
+ }
4194
+
4195
+ const oldVNodes = oldSlots[key];
4196
+ const vnodes = cmpSlots[key];
4197
+
4198
+ for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4199
+ if (oldVNodes[j] !== vnodes[j]) {
4200
+ markComponentAsDirty(vm);
4201
+ return;
3954
4202
  }
4203
+ }
3955
4204
  }
3956
- }
3957
- // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3958
- const FromIteration = new WeakMap();
3959
- // dynamic children means it was generated by an iteration
4205
+ }
4206
+ } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4207
+
4208
+
4209
+ const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
3960
4210
  // in a template, and will require a more complex diffing algo.
4211
+
3961
4212
  function markAsDynamicChildren(children) {
3962
- FromIteration.set(children, 1);
4213
+ FromIteration.set(children, 1);
3963
4214
  }
4215
+
3964
4216
  function hasDynamicChildren(children) {
3965
- return FromIteration.has(children);
4217
+ return FromIteration.has(children);
3966
4218
  }
4219
+
3967
4220
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3968
- const map = {};
3969
- // TODO [#1637]: simplify this by assuming that all vnodes has keys
3970
- for (let j = beginIdx; j <= endIdx; ++j) {
3971
- const ch = children[j];
3972
- if (isVNode(ch)) {
3973
- const { key } = ch;
3974
- if (key !== undefined) {
3975
- map[key] = j;
3976
- }
3977
- }
4221
+ const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
4222
+
4223
+ for (let j = beginIdx; j <= endIdx; ++j) {
4224
+ const ch = children[j];
4225
+
4226
+ if (isVNode(ch)) {
4227
+ const {
4228
+ key
4229
+ } = ch;
4230
+
4231
+ if (key !== undefined) {
4232
+ map[key] = j;
4233
+ }
3978
4234
  }
3979
- return map;
4235
+ }
4236
+
4237
+ return map;
3980
4238
  }
4239
+
3981
4240
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3982
- let oldStartIdx = 0;
3983
- let newStartIdx = 0;
3984
- let oldEndIdx = oldCh.length - 1;
3985
- let oldStartVnode = oldCh[0];
3986
- let oldEndVnode = oldCh[oldEndIdx];
3987
- const newChEnd = newCh.length - 1;
3988
- let newEndIdx = newChEnd;
3989
- let newStartVnode = newCh[0];
3990
- let newEndVnode = newCh[newEndIdx];
3991
- let oldKeyToIdx;
3992
- let idxInOld;
3993
- let elmToMove;
3994
- let before;
3995
- let clonedOldCh = false;
3996
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3997
- if (!isVNode(oldStartVnode)) {
3998
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
3999
- }
4000
- else if (!isVNode(oldEndVnode)) {
4001
- oldEndVnode = oldCh[--oldEndIdx];
4002
- }
4003
- else if (!isVNode(newStartVnode)) {
4004
- newStartVnode = newCh[++newStartIdx];
4005
- }
4006
- else if (!isVNode(newEndVnode)) {
4007
- newEndVnode = newCh[--newEndIdx];
4008
- }
4009
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
4010
- patch(oldStartVnode, newStartVnode, parent, renderer);
4011
- oldStartVnode = oldCh[++oldStartIdx];
4012
- newStartVnode = newCh[++newStartIdx];
4013
- }
4014
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
4015
- patch(oldEndVnode, newEndVnode, parent, renderer);
4016
- oldEndVnode = oldCh[--oldEndIdx];
4017
- newEndVnode = newCh[--newEndIdx];
4018
- }
4019
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
4020
- // Vnode moved right
4021
- patch(oldStartVnode, newEndVnode, parent, renderer);
4022
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4023
- oldStartVnode = oldCh[++oldStartIdx];
4024
- newEndVnode = newCh[--newEndIdx];
4025
- }
4026
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
4027
- // Vnode moved left
4028
- patch(oldEndVnode, newStartVnode, parent, renderer);
4029
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4030
- oldEndVnode = oldCh[--oldEndIdx];
4031
- newStartVnode = newCh[++newStartIdx];
4032
- }
4033
- else {
4034
- if (oldKeyToIdx === undefined) {
4035
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4036
- }
4037
- idxInOld = oldKeyToIdx[newStartVnode.key];
4038
- if (isUndefined$1(idxInOld)) {
4039
- // New element
4040
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4041
- newStartVnode = newCh[++newStartIdx];
4042
- }
4043
- else {
4044
- elmToMove = oldCh[idxInOld];
4045
- if (isVNode(elmToMove)) {
4046
- if (elmToMove.sel !== newStartVnode.sel) {
4047
- // New element
4048
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4049
- }
4050
- else {
4051
- patch(elmToMove, newStartVnode, parent, renderer);
4052
- // Delete the old child, but copy the array since it is read-only.
4053
- // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4054
- // so we only care about the `oldCh` object inside this function.
4055
- // To avoid cloning over and over again, we check `clonedOldCh`
4056
- // and only clone once.
4057
- if (!clonedOldCh) {
4058
- clonedOldCh = true;
4059
- oldCh = [...oldCh];
4060
- }
4061
- // We've already cloned at least once, so it's no longer read-only
4062
- oldCh[idxInOld] = undefined;
4063
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4064
- }
4065
- }
4066
- newStartVnode = newCh[++newStartIdx];
4067
- }
4241
+ let oldStartIdx = 0;
4242
+ let newStartIdx = 0;
4243
+ let oldEndIdx = oldCh.length - 1;
4244
+ let oldStartVnode = oldCh[0];
4245
+ let oldEndVnode = oldCh[oldEndIdx];
4246
+ const newChEnd = newCh.length - 1;
4247
+ let newEndIdx = newChEnd;
4248
+ let newStartVnode = newCh[0];
4249
+ let newEndVnode = newCh[newEndIdx];
4250
+ let oldKeyToIdx;
4251
+ let idxInOld;
4252
+ let elmToMove;
4253
+ let before;
4254
+ let clonedOldCh = false;
4255
+
4256
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4257
+ if (!isVNode(oldStartVnode)) {
4258
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4259
+ } else if (!isVNode(oldEndVnode)) {
4260
+ oldEndVnode = oldCh[--oldEndIdx];
4261
+ } else if (!isVNode(newStartVnode)) {
4262
+ newStartVnode = newCh[++newStartIdx];
4263
+ } else if (!isVNode(newEndVnode)) {
4264
+ newEndVnode = newCh[--newEndIdx];
4265
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4266
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4267
+ oldStartVnode = oldCh[++oldStartIdx];
4268
+ newStartVnode = newCh[++newStartIdx];
4269
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4270
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4271
+ oldEndVnode = oldCh[--oldEndIdx];
4272
+ newEndVnode = newCh[--newEndIdx];
4273
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4274
+ // Vnode moved right
4275
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4276
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4277
+ oldStartVnode = oldCh[++oldStartIdx];
4278
+ newEndVnode = newCh[--newEndIdx];
4279
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4280
+ // Vnode moved left
4281
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4282
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4283
+ oldEndVnode = oldCh[--oldEndIdx];
4284
+ newStartVnode = newCh[++newStartIdx];
4285
+ } else {
4286
+ if (oldKeyToIdx === undefined) {
4287
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4288
+ }
4289
+
4290
+ idxInOld = oldKeyToIdx[newStartVnode.key];
4291
+
4292
+ if (isUndefined$1(idxInOld)) {
4293
+ // New element
4294
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4295
+ newStartVnode = newCh[++newStartIdx];
4296
+ } else {
4297
+ elmToMove = oldCh[idxInOld];
4298
+
4299
+ if (isVNode(elmToMove)) {
4300
+ if (elmToMove.sel !== newStartVnode.sel) {
4301
+ // New element
4302
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4303
+ } else {
4304
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4305
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4306
+ // so we only care about the `oldCh` object inside this function.
4307
+ // To avoid cloning over and over again, we check `clonedOldCh`
4308
+ // and only clone once.
4309
+
4310
+ if (!clonedOldCh) {
4311
+ clonedOldCh = true;
4312
+ oldCh = [...oldCh];
4313
+ } // We've already cloned at least once, so it's no longer read-only
4314
+
4315
+
4316
+ oldCh[idxInOld] = undefined;
4317
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4318
+ }
4068
4319
  }
4320
+
4321
+ newStartVnode = newCh[++newStartIdx];
4322
+ }
4069
4323
  }
4070
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4071
- if (oldStartIdx > oldEndIdx) {
4072
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4073
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4074
- let i = newEndIdx;
4075
- let n;
4076
- do {
4077
- n = newCh[++i];
4078
- } while (!isVNode(n) && i < newChEnd);
4079
- before = isVNode(n) ? n.elm : null;
4080
- mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4081
- }
4082
- else {
4083
- unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4084
- }
4324
+ }
4325
+
4326
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4327
+ if (oldStartIdx > oldEndIdx) {
4328
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4329
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4330
+ let i = newEndIdx;
4331
+ let n;
4332
+
4333
+ do {
4334
+ n = newCh[++i];
4335
+ } while (!isVNode(n) && i < newChEnd);
4336
+
4337
+ before = isVNode(n) ? n.elm : null;
4338
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4339
+ } else {
4340
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4085
4341
  }
4342
+ }
4086
4343
  }
4344
+
4087
4345
  function updateStaticChildren(c1, c2, parent, renderer) {
4088
- const c1Length = c1.length;
4089
- const c2Length = c2.length;
4090
- if (c1Length === 0) {
4091
- // the old list is empty, we can directly insert anything new
4092
- mountVNodes(c2, parent, renderer, null);
4093
- return;
4094
- }
4095
- if (c2Length === 0) {
4096
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4097
- // this is the case in which the dynamic children of an if-directive should be removed
4098
- unmountVNodes(c1, parent, renderer, true);
4099
- return;
4100
- }
4101
- // if the old list is not empty, the new list MUST have the same
4102
- // amount of nodes, that's why we call this static children
4103
- let anchor = null;
4104
- for (let i = c2Length - 1; i >= 0; i -= 1) {
4105
- const n1 = c1[i];
4106
- const n2 = c2[i];
4107
- if (n2 !== n1) {
4108
- if (isVNode(n1)) {
4109
- if (isVNode(n2)) {
4110
- // both vnodes are equivalent, and we just need to patch them
4111
- patch(n1, n2, parent, renderer);
4112
- anchor = n2.elm;
4113
- }
4114
- else {
4115
- // removing the old vnode since the new one is null
4116
- unmount(n1, parent, renderer, true);
4117
- }
4118
- }
4119
- else if (isVNode(n2)) {
4120
- mount(n2, parent, renderer, anchor);
4121
- anchor = n2.elm;
4122
- }
4346
+ const c1Length = c1.length;
4347
+ const c2Length = c2.length;
4348
+
4349
+ if (c1Length === 0) {
4350
+ // the old list is empty, we can directly insert anything new
4351
+ mountVNodes(c2, parent, renderer, null);
4352
+ return;
4353
+ }
4354
+
4355
+ if (c2Length === 0) {
4356
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4357
+ // this is the case in which the dynamic children of an if-directive should be removed
4358
+ unmountVNodes(c1, parent, renderer, true);
4359
+ return;
4360
+ } // if the old list is not empty, the new list MUST have the same
4361
+ // amount of nodes, that's why we call this static children
4362
+
4363
+
4364
+ let anchor = null;
4365
+
4366
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4367
+ const n1 = c1[i];
4368
+ const n2 = c2[i];
4369
+
4370
+ if (n2 !== n1) {
4371
+ if (isVNode(n1)) {
4372
+ if (isVNode(n2)) {
4373
+ // both vnodes are equivalent, and we just need to patch them
4374
+ patch(n1, n2, parent, renderer);
4375
+ anchor = n2.elm;
4376
+ } else {
4377
+ // removing the old vnode since the new one is null
4378
+ unmount(n1, parent, renderer, true);
4123
4379
  }
4380
+ } else if (isVNode(n2)) {
4381
+ mount(n2, parent, renderer, anchor);
4382
+ anchor = n2.elm;
4383
+ }
4124
4384
  }
4385
+ }
4125
4386
  }
4126
4387
 
4127
4388
  /*
@@ -5976,7 +6237,7 @@ function freezeTemplate(tmpl) {
5976
6237
  });
5977
6238
  }
5978
6239
  }
5979
- /* version: 2.23.1 */
6240
+ /* version: 2.23.2 */
5980
6241
 
5981
6242
  /*
5982
6243
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6446,6 +6707,6 @@ function renderComponent(tagName, Ctor, props = {}) {
6446
6707
  */
6447
6708
  freeze(LightningElement);
6448
6709
  seal(LightningElement.prototype);
6449
- /* version: 2.23.1 */
6710
+ /* version: 2.23.2 */
6450
6711
 
6451
6712
  export { LightningElement, api$1 as api, createContextProvider, freezeTemplate, getComponentDef, isComponentConstructor, parseFragment, parseFragment as parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };