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