lwc 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +603 -449
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +603 -449
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +477 -398
  5. package/dist/engine-dom/iife/es5/engine-dom.js +657 -479
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +509 -425
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +603 -449
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +477 -398
  11. package/dist/engine-dom/umd/es5/engine-dom.js +657 -479
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +509 -425
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +391 -285
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +391 -285
  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
@@ -309,7 +309,17 @@
309
309
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
310
310
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
311
311
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
312
- /** version: 2.9.0 */
312
+ /*
313
+ * Copyright (c) 2018, salesforce.com, inc.
314
+ * All rights reserved.
315
+ * SPDX-License-Identifier: MIT
316
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
317
+ */
318
+ // Increment whenever the LWC template compiler changes
319
+
320
+ const LWC_VERSION = "2.10.0";
321
+ const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
322
+ /** version: 2.10.0 */
313
323
 
314
324
  /*
315
325
  * Copyright (c) 2018, salesforce.com, inc.
@@ -376,7 +386,7 @@
376
386
  };
377
387
  }
378
388
 
379
- function patch(propName) {
389
+ function patch$1(propName) {
380
390
  // Typescript is inferring the wrong function type for this particular
381
391
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
382
392
  // @ts-ignore type-mismatch
@@ -398,7 +408,7 @@
398
408
  const propName = ElementPrototypeAriaPropertyNames[i];
399
409
 
400
410
  if (detect(propName)) {
401
- patch(propName);
411
+ patch$1(propName);
402
412
  }
403
413
  }
404
414
  /**
@@ -414,14 +424,15 @@
414
424
 
415
425
 
416
426
  const features = {
417
- ENABLE_REACTIVE_SETTER: null,
418
- ENABLE_HMR: null,
419
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
427
+ DISABLE_MIXED_SHADOW_MODE: null,
420
428
  ENABLE_ELEMENT_PATCH: null,
421
429
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
422
- ENABLE_NODE_LIST_PATCH: null,
430
+ ENABLE_HMR: null,
423
431
  ENABLE_HTML_COLLECTIONS_PATCH: null,
432
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
433
+ ENABLE_NODE_LIST_PATCH: null,
424
434
  ENABLE_NODE_PATCH: null,
435
+ ENABLE_REACTIVE_SETTER: null,
425
436
  ENABLE_WIRE_SYNC_EMIT: null
426
437
  };
427
438
 
@@ -486,7 +497,7 @@
486
497
  setFeatureFlag(name, value);
487
498
  }
488
499
  }
489
- /** version: 2.9.0 */
500
+ /** version: 2.10.0 */
490
501
 
491
502
  /* proxy-compat-disable */
492
503
 
@@ -573,6 +584,20 @@
573
584
  }
574
585
 
575
586
  return result;
587
+ }
588
+
589
+ function flattenStylesheets(stylesheets) {
590
+ const list = [];
591
+
592
+ for (const stylesheet of stylesheets) {
593
+ if (!Array.isArray(stylesheet)) {
594
+ list.push(stylesheet);
595
+ } else {
596
+ list.push(...flattenStylesheets(stylesheet));
597
+ }
598
+ }
599
+
600
+ return list;
576
601
  } //
577
602
  // Primitives
578
603
  //
@@ -3378,6 +3403,47 @@
3378
3403
  const meta = signedDecoratorToMetaMap.get(Ctor);
3379
3404
  return isUndefined$1(meta) ? defaultMeta : meta;
3380
3405
  }
3406
+ /*
3407
+ * Copyright (c) 2018, salesforce.com, inc.
3408
+ * All rights reserved.
3409
+ * SPDX-License-Identifier: MIT
3410
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3411
+ */
3412
+
3413
+
3414
+ let warned = false;
3415
+
3416
+ if (process.env.NODE_ENV === 'development') {
3417
+ // @ts-ignore
3418
+ window.__lwcResetWarnedOnVersionMismatch = () => {
3419
+ warned = false;
3420
+ };
3421
+ }
3422
+
3423
+ function checkVersionMismatch(func, type) {
3424
+ const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3425
+
3426
+ if (!isNull(versionMatcher) && !warned) {
3427
+ const version = versionMatcher[1];
3428
+ const [major, minor] = version.split('.');
3429
+ const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
3430
+
3431
+ if (major !== expectedMajor || minor !== expectedMinor) {
3432
+ warned = true; // only warn once to avoid flooding the console
3433
+ // stylesheets and templates do not have user-meaningful names, but components do
3434
+
3435
+ const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
3436
+ logError(`LWC WARNING: current engine is v${LWC_VERSION}, but ${friendlyName} was compiled with v${version}.\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear.`);
3437
+ }
3438
+ }
3439
+ }
3440
+ /*
3441
+ * Copyright (c) 2018, salesforce.com, inc.
3442
+ * All rights reserved.
3443
+ * SPDX-License-Identifier: MIT
3444
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3445
+ */
3446
+
3381
3447
 
3382
3448
  const signedTemplateSet = new Set();
3383
3449
 
@@ -3390,6 +3456,16 @@
3390
3456
  function isTemplateRegistered(tpl) {
3391
3457
  return signedTemplateSet.has(tpl);
3392
3458
  }
3459
+
3460
+ function checkTemplateVersionMismatch(template) {
3461
+ checkVersionMismatch(template, 'template');
3462
+
3463
+ if (!isUndefined$1(template.stylesheets)) {
3464
+ for (const stylesheet of flattenStylesheets(template.stylesheets)) {
3465
+ checkVersionMismatch(stylesheet, 'stylesheet');
3466
+ }
3467
+ }
3468
+ }
3393
3469
  /**
3394
3470
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3395
3471
  * will prevent this function from being imported by userland code.
@@ -3397,6 +3473,10 @@
3397
3473
 
3398
3474
 
3399
3475
  function registerTemplate(tpl) {
3476
+ if (process.env.NODE_ENV !== 'production') {
3477
+ checkTemplateVersionMismatch(tpl);
3478
+ }
3479
+
3400
3480
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3401
3481
  // assignment of templates easily, without too much transformation
3402
3482
 
@@ -3692,20 +3772,6 @@
3692
3772
  return canRefreshAllInstances;
3693
3773
  }
3694
3774
 
3695
- function flattenStylesheets(stylesheets) {
3696
- const list = [];
3697
-
3698
- for (const stylesheet of stylesheets) {
3699
- if (!Array.isArray(stylesheet)) {
3700
- list.push(stylesheet);
3701
- } else {
3702
- list.push(...flattenStylesheets(stylesheet));
3703
- }
3704
- }
3705
-
3706
- return list;
3707
- }
3708
-
3709
3775
  function getTemplateOrSwappedTemplate(tpl) {
3710
3776
  if (process.env.NODE_ENV === 'production') {
3711
3777
  // this method should never leak to prod
@@ -4536,156 +4602,268 @@
4536
4602
  */
4537
4603
 
4538
4604
 
4539
- const TextHook = {
4540
- create: vnode => {
4541
- const {
4542
- owner
4543
- } = vnode;
4544
- const elm = createText$1(vnode.text);
4545
- linkNodeToShadow(elm, owner);
4546
- vnode.elm = elm;
4547
- },
4548
- update: updateNodeHook,
4549
- insert: insertNode,
4550
- move: insertNode,
4551
- remove: removeNode
4552
- };
4553
- const CommentHook = {
4554
- create: vnode => {
4555
- const {
4556
- owner,
4557
- text
4558
- } = vnode;
4559
- const elm = createComment$1(text);
4560
- linkNodeToShadow(elm, owner);
4561
- vnode.elm = elm;
4562
- },
4563
- update: updateNodeHook,
4564
- insert: insertNode,
4565
- move: insertNode,
4566
- remove: removeNode
4567
- }; // insert is called after update, which is used somewhere else (via a module)
4568
- // to mark the vm as inserted, that means we cannot use update as the main channel
4569
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4570
- // which breaks some invariants. For that reason, we have the following for any
4571
- // Custom Element that is inserted via a template.
4572
-
4573
- const ElementHook = {
4574
- create: vnode => {
4575
- const {
4576
- sel,
4577
- owner,
4578
- data: {
4579
- svg
4580
- }
4581
- } = vnode;
4582
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4583
- const elm = createElement$2(sel, namespace);
4584
- linkNodeToShadow(elm, owner);
4585
- fallbackElmHook(elm, vnode);
4586
- vnode.elm = elm;
4587
- patchElementPropsAndAttrs$1(null, vnode);
4588
- },
4589
- update: (oldVnode, vnode) => {
4590
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4591
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4592
- },
4593
- insert: (vnode, parentNode, referenceNode) => {
4594
- insertNode(vnode, parentNode, referenceNode);
4595
- createChildrenHook(vnode);
4596
- },
4597
- move: insertNode,
4598
- remove: (vnode, parentNode) => {
4599
- removeNode(vnode, parentNode);
4600
- removeChildren(vnode);
4605
+ function patchChildren(c1, c2, parent) {
4606
+ if (hasDynamicChildren(c2)) {
4607
+ updateDynamicChildren(c1, c2, parent);
4608
+ } else {
4609
+ updateStaticChildren(c1, c2, parent);
4610
+ }
4611
+ }
4612
+
4613
+ function patch(n1, n2) {
4614
+ if (n1 === n2) {
4615
+ return;
4601
4616
  }
4602
- };
4603
- const CustomElementHook = {
4604
- create: vnode => {
4605
- const {
4606
- sel,
4607
- owner
4608
- } = vnode;
4609
- const UpgradableConstructor = getUpgradableConstructor(sel);
4610
- /**
4611
- * Note: if the upgradable constructor does not expect, or throw when we new it
4612
- * with a callback as the first argument, we could implement a more advanced
4613
- * mechanism that only passes that argument if the constructor is known to be
4614
- * an upgradable custom element.
4615
- */
4616
-
4617
- let vm;
4618
- const elm = new UpgradableConstructor(elm => {
4619
- // the custom element from the registry is expecting an upgrade callback
4620
- vm = createViewModelHook(elm, vnode);
4621
- });
4622
- linkNodeToShadow(elm, owner);
4623
- vnode.elm = elm;
4624
4617
 
4625
- if (vm) {
4626
- allocateChildren(vnode, vm);
4627
- } else if (vnode.ctor !== UpgradableConstructor) {
4628
- throw new TypeError(`Incorrect Component Constructor`);
4618
+ if (process.env.NODE_ENV !== 'production') {
4619
+ if (!isSameVnode(n1, n2)) {
4620
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4621
+ sel: n1.sel,
4622
+ key: n1.key
4623
+ }) + ', ' + JSON.stringify({
4624
+ sel: n2.sel,
4625
+ key: n2.key
4626
+ }));
4629
4627
  }
4628
+ }
4630
4629
 
4631
- patchElementPropsAndAttrs$1(null, vnode);
4632
- },
4633
- update: (oldVnode, vnode) => {
4634
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4635
- const vm = getAssociatedVMIfPresent(vnode.elm);
4630
+ switch (n2.type) {
4631
+ case 0
4632
+ /* Text */
4633
+ :
4634
+ patchText(n1, n2);
4635
+ break;
4636
+
4637
+ case 1
4638
+ /* Comment */
4639
+ :
4640
+ patchComment(n1, n2);
4641
+ break;
4636
4642
 
4637
- if (vm) {
4638
- // in fallback mode, the allocation will always set children to
4639
- // empty and delegate the real allocation to the slot elements
4640
- allocateChildren(vnode, vm);
4641
- } // in fallback mode, the children will be always empty, so, nothing
4642
- // will happen, but in native, it does allocate the light dom
4643
+ case 2
4644
+ /* Element */
4645
+ :
4646
+ patchElement(n1, n2);
4647
+ break;
4643
4648
 
4649
+ case 3
4650
+ /* CustomElement */
4651
+ :
4652
+ patchCustomElement(n1, n2);
4653
+ break;
4654
+ }
4655
+ }
4644
4656
 
4645
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4657
+ function mount(node, parent, anchor) {
4658
+ switch (node.type) {
4659
+ case 0
4660
+ /* Text */
4661
+ :
4662
+ mountText(node, parent, anchor);
4663
+ break;
4646
4664
 
4647
- if (vm) {
4648
- if (process.env.NODE_ENV !== 'production') {
4649
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4650
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4651
- // this is important to preserve the top to bottom synchronous rendering phase.
4665
+ case 1
4666
+ /* Comment */
4667
+ :
4668
+ mountComment(node, parent, anchor);
4669
+ break;
4670
+
4671
+ case 2
4672
+ /* Element */
4673
+ :
4674
+ mountElement(node, parent, anchor);
4675
+ break;
4676
+
4677
+ case 3
4678
+ /* CustomElement */
4679
+ :
4680
+ mountCustomElement(node, parent, anchor);
4681
+ break;
4682
+ }
4683
+ }
4652
4684
 
4685
+ function patchText(n1, n2) {
4686
+ n2.elm = n1.elm;
4653
4687
 
4654
- rerenderVM(vm);
4688
+ if (n2.text !== n1.text) {
4689
+ updateTextContent(n2);
4690
+ }
4691
+ }
4692
+
4693
+ function mountText(node, parent, anchor) {
4694
+ const {
4695
+ owner
4696
+ } = node;
4697
+ const textNode = node.elm = createText$1(node.text);
4698
+ linkNodeToShadow(textNode, owner);
4699
+ insertNode(textNode, parent, anchor);
4700
+ }
4701
+
4702
+ function patchComment(n1, n2) {
4703
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4704
+ // it is the case today.
4705
+
4706
+ if (n2.text !== n1.text) {
4707
+ updateTextContent(n2);
4708
+ }
4709
+ }
4710
+
4711
+ function mountComment(node, parent, anchor) {
4712
+ const {
4713
+ owner
4714
+ } = node;
4715
+ const commentNode = node.elm = createComment$1(node.text);
4716
+ linkNodeToShadow(commentNode, owner);
4717
+ insertNode(commentNode, parent, anchor);
4718
+ }
4719
+
4720
+ function mountElement(vnode, parent, anchor) {
4721
+ const {
4722
+ sel,
4723
+ owner,
4724
+ data: {
4725
+ svg
4655
4726
  }
4656
- },
4657
- insert: (vnode, parentNode, referenceNode) => {
4658
- insertNode(vnode, parentNode, referenceNode);
4659
- const vm = getAssociatedVMIfPresent(vnode.elm);
4727
+ } = vnode;
4728
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4729
+ const elm = createElement$2(sel, namespace);
4730
+ linkNodeToShadow(elm, owner);
4731
+ fallbackElmHook(elm, vnode);
4732
+ vnode.elm = elm;
4733
+ patchElementPropsAndAttrs$1(null, vnode);
4734
+ insertNode(elm, parent, anchor);
4735
+ mountVNodes(vnode.children, elm, null);
4736
+ }
4660
4737
 
4661
- if (vm) {
4662
- if (process.env.NODE_ENV !== 'production') {
4663
- assert.isTrue(vm.state === 0
4664
- /* created */
4665
- , `${vm} cannot be recycled.`);
4666
- }
4738
+ function patchElement(n1, n2) {
4739
+ const elm = n2.elm = n1.elm;
4740
+ patchElementPropsAndAttrs$1(n1, n2);
4741
+ patchChildren(n1.children, n2.children, elm);
4742
+ }
4743
+
4744
+ function mountCustomElement(vnode, parent, anchor) {
4745
+ const {
4746
+ sel,
4747
+ owner
4748
+ } = vnode;
4749
+ const UpgradableConstructor = getUpgradableConstructor(sel);
4750
+ /**
4751
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4752
+ * with a callback as the first argument, we could implement a more advanced
4753
+ * mechanism that only passes that argument if the constructor is known to be
4754
+ * an upgradable custom element.
4755
+ */
4756
+
4757
+ let vm;
4758
+ const elm = new UpgradableConstructor(elm => {
4759
+ // the custom element from the registry is expecting an upgrade callback
4760
+ vm = createViewModelHook(elm, vnode);
4761
+ });
4762
+ linkNodeToShadow(elm, owner);
4763
+ vnode.elm = elm;
4764
+ vnode.vm = vm;
4765
+
4766
+ if (vm) {
4767
+ allocateChildren(vnode, vm);
4768
+ } else if (vnode.ctor !== UpgradableConstructor) {
4769
+ throw new TypeError(`Incorrect Component Constructor`);
4770
+ }
4771
+
4772
+ patchElementPropsAndAttrs$1(null, vnode);
4773
+ insertNode(elm, parent, anchor);
4667
4774
 
4668
- runConnectedCallback(vm);
4775
+ if (vm) {
4776
+ if (process.env.NODE_ENV !== 'production') {
4777
+ assert.isTrue(vm.state === 0
4778
+ /* created */
4779
+ , `${vm} cannot be recycled.`);
4669
4780
  }
4670
4781
 
4671
- createChildrenHook(vnode);
4782
+ runConnectedCallback(vm);
4783
+ }
4784
+
4785
+ mountVNodes(vnode.children, elm, null);
4786
+
4787
+ if (vm) {
4788
+ appendVM(vm);
4789
+ }
4790
+ }
4791
+
4792
+ function patchCustomElement(n1, n2) {
4793
+ const elm = n2.elm = n1.elm;
4794
+ const vm = n2.vm = n1.vm;
4795
+ patchElementPropsAndAttrs$1(n1, n2);
4796
+
4797
+ if (!isUndefined$1(vm)) {
4798
+ // in fallback mode, the allocation will always set children to
4799
+ // empty and delegate the real allocation to the slot elements
4800
+ allocateChildren(n2, vm);
4801
+ } // in fallback mode, the children will be always empty, so, nothing
4802
+ // will happen, but in native, it does allocate the light dom
4803
+
4804
+
4805
+ patchChildren(n1.children, n2.children, elm);
4806
+
4807
+ if (!isUndefined$1(vm)) {
4808
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4809
+ // this is important to preserve the top to bottom synchronous rendering phase.
4810
+ rerenderVM(vm);
4811
+ }
4812
+ }
4813
+
4814
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
4815
+ for (; start < end; ++start) {
4816
+ const vnode = vnodes[start];
4672
4817
 
4673
- if (vm) {
4674
- appendVM(vm);
4818
+ if (isVNode(vnode)) {
4819
+ mount(vnode, parent, anchor);
4675
4820
  }
4676
- },
4677
- move: insertNode,
4678
- remove: (vnode, parentNode) => {
4679
- removeNode(vnode, parentNode);
4680
- const vm = getAssociatedVMIfPresent(vnode.elm);
4821
+ }
4822
+ }
4823
+
4824
+ function unmount(vnode, parent, doRemove = false) {
4825
+ const {
4826
+ type,
4827
+ elm
4828
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4829
+ // subtree root, is the only element worth unmounting from the subtree.
4830
+
4831
+ if (doRemove) {
4832
+ removeNode(elm, parent);
4833
+ }
4834
+
4835
+ switch (type) {
4836
+ case 2
4837
+ /* Element */
4838
+ :
4839
+ unmountVNodes(vnode.children, elm);
4840
+ break;
4841
+
4842
+ case 3
4843
+ /* CustomElement */
4844
+ :
4845
+ {
4846
+ const {
4847
+ vm
4848
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
4849
+ // children.
4850
+
4851
+ if (!isUndefined$1(vm)) {
4852
+ removeVM(vm);
4853
+ }
4854
+ }
4855
+ }
4856
+ }
4857
+
4858
+ function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
4859
+ for (; start < end; ++start) {
4860
+ const ch = vnodes[start];
4681
4861
 
4682
- if (vm) {
4683
- // for custom elements we don't have to go recursively because the removeVM routine
4684
- // will take care of disconnecting any child VM attached to its shadow as well.
4685
- removeVM(vm);
4862
+ if (isVNode(ch)) {
4863
+ unmount(ch, parent, doRemove);
4686
4864
  }
4687
4865
  }
4688
- };
4866
+ }
4689
4867
 
4690
4868
  function isVNode(vnode) {
4691
4869
  return vnode != null;
@@ -4730,43 +4908,41 @@
4730
4908
  }
4731
4909
  }
4732
4910
 
4733
- function updateNodeHook(oldVnode, vnode) {
4911
+ function updateTextContent(vnode) {
4734
4912
  const {
4735
4913
  elm,
4736
4914
  text
4737
4915
  } = vnode;
4738
4916
 
4739
- if (oldVnode.text !== text) {
4740
- if (process.env.NODE_ENV !== 'production') {
4741
- unlockDomMutation();
4742
- }
4917
+ if (process.env.NODE_ENV !== 'production') {
4918
+ unlockDomMutation();
4919
+ }
4743
4920
 
4744
- setText$1(elm, text);
4921
+ setText$1(elm, text);
4745
4922
 
4746
- if (process.env.NODE_ENV !== 'production') {
4747
- lockDomMutation();
4748
- }
4923
+ if (process.env.NODE_ENV !== 'production') {
4924
+ lockDomMutation();
4749
4925
  }
4750
4926
  }
4751
4927
 
4752
- function insertNode(vnode, parentNode, referenceNode) {
4928
+ function insertNode(node, parent, anchor) {
4753
4929
  if (process.env.NODE_ENV !== 'production') {
4754
4930
  unlockDomMutation();
4755
4931
  }
4756
4932
 
4757
- insert$1(vnode.elm, parentNode, referenceNode);
4933
+ insert$1(node, parent, anchor);
4758
4934
 
4759
4935
  if (process.env.NODE_ENV !== 'production') {
4760
4936
  lockDomMutation();
4761
4937
  }
4762
4938
  }
4763
4939
 
4764
- function removeNode(vnode, parentNode) {
4940
+ function removeNode(node, parent) {
4765
4941
  if (process.env.NODE_ENV !== 'production') {
4766
4942
  unlockDomMutation();
4767
4943
  }
4768
4944
 
4769
- remove$1(vnode.elm, parentNode);
4945
+ remove$1(node, parent);
4770
4946
 
4771
4947
  if (process.env.NODE_ENV !== 'production') {
4772
4948
  lockDomMutation();
@@ -4839,14 +5015,6 @@
4839
5015
  }
4840
5016
  }
4841
5017
 
4842
- function patchChildren(parent, oldCh, newCh) {
4843
- if (hasDynamicChildren(newCh)) {
4844
- updateDynamicChildren(parent, oldCh, newCh);
4845
- } else {
4846
- updateStaticChildren(parent, oldCh, newCh);
4847
- }
4848
- }
4849
-
4850
5018
  function allocateChildren(vnode, vm) {
4851
5019
  // A component with slots will re-render because:
4852
5020
  // 1- There is a change of the internal state.
@@ -4922,50 +5090,16 @@
4922
5090
  return vm;
4923
5091
  }
4924
5092
 
4925
- function createChildrenHook(vnode) {
5093
+ function allocateInSlot(vm, children) {
5094
+ var _a;
5095
+
4926
5096
  const {
4927
- elm,
4928
- children
4929
- } = vnode;
5097
+ cmpSlots: oldSlots
5098
+ } = vm;
5099
+ const cmpSlots = vm.cmpSlots = create(null);
4930
5100
 
4931
- for (let j = 0; j < children.length; ++j) {
4932
- const ch = children[j];
4933
-
4934
- if (ch != null) {
4935
- ch.hook.create(ch);
4936
- ch.hook.insert(ch, elm, null);
4937
- }
4938
- }
4939
- }
4940
-
4941
- function removeChildren(vnode) {
4942
- // this method only needs to search on child vnodes from template
4943
- // to trigger the remove hook just in case some of those children
4944
- // are custom elements.
4945
- const {
4946
- children,
4947
- elm
4948
- } = vnode;
4949
-
4950
- for (let j = 0, len = children.length; j < len; ++j) {
4951
- const ch = children[j];
4952
-
4953
- if (!isNull(ch)) {
4954
- ch.hook.remove(ch, elm);
4955
- }
4956
- }
4957
- }
4958
-
4959
- function allocateInSlot(vm, children) {
4960
- var _a;
4961
-
4962
- const {
4963
- cmpSlots: oldSlots
4964
- } = vm;
4965
- const cmpSlots = vm.cmpSlots = create(null);
4966
-
4967
- for (let i = 0, len = children.length; i < len; i += 1) {
4968
- const vnode = children[i];
5101
+ for (let i = 0, len = children.length; i < len; i += 1) {
5102
+ const vnode = children[i];
4969
5103
 
4970
5104
  if (isNull(vnode)) {
4971
5105
  continue;
@@ -5052,28 +5186,7 @@
5052
5186
  return map;
5053
5187
  }
5054
5188
 
5055
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
5056
- for (; startIdx <= endIdx; ++startIdx) {
5057
- const ch = vnodes[startIdx];
5058
-
5059
- if (isVNode(ch)) {
5060
- ch.hook.create(ch);
5061
- ch.hook.insert(ch, parentElm, before);
5062
- }
5063
- }
5064
- }
5065
-
5066
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
5067
- for (; startIdx <= endIdx; ++startIdx) {
5068
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
5069
-
5070
- if (isVNode(ch)) {
5071
- ch.hook.remove(ch, parentElm);
5072
- }
5073
- }
5074
- }
5075
-
5076
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5189
+ function updateDynamicChildren(oldCh, newCh, parent) {
5077
5190
  let oldStartIdx = 0;
5078
5191
  let newStartIdx = 0;
5079
5192
  let oldEndIdx = oldCh.length - 1;
@@ -5099,23 +5212,23 @@
5099
5212
  } else if (!isVNode(newEndVnode)) {
5100
5213
  newEndVnode = newCh[--newEndIdx];
5101
5214
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5102
- patchVnode(oldStartVnode, newStartVnode);
5215
+ patch(oldStartVnode, newStartVnode);
5103
5216
  oldStartVnode = oldCh[++oldStartIdx];
5104
5217
  newStartVnode = newCh[++newStartIdx];
5105
5218
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5106
- patchVnode(oldEndVnode, newEndVnode);
5219
+ patch(oldEndVnode, newEndVnode);
5107
5220
  oldEndVnode = oldCh[--oldEndIdx];
5108
5221
  newEndVnode = newCh[--newEndIdx];
5109
5222
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5110
5223
  // Vnode moved right
5111
- patchVnode(oldStartVnode, newEndVnode);
5112
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5224
+ patch(oldStartVnode, newEndVnode);
5225
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5113
5226
  oldStartVnode = oldCh[++oldStartIdx];
5114
5227
  newEndVnode = newCh[--newEndIdx];
5115
5228
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5116
5229
  // Vnode moved left
5117
- patchVnode(oldEndVnode, newStartVnode);
5118
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5230
+ patch(oldEndVnode, newStartVnode);
5231
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5119
5232
  oldEndVnode = oldCh[--oldEndIdx];
5120
5233
  newStartVnode = newCh[++newStartIdx];
5121
5234
  } else {
@@ -5127,8 +5240,7 @@
5127
5240
 
5128
5241
  if (isUndefined$1(idxInOld)) {
5129
5242
  // New element
5130
- newStartVnode.hook.create(newStartVnode);
5131
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5243
+ mount(newStartVnode, parent, oldStartVnode.elm);
5132
5244
  newStartVnode = newCh[++newStartIdx];
5133
5245
  } else {
5134
5246
  elmToMove = oldCh[idxInOld];
@@ -5136,10 +5248,9 @@
5136
5248
  if (isVNode(elmToMove)) {
5137
5249
  if (elmToMove.sel !== newStartVnode.sel) {
5138
5250
  // New element
5139
- newStartVnode.hook.create(newStartVnode);
5140
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5251
+ mount(newStartVnode, parent, oldStartVnode.elm);
5141
5252
  } else {
5142
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5253
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5143
5254
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5144
5255
  // so we only care about the `oldCh` object inside this function.
5145
5256
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -5152,7 +5263,7 @@
5152
5263
 
5153
5264
 
5154
5265
  oldCh[idxInOld] = undefined;
5155
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5266
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5156
5267
  }
5157
5268
  }
5158
5269
 
@@ -5173,65 +5284,55 @@
5173
5284
  } while (!isVNode(n) && i < newChEnd);
5174
5285
 
5175
5286
  before = isVNode(n) ? n.elm : null;
5176
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5287
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5177
5288
  } else {
5178
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5289
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5179
5290
  }
5180
5291
  }
5181
5292
  }
5182
5293
 
5183
- function updateStaticChildren(parentElm, oldCh, newCh) {
5184
- const oldChLength = oldCh.length;
5185
- const newChLength = newCh.length;
5294
+ function updateStaticChildren(c1, c2, parent) {
5295
+ const c1Length = c1.length;
5296
+ const c2Length = c2.length;
5186
5297
 
5187
- if (oldChLength === 0) {
5298
+ if (c1Length === 0) {
5188
5299
  // the old list is empty, we can directly insert anything new
5189
- addVnodes(parentElm, null, newCh, 0, newChLength);
5300
+ mountVNodes(c2, parent, null);
5190
5301
  return;
5191
5302
  }
5192
5303
 
5193
- if (newChLength === 0) {
5304
+ if (c2Length === 0) {
5194
5305
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5195
5306
  // this is the case in which the dynamic children of an if-directive should be removed
5196
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5307
+ unmountVNodes(c1, parent, true);
5197
5308
  return;
5198
5309
  } // if the old list is not empty, the new list MUST have the same
5199
5310
  // amount of nodes, that's why we call this static children
5200
5311
 
5201
5312
 
5202
- let referenceElm = null;
5313
+ let anchor = null;
5203
5314
 
5204
- for (let i = newChLength - 1; i >= 0; i -= 1) {
5205
- const vnode = newCh[i];
5206
- const oldVNode = oldCh[i];
5315
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
5316
+ const n1 = c1[i];
5317
+ const n2 = c2[i];
5207
5318
 
5208
- if (vnode !== oldVNode) {
5209
- if (isVNode(oldVNode)) {
5210
- if (isVNode(vnode)) {
5211
- // both vnodes must be equivalent, and se just need to patch them
5212
- patchVnode(oldVNode, vnode);
5213
- referenceElm = vnode.elm;
5319
+ if (n2 !== n1) {
5320
+ if (isVNode(n1)) {
5321
+ if (isVNode(n2)) {
5322
+ // both vnodes are equivalent, and we just need to patch them
5323
+ patch(n1, n2);
5324
+ anchor = n2.elm;
5214
5325
  } else {
5215
5326
  // removing the old vnode since the new one is null
5216
- oldVNode.hook.remove(oldVNode, parentElm);
5327
+ unmount(n1, parent, true);
5217
5328
  }
5218
- } else if (isVNode(vnode)) {
5219
- // this condition is unnecessary
5220
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5221
-
5222
- vnode.hook.insert(vnode, parentElm, referenceElm);
5223
- referenceElm = vnode.elm;
5329
+ } else if (isVNode(n2)) {
5330
+ mount(n2, parent, anchor);
5331
+ anchor = n2.elm;
5224
5332
  }
5225
5333
  }
5226
5334
  }
5227
5335
  }
5228
-
5229
- function patchVnode(oldVnode, vnode) {
5230
- if (oldVnode !== vnode) {
5231
- vnode.elm = oldVnode.elm;
5232
- vnode.hook.update(oldVnode, vnode);
5233
- }
5234
- }
5235
5336
  /*
5236
5337
  * Copyright (c) 2018, salesforce.com, inc.
5237
5338
  * All rights reserved.
@@ -5283,7 +5384,6 @@
5283
5384
  children,
5284
5385
  elm,
5285
5386
  key,
5286
- hook: ElementHook,
5287
5387
  owner: vmBeingRendered
5288
5388
  };
5289
5389
  } // [t]ab[i]ndex function
@@ -5370,7 +5470,7 @@
5370
5470
  const {
5371
5471
  key
5372
5472
  } = data;
5373
- let elm;
5473
+ let elm, aChildren, vm;
5374
5474
  const vnode = {
5375
5475
  type: 3
5376
5476
  /* CustomElement */
@@ -5380,11 +5480,11 @@
5380
5480
  children,
5381
5481
  elm,
5382
5482
  key,
5383
- hook: CustomElementHook,
5384
5483
  ctor: Ctor,
5385
5484
  owner: vmBeingRendered,
5386
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5387
-
5485
+ mode: 'open',
5486
+ aChildren,
5487
+ vm
5388
5488
  };
5389
5489
  addVNodeToChildLWC(vnode);
5390
5490
  return vnode;
@@ -5514,7 +5614,6 @@
5514
5614
  text,
5515
5615
  elm,
5516
5616
  key,
5517
- hook: TextHook,
5518
5617
  owner: getVMBeingRendered()
5519
5618
  };
5520
5619
  } // [co]mment node
@@ -5530,7 +5629,6 @@
5530
5629
  text,
5531
5630
  elm,
5532
5631
  key,
5533
- hook: CommentHook,
5534
5632
  owner: getVMBeingRendered()
5535
5633
  };
5536
5634
  } // [d]ynamic text
@@ -6397,6 +6495,10 @@
6397
6495
  function registerComponent(Ctor, {
6398
6496
  tmpl
6399
6497
  }) {
6498
+ if (process.env.NODE_ENV !== 'production') {
6499
+ checkVersionMismatch(Ctor, 'component');
6500
+ }
6501
+
6400
6502
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6401
6503
  // without too much transformation
6402
6504
 
@@ -6521,7 +6623,7 @@
6521
6623
  */
6522
6624
 
6523
6625
 
6524
- function hydrate$1(vnode, node) {
6626
+ function hydrate(vnode, node) {
6525
6627
  switch (vnode.type) {
6526
6628
  case 0
6527
6629
  /* Text */
@@ -6553,16 +6655,18 @@
6553
6655
  var _a;
6554
6656
 
6555
6657
  if (process.env.NODE_ENV !== 'production') {
6556
- // eslint-disable-next-line lwc-internal/no-global-node
6557
- validateNodeType(vnode, node, Node.TEXT_NODE);
6658
+ validateNodeType(vnode, node, 3
6659
+ /* TEXT */
6660
+ );
6661
+ const nodeValue = getProperty$1(node, 'nodeValue');
6558
6662
 
6559
- if (node.nodeValue !== vnode.text && !(node.nodeValue === '\u200D' && vnode.text === '')) {
6663
+ if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
6560
6664
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6561
6665
  }
6562
6666
  } // always set the text value to the one from the vnode.
6563
6667
 
6564
6668
 
6565
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6669
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6566
6670
  vnode.elm = node;
6567
6671
  }
6568
6672
 
@@ -6570,23 +6674,25 @@
6570
6674
  var _a;
6571
6675
 
6572
6676
  if (process.env.NODE_ENV !== 'production') {
6573
- // eslint-disable-next-line lwc-internal/no-global-node
6574
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6677
+ validateNodeType(vnode, node, 8
6678
+ /* COMMENT */
6679
+ );
6575
6680
 
6576
- if (node.nodeValue !== vnode.text) {
6681
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6577
6682
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6578
6683
  }
6579
6684
  } // always set the text value to the one from the vnode.
6580
6685
 
6581
6686
 
6582
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6687
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6583
6688
  vnode.elm = node;
6584
6689
  }
6585
6690
 
6586
6691
  function hydrateElement(vnode, node) {
6587
6692
  if (process.env.NODE_ENV !== 'production') {
6588
- // eslint-disable-next-line lwc-internal/no-global-node
6589
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6693
+ validateNodeType(vnode, node, 1
6694
+ /* ELEMENT */
6695
+ );
6590
6696
  validateElement(vnode, node);
6591
6697
  }
6592
6698
 
@@ -6607,13 +6713,13 @@
6607
6713
  } = vnode.data;
6608
6714
 
6609
6715
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6610
- if (elm.innerHTML === props.innerHTML) {
6716
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6611
6717
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6612
6718
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
6613
6719
  props: cloneAndOmitKey(props, 'innerHTML')
6614
6720
  });
6615
6721
  } else {
6616
- logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
6722
+ logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
6617
6723
  }
6618
6724
  }
6619
6725
  }
@@ -6621,19 +6727,19 @@
6621
6727
  patchElementPropsAndAttrs(vnode);
6622
6728
 
6623
6729
  if (!isDomManual) {
6624
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6730
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6625
6731
  }
6626
6732
  }
6627
6733
 
6628
6734
  function hydrateCustomElement(vnode, node) {
6629
6735
  if (process.env.NODE_ENV !== 'production') {
6630
- // eslint-disable-next-line lwc-internal/no-global-node
6631
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6736
+ validateNodeType(vnode, node, 1
6737
+ /* ELEMENT */
6738
+ );
6632
6739
  validateElement(vnode, node);
6633
6740
  }
6634
6741
 
6635
6742
  const elm = node;
6636
- vnode.elm = elm;
6637
6743
  const {
6638
6744
  sel,
6639
6745
  mode,
@@ -6645,6 +6751,8 @@
6645
6751
  owner,
6646
6752
  tagName: sel
6647
6753
  });
6754
+ vnode.elm = elm;
6755
+ vnode.vm = vm;
6648
6756
  allocateChildren(vnode, vm);
6649
6757
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6650
6758
 
@@ -6661,7 +6769,7 @@
6661
6769
  ) {
6662
6770
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6663
6771
  // Note: for Light DOM, this is handled while hydrating the VM
6664
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6772
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6665
6773
  }
6666
6774
 
6667
6775
  hydrateVM(vm);
@@ -6684,7 +6792,7 @@
6684
6792
 
6685
6793
  if (!isNull(childVnode)) {
6686
6794
  const childNode = elmChildren[childNodeIndex];
6687
- hydrate$1(childVnode, childNode);
6795
+ hydrate(childVnode, childNode);
6688
6796
  childNodeIndex++;
6689
6797
  }
6690
6798
  }
@@ -6700,15 +6808,15 @@
6700
6808
  }
6701
6809
 
6702
6810
  function validateNodeType(vnode, node, nodeType) {
6703
- if (node.nodeType !== nodeType) {
6811
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6704
6812
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6705
6813
  assert.fail('Hydration mismatch: incorrect node type received.');
6706
6814
  }
6707
6815
  }
6708
6816
 
6709
6817
  function validateElement(vnode, elm) {
6710
- if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
6711
- logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm.tagName.toLowerCase()}".`, vnode.owner);
6818
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6819
+ logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty$1(elm, 'tagName').toLowerCase()}".`, vnode.owner);
6712
6820
  throwHydrationError();
6713
6821
  }
6714
6822
 
@@ -6735,7 +6843,7 @@
6735
6843
  const elmAttrValue = getAttribute$1(elm, attrName);
6736
6844
 
6737
6845
  if (String(attrValue) !== elmAttrValue) {
6738
- logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6846
+ logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
6739
6847
  nodesAreCompatible = false;
6740
6848
  }
6741
6849
  }
@@ -6753,7 +6861,7 @@
6753
6861
  let nodesAreCompatible = true;
6754
6862
  let vnodeClassName;
6755
6863
 
6756
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6864
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6757
6865
  // className is used when class is bound to an expr.
6758
6866
  nodesAreCompatible = false;
6759
6867
  vnodeClassName = className;
@@ -6778,7 +6886,7 @@
6778
6886
  }
6779
6887
 
6780
6888
  if (!nodesAreCompatible) {
6781
- logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
6889
+ logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty$1(elm, 'className')}"`, vnode.owner);
6782
6890
  }
6783
6891
 
6784
6892
  return nodesAreCompatible;
@@ -6825,7 +6933,7 @@
6825
6933
 
6826
6934
  if (!nodesAreCompatible) {
6827
6935
  // style is used when class is bound to an expr.
6828
- logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6936
+ logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
6829
6937
  }
6830
6938
 
6831
6939
  return nodesAreCompatible;
@@ -6895,7 +7003,19 @@
6895
7003
  }
6896
7004
 
6897
7005
  function hydrateVM(vm) {
6898
- hydrate(vm);
7006
+ if (isTrue(vm.isDirty)) {
7007
+ // manually diffing/patching here.
7008
+ // This routine is:
7009
+ // patchShadowRoot(vm, children);
7010
+ // -> addVnodes.
7011
+ const children = renderComponent(vm);
7012
+ vm.children = children;
7013
+ const vmChildren = vm.renderMode === 0
7014
+ /* Light */
7015
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
7016
+ hydrateChildren(vmChildren, children, vm);
7017
+ runRenderedCallback(vm);
7018
+ }
6899
7019
  } // just in case the component comes back, with this we guarantee re-rendering it
6900
7020
  // while preventing any attempt to rehydration until after reinsertion.
6901
7021
 
@@ -7046,7 +7166,11 @@
7046
7166
  /* Native */
7047
7167
  ;
7048
7168
  } else if (isNativeShadowDefined$1) {
7049
- if (def.shadowSupportMode === "any"
7169
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
7170
+ shadowMode = 1
7171
+ /* Synthetic */
7172
+ ;
7173
+ } else if (def.shadowSupportMode === "any"
7050
7174
  /* Any */
7051
7175
  ) {
7052
7176
  shadowMode = 0
@@ -7126,22 +7250,6 @@
7126
7250
  }
7127
7251
  }
7128
7252
 
7129
- function hydrate(vm) {
7130
- if (isTrue(vm.isDirty)) {
7131
- // manually diffing/patching here.
7132
- // This routine is:
7133
- // patchShadowRoot(vm, children);
7134
- // -> addVnodes.
7135
- const children = renderComponent(vm);
7136
- vm.children = children;
7137
- const vmChildren = vm.renderMode === 0
7138
- /* Light */
7139
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
7140
- hydrateChildren(vmChildren, children, vm);
7141
- runRenderedCallback(vm);
7142
- }
7143
- }
7144
-
7145
7253
  function patchShadowRoot(vm, newCh) {
7146
7254
  const {
7147
7255
  renderRoot,
@@ -7161,7 +7269,7 @@
7161
7269
  , vm);
7162
7270
  }, () => {
7163
7271
  // job
7164
- patchChildren(renderRoot, oldCh, newCh);
7272
+ patchChildren(oldCh, newCh, renderRoot);
7165
7273
  }, () => {
7166
7274
  // post
7167
7275
  logOperationEnd(2
@@ -7908,7 +8016,7 @@
7908
8016
  hooksAreSet = true;
7909
8017
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7910
8018
  }
7911
- /* version: 2.9.0 */
8019
+ /* version: 2.10.0 */
7912
8020
 
7913
8021
  /*
7914
8022
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7934,6 +8042,7 @@
7934
8042
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7935
8043
 
7936
8044
  const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
8045
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7937
8046
  const styleElements = create(null);
7938
8047
  const styleSheets = create(null);
7939
8048
  const nodesToStyleSheets = new WeakMap();
@@ -7977,7 +8086,13 @@
7977
8086
  }
7978
8087
 
7979
8088
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
7980
- target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
8089
+ if (supportsMutableAdoptedStyleSheets) {
8090
+ // This is only supported in later versions of Chromium:
8091
+ // https://chromestatus.com/feature/5638996492288000
8092
+ target.adoptedStyleSheets.push(styleSheet);
8093
+ } else {
8094
+ target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
8095
+ }
7981
8096
  }
7982
8097
  }
7983
8098
 
@@ -8279,6 +8394,156 @@
8279
8394
  setSetText(setText);
8280
8395
  setSsr(ssr);
8281
8396
  setAddEventListener(addEventListener);
8397
+ /*
8398
+ * Copyright (c) 2018, salesforce.com, inc.
8399
+ * All rights reserved.
8400
+ * SPDX-License-Identifier: MIT
8401
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8402
+ */
8403
+
8404
+ function resetShadowRootAndLightDom(element, Ctor) {
8405
+ if (element.shadowRoot) {
8406
+ const shadowRoot = element.shadowRoot;
8407
+
8408
+ while (!isNull(shadowRoot.firstChild)) {
8409
+ shadowRoot.removeChild(shadowRoot.firstChild);
8410
+ }
8411
+ }
8412
+
8413
+ if (Ctor.renderMode === 'light') {
8414
+ while (!isNull(element.firstChild)) {
8415
+ element.removeChild(element.firstChild);
8416
+ }
8417
+ }
8418
+ }
8419
+
8420
+ function createVMWithProps(element, Ctor, props) {
8421
+ createVM(element, Ctor, {
8422
+ mode: 'open',
8423
+ owner: null,
8424
+ tagName: element.tagName.toLowerCase()
8425
+ });
8426
+
8427
+ for (const [key, value] of Object.entries(props)) {
8428
+ element[key] = value;
8429
+ }
8430
+ }
8431
+
8432
+ function hydrateComponent(element, Ctor, props = {}) {
8433
+ if (!(element instanceof Element)) {
8434
+ throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
8435
+ }
8436
+
8437
+ if (!isFunction$1(Ctor)) {
8438
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
8439
+ }
8440
+
8441
+ if (!isObject(props) || isNull(props)) {
8442
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
8443
+ }
8444
+
8445
+ if (getAssociatedVMIfPresent(element)) {
8446
+ /* eslint-disable-next-line no-console */
8447
+ console.warn(`"hydrateComponent" expects an element that is not hydrated.`, element);
8448
+ return;
8449
+ }
8450
+
8451
+ try {
8452
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8453
+ // and uses the same algo to create the stylesheets as in SSR.
8454
+ setIsHydrating(true);
8455
+ createVMWithProps(element, Ctor, props);
8456
+ hydrateRootElement(element); // set it back since now we finished hydration.
8457
+
8458
+ setIsHydrating(false);
8459
+ } catch (e) {
8460
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8461
+ // with the client generated DOM.
8462
+
8463
+ /* eslint-disable-next-line no-console */
8464
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8465
+
8466
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8467
+
8468
+ createVMWithProps(element, Ctor, props);
8469
+ setIsHydrating(false);
8470
+ connectRootElement(element);
8471
+ } finally {
8472
+ // in case there's an error during recovery
8473
+ setIsHydrating(false);
8474
+ }
8475
+ }
8476
+ /*
8477
+ * Copyright (c) 2018, salesforce.com, inc.
8478
+ * All rights reserved.
8479
+ * SPDX-License-Identifier: MIT
8480
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8481
+ */
8482
+
8483
+ /**
8484
+ * This function builds a Web Component class from a LWC constructor so it can be
8485
+ * registered as a new element via customElements.define() at any given time.
8486
+ *
8487
+ * @deprecated since version 1.3.11
8488
+ *
8489
+ * @example
8490
+ * ```
8491
+ * import { buildCustomElementConstructor } from 'lwc';
8492
+ * import Foo from 'ns/foo';
8493
+ * const WC = buildCustomElementConstructor(Foo);
8494
+ * customElements.define('x-foo', WC);
8495
+ * const elm = document.createElement('x-foo');
8496
+ * ```
8497
+ */
8498
+
8499
+
8500
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8501
+ if (process.env.NODE_ENV !== 'production') {
8502
+ /* eslint-disable-next-line no-console */
8503
+ console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
8504
+ }
8505
+
8506
+ return Ctor.CustomElementConstructor;
8507
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8508
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8509
+
8510
+
8511
+ const hydratedCustomElements = new WeakSet();
8512
+
8513
+ function buildCustomElementConstructor(Ctor) {
8514
+ const HtmlPrototype = getComponentHtmlPrototype(Ctor);
8515
+ return class extends HtmlPrototype {
8516
+ constructor() {
8517
+ super();
8518
+
8519
+ if (this.isConnected) {
8520
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8521
+ hydrateComponent(this, Ctor, {});
8522
+ hydratedCustomElements.add(this);
8523
+ } else {
8524
+ createVM(this, Ctor, {
8525
+ mode: 'open',
8526
+ owner: null,
8527
+ tagName: this.tagName
8528
+ });
8529
+ }
8530
+ }
8531
+
8532
+ connectedCallback() {
8533
+ if (hydratedCustomElements.has(this)) {
8534
+ // This is an un-upgraded element that was hydrated in the constructor.
8535
+ hydratedCustomElements.delete(this);
8536
+ } else {
8537
+ connectRootElement(this);
8538
+ }
8539
+ }
8540
+
8541
+ disconnectedCallback() {
8542
+ disconnectRootElement(this);
8543
+ }
8544
+
8545
+ };
8546
+ }
8282
8547
  /*
8283
8548
  * Copyright (c) 2018, salesforce.com, inc.
8284
8549
  * All rights reserved.
@@ -8288,6 +8553,7 @@
8288
8553
  // TODO [#2472]: Remove this workaround when appropriate.
8289
8554
  // eslint-disable-next-line lwc-internal/no-global-node
8290
8555
 
8556
+
8291
8557
  const _Node$1 = Node;
8292
8558
  const ConnectingSlot = new WeakMap();
8293
8559
  const DisconnectingSlot = new WeakMap();
@@ -8396,118 +8662,6 @@
8396
8662
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8397
8663
  */
8398
8664
 
8399
-
8400
- function hydrateComponent(element, Ctor, props = {}) {
8401
- if (!(element instanceof Element)) {
8402
- throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
8403
- }
8404
-
8405
- if (!isFunction$1(Ctor)) {
8406
- throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
8407
- }
8408
-
8409
- if (!isObject(props) || isNull(props)) {
8410
- throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
8411
- }
8412
-
8413
- try {
8414
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8415
- // and uses the same algo to create the stylesheets as in SSR.
8416
- setIsHydrating(true);
8417
- createVM(element, Ctor, {
8418
- mode: 'open',
8419
- owner: null,
8420
- tagName: element.tagName.toLowerCase()
8421
- });
8422
-
8423
- for (const [key, value] of Object.entries(props)) {
8424
- element[key] = value;
8425
- }
8426
-
8427
- hydrateRootElement(element); // set it back since now we finished hydration.
8428
-
8429
- setIsHydrating(false);
8430
- } catch (e) {
8431
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8432
- // the client generated DOM.
8433
-
8434
- /* eslint-disable-next-line no-console */
8435
- console.error('Recovering from error while hydrating: ', e);
8436
- setIsHydrating(false);
8437
- const newElem = createElement(element.tagName, {
8438
- is: Ctor,
8439
- mode: 'open'
8440
- });
8441
-
8442
- for (const [key, value] of Object.entries(props)) {
8443
- newElem[key] = value;
8444
- }
8445
-
8446
- element.parentNode.replaceChild(newElem, element);
8447
- }
8448
- }
8449
- /*
8450
- * Copyright (c) 2018, salesforce.com, inc.
8451
- * All rights reserved.
8452
- * SPDX-License-Identifier: MIT
8453
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8454
- */
8455
-
8456
- /**
8457
- * This function builds a Web Component class from a LWC constructor so it can be
8458
- * registered as a new element via customElements.define() at any given time.
8459
- *
8460
- * @deprecated since version 1.3.11
8461
- *
8462
- * @example
8463
- * ```
8464
- * import { buildCustomElementConstructor } from 'lwc';
8465
- * import Foo from 'ns/foo';
8466
- * const WC = buildCustomElementConstructor(Foo);
8467
- * customElements.define('x-foo', WC);
8468
- * const elm = document.createElement('x-foo');
8469
- * ```
8470
- */
8471
-
8472
-
8473
- function deprecatedBuildCustomElementConstructor(Ctor) {
8474
- if (process.env.NODE_ENV !== 'production') {
8475
- /* eslint-disable-next-line no-console */
8476
- console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
8477
- }
8478
-
8479
- return Ctor.CustomElementConstructor;
8480
- }
8481
-
8482
- function buildCustomElementConstructor(Ctor) {
8483
- const HtmlPrototype = getComponentHtmlPrototype(Ctor);
8484
- return class extends HtmlPrototype {
8485
- constructor() {
8486
- super();
8487
- createVM(this, Ctor, {
8488
- mode: 'open',
8489
- owner: null,
8490
- tagName: this.tagName
8491
- });
8492
- }
8493
-
8494
- connectedCallback() {
8495
- connectRootElement(this);
8496
- }
8497
-
8498
- disconnectedCallback() {
8499
- disconnectRootElement(this);
8500
- }
8501
-
8502
- };
8503
- }
8504
- /*
8505
- * Copyright (c) 2018, salesforce.com, inc.
8506
- * All rights reserved.
8507
- * SPDX-License-Identifier: MIT
8508
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8509
- */
8510
-
8511
8665
  /**
8512
8666
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8513
8667
  * This API is subject to change or being removed.
@@ -8608,7 +8762,7 @@
8608
8762
  });
8609
8763
  freeze(LightningElement);
8610
8764
  seal(LightningElement.prototype);
8611
- /* version: 2.9.0 */
8765
+ /* version: 2.10.0 */
8612
8766
 
8613
8767
  exports.LightningElement = LightningElement;
8614
8768
  exports.__unstable__ProfilerControl = profilerControl;