lwc 2.7.4 → 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 (36) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +663 -470
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +663 -470
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +544 -426
  5. package/dist/engine-dom/iife/es5/engine-dom.js +816 -594
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +624 -497
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +663 -470
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +544 -426
  11. package/dist/engine-dom/umd/es5/engine-dom.js +816 -594
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +624 -497
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +427 -299
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +427 -299
  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 +8 -8
  36. package/LICENSE +0 -10
@@ -259,7 +259,7 @@ const KEY__SCOPED_CSS = '$scoped$';
259
259
  // The following list contains a mix of both void elements from the HTML and the XML namespace
260
260
  // without distinction.
261
261
 
262
- const VOID_ELEMENTS = ['area', 'base', 'br', 'circle', 'col', 'ellipse', 'feBlend', 'feColorMatrix', 'feFuncR', 'feFuncG', 'feFuncB', 'feFuncA', 'feImage', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDropShadow', 'feFlood', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'feSpecularLighting', 'feTile', 'feTurbulence', 'fePointLight', 'embed', 'hr', 'img', 'input', 'keygen', 'line', 'link', 'menuitem', 'meta', 'param', 'rect', 'source', 'track', 'wbr'];
262
+ const VOID_ELEMENTS = ['area', 'base', 'br', 'circle', 'col', 'ellipse', 'feBlend', 'feColorMatrix', 'feFuncR', 'feFuncG', 'feFuncB', 'feFuncA', 'feImage', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDropShadow', 'feFlood', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'feSpecularLighting', 'feTile', 'feTurbulence', 'fePointLight', 'embed', 'hr', 'img', 'input', 'keygen', 'line', 'link', 'menuitem', 'meta', 'param', 'path', 'rect', 'source', 'track', 'wbr'];
263
263
  const VOID_ELEMENTS_SET = new Set(VOID_ELEMENTS);
264
264
 
265
265
  function isVoidElement(name) {
@@ -343,7 +343,17 @@ function htmlPropertyToAttribute(propName) {
343
343
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
344
344
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
345
345
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
346
- /** version: 2.7.4 */
346
+ /*
347
+ * Copyright (c) 2018, salesforce.com, inc.
348
+ * All rights reserved.
349
+ * SPDX-License-Identifier: MIT
350
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
351
+ */
352
+ // Increment whenever the LWC template compiler changes
353
+
354
+ const LWC_VERSION = "2.10.0";
355
+ const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
356
+ /** version: 2.10.0 */
347
357
 
348
358
  /*
349
359
  * Copyright (c) 2020, salesforce.com, inc.
@@ -392,14 +402,15 @@ if (typeof CustomEvent !== 'function') {
392
402
 
393
403
 
394
404
  const features = {
395
- ENABLE_REACTIVE_SETTER: null,
396
- ENABLE_HMR: null,
397
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
405
+ DISABLE_MIXED_SHADOW_MODE: null,
398
406
  ENABLE_ELEMENT_PATCH: null,
399
407
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
400
- ENABLE_NODE_LIST_PATCH: null,
408
+ ENABLE_HMR: null,
401
409
  ENABLE_HTML_COLLECTIONS_PATCH: null,
410
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
411
+ ENABLE_NODE_LIST_PATCH: null,
402
412
  ENABLE_NODE_PATCH: null,
413
+ ENABLE_REACTIVE_SETTER: null,
403
414
  ENABLE_WIRE_SYNC_EMIT: null
404
415
  };
405
416
 
@@ -464,7 +475,7 @@ function setFeatureFlagForTest(name, value) {
464
475
  setFeatureFlag(name, value);
465
476
  }
466
477
  }
467
- /** version: 2.7.4 */
478
+ /** version: 2.10.0 */
468
479
 
469
480
  /* proxy-compat-disable */
470
481
 
@@ -517,7 +528,21 @@ function guid() {
517
528
 
518
529
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
519
530
  } // Borrowed from Vue template compiler.
520
- //
531
+
532
+
533
+ function flattenStylesheets(stylesheets) {
534
+ const list = [];
535
+
536
+ for (const stylesheet of stylesheets) {
537
+ if (!Array.isArray(stylesheet)) {
538
+ list.push(stylesheet);
539
+ } else {
540
+ list.push(...flattenStylesheets(stylesheet));
541
+ }
542
+ }
543
+
544
+ return list;
545
+ } //
521
546
  // Primitives
522
547
  //
523
548
 
@@ -3318,6 +3343,47 @@ function getDecoratorsMeta(Ctor) {
3318
3343
  const meta = signedDecoratorToMetaMap.get(Ctor);
3319
3344
  return isUndefined$1(meta) ? defaultMeta : meta;
3320
3345
  }
3346
+ /*
3347
+ * Copyright (c) 2018, salesforce.com, inc.
3348
+ * All rights reserved.
3349
+ * SPDX-License-Identifier: MIT
3350
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3351
+ */
3352
+
3353
+
3354
+ let warned = false;
3355
+
3356
+ if (process.env.NODE_ENV === 'development') {
3357
+ // @ts-ignore
3358
+ window.__lwcResetWarnedOnVersionMismatch = () => {
3359
+ warned = false;
3360
+ };
3361
+ }
3362
+
3363
+ function checkVersionMismatch(func, type) {
3364
+ const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3365
+
3366
+ if (!isNull(versionMatcher) && !warned) {
3367
+ const version = versionMatcher[1];
3368
+ const [major, minor] = version.split('.');
3369
+ const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
3370
+
3371
+ if (major !== expectedMajor || minor !== expectedMinor) {
3372
+ warned = true; // only warn once to avoid flooding the console
3373
+ // stylesheets and templates do not have user-meaningful names, but components do
3374
+
3375
+ const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
3376
+ 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.`);
3377
+ }
3378
+ }
3379
+ }
3380
+ /*
3381
+ * Copyright (c) 2018, salesforce.com, inc.
3382
+ * All rights reserved.
3383
+ * SPDX-License-Identifier: MIT
3384
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3385
+ */
3386
+
3321
3387
 
3322
3388
  const signedTemplateSet = new Set();
3323
3389
 
@@ -3330,6 +3396,16 @@ signedTemplateSet.add(defaultEmptyTemplate);
3330
3396
  function isTemplateRegistered(tpl) {
3331
3397
  return signedTemplateSet.has(tpl);
3332
3398
  }
3399
+
3400
+ function checkTemplateVersionMismatch(template) {
3401
+ checkVersionMismatch(template, 'template');
3402
+
3403
+ if (!isUndefined$1(template.stylesheets)) {
3404
+ for (const stylesheet of flattenStylesheets(template.stylesheets)) {
3405
+ checkVersionMismatch(stylesheet, 'stylesheet');
3406
+ }
3407
+ }
3408
+ }
3333
3409
  /**
3334
3410
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3335
3411
  * will prevent this function from being imported by userland code.
@@ -3337,6 +3413,10 @@ function isTemplateRegistered(tpl) {
3337
3413
 
3338
3414
 
3339
3415
  function registerTemplate(tpl) {
3416
+ if (process.env.NODE_ENV !== 'production') {
3417
+ checkTemplateVersionMismatch(tpl);
3418
+ }
3419
+
3340
3420
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3341
3421
  // assignment of templates easily, without too much transformation
3342
3422
 
@@ -3561,20 +3641,6 @@ const activeTemplates = new WeakMap();
3561
3641
  const activeComponents = new WeakMap();
3562
3642
  const activeStyles = new WeakMap();
3563
3643
 
3564
- function flattenStylesheets(stylesheets) {
3565
- const list = [];
3566
-
3567
- for (const stylesheet of stylesheets) {
3568
- if (!Array.isArray(stylesheet)) {
3569
- list.push(stylesheet);
3570
- } else {
3571
- list.push(...flattenStylesheets(stylesheet));
3572
- }
3573
- }
3574
-
3575
- return list;
3576
- }
3577
-
3578
3644
  function getTemplateOrSwappedTemplate(tpl) {
3579
3645
  if (process.env.NODE_ENV === 'production') {
3580
3646
  // this method should never leak to prod
@@ -4351,156 +4417,268 @@ function applyStaticStyleAttribute(vnode) {
4351
4417
  */
4352
4418
 
4353
4419
 
4354
- const TextHook = {
4355
- create: vnode => {
4356
- const {
4357
- owner
4358
- } = vnode;
4359
- const elm = createText$1(vnode.text);
4360
- linkNodeToShadow(elm, owner);
4361
- vnode.elm = elm;
4362
- },
4363
- update: updateNodeHook,
4364
- insert: insertNode,
4365
- move: insertNode,
4366
- remove: removeNode
4367
- };
4368
- const CommentHook = {
4369
- create: vnode => {
4370
- const {
4371
- owner,
4372
- text
4373
- } = vnode;
4374
- const elm = createComment$1(text);
4375
- linkNodeToShadow(elm, owner);
4376
- vnode.elm = elm;
4377
- },
4378
- update: updateNodeHook,
4379
- insert: insertNode,
4380
- move: insertNode,
4381
- remove: removeNode
4382
- }; // insert is called after update, which is used somewhere else (via a module)
4383
- // to mark the vm as inserted, that means we cannot use update as the main channel
4384
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4385
- // which breaks some invariants. For that reason, we have the following for any
4386
- // Custom Element that is inserted via a template.
4387
-
4388
- const ElementHook = {
4389
- create: vnode => {
4390
- const {
4391
- sel,
4392
- owner,
4393
- data: {
4394
- svg
4395
- }
4396
- } = vnode;
4397
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4398
- const elm = createElement$1(sel, namespace);
4399
- linkNodeToShadow(elm, owner);
4400
- fallbackElmHook(elm, vnode);
4401
- vnode.elm = elm;
4402
- patchElementPropsAndAttrs$1(null, vnode);
4403
- },
4404
- update: (oldVnode, vnode) => {
4405
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4406
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4407
- },
4408
- insert: (vnode, parentNode, referenceNode) => {
4409
- insertNode(vnode, parentNode, referenceNode);
4410
- createChildrenHook(vnode);
4411
- },
4412
- move: insertNode,
4413
- remove: (vnode, parentNode) => {
4414
- removeNode(vnode, parentNode);
4415
- removeChildren(vnode);
4420
+ function patchChildren(c1, c2, parent) {
4421
+ if (hasDynamicChildren(c2)) {
4422
+ updateDynamicChildren(c1, c2, parent);
4423
+ } else {
4424
+ updateStaticChildren(c1, c2, parent);
4425
+ }
4426
+ }
4427
+
4428
+ function patch(n1, n2) {
4429
+ if (n1 === n2) {
4430
+ return;
4416
4431
  }
4417
- };
4418
- const CustomElementHook = {
4419
- create: vnode => {
4420
- const {
4421
- sel,
4422
- owner
4423
- } = vnode;
4424
- const UpgradableConstructor = getUpgradableConstructor(sel);
4425
- /**
4426
- * Note: if the upgradable constructor does not expect, or throw when we new it
4427
- * with a callback as the first argument, we could implement a more advanced
4428
- * mechanism that only passes that argument if the constructor is known to be
4429
- * an upgradable custom element.
4430
- */
4431
-
4432
- let vm;
4433
- const elm = new UpgradableConstructor(elm => {
4434
- // the custom element from the registry is expecting an upgrade callback
4435
- vm = createViewModelHook(elm, vnode);
4436
- });
4437
- linkNodeToShadow(elm, owner);
4438
- vnode.elm = elm;
4439
4432
 
4440
- if (vm) {
4441
- allocateChildren(vnode, vm);
4442
- } else if (vnode.ctor !== UpgradableConstructor) {
4443
- throw new TypeError(`Incorrect Component Constructor`);
4433
+ if (process.env.NODE_ENV !== 'production') {
4434
+ if (!isSameVnode(n1, n2)) {
4435
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4436
+ sel: n1.sel,
4437
+ key: n1.key
4438
+ }) + ', ' + JSON.stringify({
4439
+ sel: n2.sel,
4440
+ key: n2.key
4441
+ }));
4444
4442
  }
4443
+ }
4445
4444
 
4446
- patchElementPropsAndAttrs$1(null, vnode);
4447
- },
4448
- update: (oldVnode, vnode) => {
4449
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4450
- const vm = getAssociatedVMIfPresent(vnode.elm);
4445
+ switch (n2.type) {
4446
+ case 0
4447
+ /* Text */
4448
+ :
4449
+ patchText(n1, n2);
4450
+ break;
4451
4451
 
4452
- if (vm) {
4453
- // in fallback mode, the allocation will always set children to
4454
- // empty and delegate the real allocation to the slot elements
4455
- allocateChildren(vnode, vm);
4456
- } // in fallback mode, the children will be always empty, so, nothing
4457
- // will happen, but in native, it does allocate the light dom
4452
+ case 1
4453
+ /* Comment */
4454
+ :
4455
+ patchComment(n1, n2);
4456
+ break;
4458
4457
 
4458
+ case 2
4459
+ /* Element */
4460
+ :
4461
+ patchElement(n1, n2);
4462
+ break;
4459
4463
 
4460
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4464
+ case 3
4465
+ /* CustomElement */
4466
+ :
4467
+ patchCustomElement(n1, n2);
4468
+ break;
4469
+ }
4470
+ }
4461
4471
 
4462
- if (vm) {
4463
- if (process.env.NODE_ENV !== 'production') {
4464
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4465
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4466
- // this is important to preserve the top to bottom synchronous rendering phase.
4472
+ function mount(node, parent, anchor) {
4473
+ switch (node.type) {
4474
+ case 0
4475
+ /* Text */
4476
+ :
4477
+ mountText(node, parent, anchor);
4478
+ break;
4479
+
4480
+ case 1
4481
+ /* Comment */
4482
+ :
4483
+ mountComment(node, parent, anchor);
4484
+ break;
4467
4485
 
4486
+ case 2
4487
+ /* Element */
4488
+ :
4489
+ mountElement(node, parent, anchor);
4490
+ break;
4468
4491
 
4469
- rerenderVM(vm);
4492
+ case 3
4493
+ /* CustomElement */
4494
+ :
4495
+ mountCustomElement(node, parent, anchor);
4496
+ break;
4497
+ }
4498
+ }
4499
+
4500
+ function patchText(n1, n2) {
4501
+ n2.elm = n1.elm;
4502
+
4503
+ if (n2.text !== n1.text) {
4504
+ updateTextContent(n2);
4505
+ }
4506
+ }
4507
+
4508
+ function mountText(node, parent, anchor) {
4509
+ const {
4510
+ owner
4511
+ } = node;
4512
+ const textNode = node.elm = createText$1(node.text);
4513
+ linkNodeToShadow(textNode, owner);
4514
+ insertNode(textNode, parent, anchor);
4515
+ }
4516
+
4517
+ function patchComment(n1, n2) {
4518
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4519
+ // it is the case today.
4520
+
4521
+ if (n2.text !== n1.text) {
4522
+ updateTextContent(n2);
4523
+ }
4524
+ }
4525
+
4526
+ function mountComment(node, parent, anchor) {
4527
+ const {
4528
+ owner
4529
+ } = node;
4530
+ const commentNode = node.elm = createComment$1(node.text);
4531
+ linkNodeToShadow(commentNode, owner);
4532
+ insertNode(commentNode, parent, anchor);
4533
+ }
4534
+
4535
+ function mountElement(vnode, parent, anchor) {
4536
+ const {
4537
+ sel,
4538
+ owner,
4539
+ data: {
4540
+ svg
4470
4541
  }
4471
- },
4472
- insert: (vnode, parentNode, referenceNode) => {
4473
- insertNode(vnode, parentNode, referenceNode);
4474
- const vm = getAssociatedVMIfPresent(vnode.elm);
4542
+ } = vnode;
4543
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4544
+ const elm = createElement$1(sel, namespace);
4545
+ linkNodeToShadow(elm, owner);
4546
+ fallbackElmHook(elm, vnode);
4547
+ vnode.elm = elm;
4548
+ patchElementPropsAndAttrs$1(null, vnode);
4549
+ insertNode(elm, parent, anchor);
4550
+ mountVNodes(vnode.children, elm, null);
4551
+ }
4475
4552
 
4476
- if (vm) {
4477
- if (process.env.NODE_ENV !== 'production') {
4478
- assert.isTrue(vm.state === 0
4479
- /* created */
4480
- , `${vm} cannot be recycled.`);
4481
- }
4553
+ function patchElement(n1, n2) {
4554
+ const elm = n2.elm = n1.elm;
4555
+ patchElementPropsAndAttrs$1(n1, n2);
4556
+ patchChildren(n1.children, n2.children, elm);
4557
+ }
4482
4558
 
4483
- runConnectedCallback(vm);
4559
+ function mountCustomElement(vnode, parent, anchor) {
4560
+ const {
4561
+ sel,
4562
+ owner
4563
+ } = vnode;
4564
+ const UpgradableConstructor = getUpgradableConstructor(sel);
4565
+ /**
4566
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4567
+ * with a callback as the first argument, we could implement a more advanced
4568
+ * mechanism that only passes that argument if the constructor is known to be
4569
+ * an upgradable custom element.
4570
+ */
4571
+
4572
+ let vm;
4573
+ const elm = new UpgradableConstructor(elm => {
4574
+ // the custom element from the registry is expecting an upgrade callback
4575
+ vm = createViewModelHook(elm, vnode);
4576
+ });
4577
+ linkNodeToShadow(elm, owner);
4578
+ vnode.elm = elm;
4579
+ vnode.vm = vm;
4580
+
4581
+ if (vm) {
4582
+ allocateChildren(vnode, vm);
4583
+ } else if (vnode.ctor !== UpgradableConstructor) {
4584
+ throw new TypeError(`Incorrect Component Constructor`);
4585
+ }
4586
+
4587
+ patchElementPropsAndAttrs$1(null, vnode);
4588
+ insertNode(elm, parent, anchor);
4589
+
4590
+ if (vm) {
4591
+ if (process.env.NODE_ENV !== 'production') {
4592
+ assert.isTrue(vm.state === 0
4593
+ /* created */
4594
+ , `${vm} cannot be recycled.`);
4484
4595
  }
4485
4596
 
4486
- createChildrenHook(vnode);
4597
+ runConnectedCallback(vm);
4598
+ }
4599
+
4600
+ mountVNodes(vnode.children, elm, null);
4601
+
4602
+ if (vm) {
4603
+ appendVM(vm);
4604
+ }
4605
+ }
4606
+
4607
+ function patchCustomElement(n1, n2) {
4608
+ const elm = n2.elm = n1.elm;
4609
+ const vm = n2.vm = n1.vm;
4610
+ patchElementPropsAndAttrs$1(n1, n2);
4611
+
4612
+ if (!isUndefined$1(vm)) {
4613
+ // in fallback mode, the allocation will always set children to
4614
+ // empty and delegate the real allocation to the slot elements
4615
+ allocateChildren(n2, vm);
4616
+ } // in fallback mode, the children will be always empty, so, nothing
4617
+ // will happen, but in native, it does allocate the light dom
4618
+
4619
+
4620
+ patchChildren(n1.children, n2.children, elm);
4487
4621
 
4488
- if (vm) {
4489
- appendVM(vm);
4622
+ if (!isUndefined$1(vm)) {
4623
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4624
+ // this is important to preserve the top to bottom synchronous rendering phase.
4625
+ rerenderVM(vm);
4626
+ }
4627
+ }
4628
+
4629
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
4630
+ for (; start < end; ++start) {
4631
+ const vnode = vnodes[start];
4632
+
4633
+ if (isVNode(vnode)) {
4634
+ mount(vnode, parent, anchor);
4490
4635
  }
4491
- },
4492
- move: insertNode,
4493
- remove: (vnode, parentNode) => {
4494
- removeNode(vnode, parentNode);
4495
- const vm = getAssociatedVMIfPresent(vnode.elm);
4636
+ }
4637
+ }
4638
+
4639
+ function unmount(vnode, parent, doRemove = false) {
4640
+ const {
4641
+ type,
4642
+ elm
4643
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4644
+ // subtree root, is the only element worth unmounting from the subtree.
4645
+
4646
+ if (doRemove) {
4647
+ removeNode(elm, parent);
4648
+ }
4496
4649
 
4497
- if (vm) {
4498
- // for custom elements we don't have to go recursively because the removeVM routine
4499
- // will take care of disconnecting any child VM attached to its shadow as well.
4500
- removeVM(vm);
4650
+ switch (type) {
4651
+ case 2
4652
+ /* Element */
4653
+ :
4654
+ unmountVNodes(vnode.children, elm);
4655
+ break;
4656
+
4657
+ case 3
4658
+ /* CustomElement */
4659
+ :
4660
+ {
4661
+ const {
4662
+ vm
4663
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
4664
+ // children.
4665
+
4666
+ if (!isUndefined$1(vm)) {
4667
+ removeVM(vm);
4668
+ }
4669
+ }
4670
+ }
4671
+ }
4672
+
4673
+ function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
4674
+ for (; start < end; ++start) {
4675
+ const ch = vnodes[start];
4676
+
4677
+ if (isVNode(ch)) {
4678
+ unmount(ch, parent, doRemove);
4501
4679
  }
4502
4680
  }
4503
- };
4681
+ }
4504
4682
 
4505
4683
  function isVNode(vnode) {
4506
4684
  return vnode != null;
@@ -4545,43 +4723,41 @@ function linkNodeToShadow(elm, owner) {
4545
4723
  }
4546
4724
  }
4547
4725
 
4548
- function updateNodeHook(oldVnode, vnode) {
4726
+ function updateTextContent(vnode) {
4549
4727
  const {
4550
4728
  elm,
4551
4729
  text
4552
4730
  } = vnode;
4553
4731
 
4554
- if (oldVnode.text !== text) {
4555
- if (process.env.NODE_ENV !== 'production') {
4556
- unlockDomMutation();
4557
- }
4732
+ if (process.env.NODE_ENV !== 'production') {
4733
+ unlockDomMutation();
4734
+ }
4558
4735
 
4559
- setText$1(elm, text);
4736
+ setText$1(elm, text);
4560
4737
 
4561
- if (process.env.NODE_ENV !== 'production') {
4562
- lockDomMutation();
4563
- }
4738
+ if (process.env.NODE_ENV !== 'production') {
4739
+ lockDomMutation();
4564
4740
  }
4565
4741
  }
4566
4742
 
4567
- function insertNode(vnode, parentNode, referenceNode) {
4743
+ function insertNode(node, parent, anchor) {
4568
4744
  if (process.env.NODE_ENV !== 'production') {
4569
4745
  unlockDomMutation();
4570
4746
  }
4571
4747
 
4572
- insert$1(vnode.elm, parentNode, referenceNode);
4748
+ insert$1(node, parent, anchor);
4573
4749
 
4574
4750
  if (process.env.NODE_ENV !== 'production') {
4575
4751
  lockDomMutation();
4576
4752
  }
4577
4753
  }
4578
4754
 
4579
- function removeNode(vnode, parentNode) {
4755
+ function removeNode(node, parent) {
4580
4756
  if (process.env.NODE_ENV !== 'production') {
4581
4757
  unlockDomMutation();
4582
4758
  }
4583
4759
 
4584
- remove$1(vnode.elm, parentNode);
4760
+ remove$1(node, parent);
4585
4761
 
4586
4762
  if (process.env.NODE_ENV !== 'production') {
4587
4763
  lockDomMutation();
@@ -4626,11 +4802,13 @@ function fallbackElmHook(elm, vnode) {
4626
4802
  ) {
4627
4803
  // this element will now accept any manual content inserted into it
4628
4804
  observeElementChildNodes(elm);
4629
- } // when running in synthetic shadow mode, we need to set the shadowToken value
4630
- // into each element from the template, so they can be styled accordingly.
4631
-
4805
+ }
4632
4806
 
4633
- setElementShadowToken(elm, stylesheetToken);
4807
+ if (!isUndefined$1(stylesheetToken)) {
4808
+ // when running in synthetic shadow mode, we need to set the shadowToken value
4809
+ // into each element from the template, so they can be styled accordingly.
4810
+ setElementShadowToken(elm, stylesheetToken);
4811
+ }
4634
4812
  }
4635
4813
 
4636
4814
  if (process.env.NODE_ENV !== 'production') {
@@ -4652,14 +4830,6 @@ function fallbackElmHook(elm, vnode) {
4652
4830
  }
4653
4831
  }
4654
4832
 
4655
- function patchChildren(parent, oldCh, newCh) {
4656
- if (hasDynamicChildren(newCh)) {
4657
- updateDynamicChildren(parent, oldCh, newCh);
4658
- } else {
4659
- updateStaticChildren(parent, oldCh, newCh);
4660
- }
4661
- }
4662
-
4663
4833
  function allocateChildren(vnode, vm) {
4664
4834
  // A component with slots will re-render because:
4665
4835
  // 1- There is a change of the internal state.
@@ -4717,7 +4887,9 @@ function createViewModelHook(elm, vnode) {
4717
4887
  } = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
4718
4888
  // into each element from the template, so they can be styled accordingly.
4719
4889
 
4720
- setElementShadowToken(elm, stylesheetToken);
4890
+ if (!isUndefined$1(stylesheetToken)) {
4891
+ setElementShadowToken(elm, stylesheetToken);
4892
+ }
4721
4893
  }
4722
4894
 
4723
4895
  vm = createVM(elm, ctor, {
@@ -4733,40 +4905,6 @@ function createViewModelHook(elm, vnode) {
4733
4905
  return vm;
4734
4906
  }
4735
4907
 
4736
- function createChildrenHook(vnode) {
4737
- const {
4738
- elm,
4739
- children
4740
- } = vnode;
4741
-
4742
- for (let j = 0; j < children.length; ++j) {
4743
- const ch = children[j];
4744
-
4745
- if (ch != null) {
4746
- ch.hook.create(ch);
4747
- ch.hook.insert(ch, elm, null);
4748
- }
4749
- }
4750
- }
4751
-
4752
- function removeChildren(vnode) {
4753
- // this method only needs to search on child vnodes from template
4754
- // to trigger the remove hook just in case some of those children
4755
- // are custom elements.
4756
- const {
4757
- children,
4758
- elm
4759
- } = vnode;
4760
-
4761
- for (let j = 0, len = children.length; j < len; ++j) {
4762
- const ch = children[j];
4763
-
4764
- if (!isNull(ch)) {
4765
- ch.hook.remove(ch, elm);
4766
- }
4767
- }
4768
- }
4769
-
4770
4908
  function allocateInSlot(vm, children) {
4771
4909
  var _a;
4772
4910
 
@@ -4863,28 +5001,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
4863
5001
  return map;
4864
5002
  }
4865
5003
 
4866
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
4867
- for (; startIdx <= endIdx; ++startIdx) {
4868
- const ch = vnodes[startIdx];
4869
-
4870
- if (isVNode(ch)) {
4871
- ch.hook.create(ch);
4872
- ch.hook.insert(ch, parentElm, before);
4873
- }
4874
- }
4875
- }
4876
-
4877
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
4878
- for (; startIdx <= endIdx; ++startIdx) {
4879
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
4880
-
4881
- if (isVNode(ch)) {
4882
- ch.hook.remove(ch, parentElm);
4883
- }
4884
- }
4885
- }
4886
-
4887
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5004
+ function updateDynamicChildren(oldCh, newCh, parent) {
4888
5005
  let oldStartIdx = 0;
4889
5006
  let newStartIdx = 0;
4890
5007
  let oldEndIdx = oldCh.length - 1;
@@ -4898,6 +5015,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4898
5015
  let idxInOld;
4899
5016
  let elmToMove;
4900
5017
  let before;
5018
+ let clonedOldCh = false;
4901
5019
 
4902
5020
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4903
5021
  if (!isVNode(oldStartVnode)) {
@@ -4909,23 +5027,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4909
5027
  } else if (!isVNode(newEndVnode)) {
4910
5028
  newEndVnode = newCh[--newEndIdx];
4911
5029
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4912
- patchVnode(oldStartVnode, newStartVnode);
5030
+ patch(oldStartVnode, newStartVnode);
4913
5031
  oldStartVnode = oldCh[++oldStartIdx];
4914
5032
  newStartVnode = newCh[++newStartIdx];
4915
5033
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4916
- patchVnode(oldEndVnode, newEndVnode);
5034
+ patch(oldEndVnode, newEndVnode);
4917
5035
  oldEndVnode = oldCh[--oldEndIdx];
4918
5036
  newEndVnode = newCh[--newEndIdx];
4919
5037
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4920
5038
  // Vnode moved right
4921
- patchVnode(oldStartVnode, newEndVnode);
4922
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5039
+ patch(oldStartVnode, newEndVnode);
5040
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4923
5041
  oldStartVnode = oldCh[++oldStartIdx];
4924
5042
  newEndVnode = newCh[--newEndIdx];
4925
5043
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4926
5044
  // Vnode moved left
4927
- patchVnode(oldEndVnode, newStartVnode);
4928
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5045
+ patch(oldEndVnode, newStartVnode);
5046
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4929
5047
  oldEndVnode = oldCh[--oldEndIdx];
4930
5048
  newStartVnode = newCh[++newStartIdx];
4931
5049
  } else {
@@ -4937,8 +5055,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4937
5055
 
4938
5056
  if (isUndefined$1(idxInOld)) {
4939
5057
  // New element
4940
- newStartVnode.hook.create(newStartVnode);
4941
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5058
+ mount(newStartVnode, parent, oldStartVnode.elm);
4942
5059
  newStartVnode = newCh[++newStartIdx];
4943
5060
  } else {
4944
5061
  elmToMove = oldCh[idxInOld];
@@ -4946,12 +5063,22 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4946
5063
  if (isVNode(elmToMove)) {
4947
5064
  if (elmToMove.sel !== newStartVnode.sel) {
4948
5065
  // New element
4949
- newStartVnode.hook.create(newStartVnode);
4950
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5066
+ mount(newStartVnode, parent, oldStartVnode.elm);
4951
5067
  } else {
4952
- patchVnode(elmToMove, newStartVnode);
5068
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5069
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5070
+ // so we only care about the `oldCh` object inside this function.
5071
+ // To avoid cloning over and over again, we check `clonedOldCh`
5072
+ // and only clone once.
5073
+
5074
+ if (!clonedOldCh) {
5075
+ clonedOldCh = true;
5076
+ oldCh = [...oldCh];
5077
+ } // We've already cloned at least once, so it's no longer read-only
5078
+
5079
+
4953
5080
  oldCh[idxInOld] = undefined;
4954
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5081
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4955
5082
  }
4956
5083
  }
4957
5084
 
@@ -4972,65 +5099,55 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4972
5099
  } while (!isVNode(n) && i < newChEnd);
4973
5100
 
4974
5101
  before = isVNode(n) ? n.elm : null;
4975
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5102
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4976
5103
  } else {
4977
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5104
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4978
5105
  }
4979
5106
  }
4980
5107
  }
4981
5108
 
4982
- function updateStaticChildren(parentElm, oldCh, newCh) {
4983
- const oldChLength = oldCh.length;
4984
- const newChLength = newCh.length;
5109
+ function updateStaticChildren(c1, c2, parent) {
5110
+ const c1Length = c1.length;
5111
+ const c2Length = c2.length;
4985
5112
 
4986
- if (oldChLength === 0) {
5113
+ if (c1Length === 0) {
4987
5114
  // the old list is empty, we can directly insert anything new
4988
- addVnodes(parentElm, null, newCh, 0, newChLength);
5115
+ mountVNodes(c2, parent, null);
4989
5116
  return;
4990
5117
  }
4991
5118
 
4992
- if (newChLength === 0) {
5119
+ if (c2Length === 0) {
4993
5120
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4994
5121
  // this is the case in which the dynamic children of an if-directive should be removed
4995
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5122
+ unmountVNodes(c1, parent, true);
4996
5123
  return;
4997
5124
  } // if the old list is not empty, the new list MUST have the same
4998
5125
  // amount of nodes, that's why we call this static children
4999
5126
 
5000
5127
 
5001
- let referenceElm = null;
5128
+ let anchor = null;
5002
5129
 
5003
- for (let i = newChLength - 1; i >= 0; i -= 1) {
5004
- const vnode = newCh[i];
5005
- const oldVNode = oldCh[i];
5130
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
5131
+ const n1 = c1[i];
5132
+ const n2 = c2[i];
5006
5133
 
5007
- if (vnode !== oldVNode) {
5008
- if (isVNode(oldVNode)) {
5009
- if (isVNode(vnode)) {
5010
- // both vnodes must be equivalent, and se just need to patch them
5011
- patchVnode(oldVNode, vnode);
5012
- referenceElm = vnode.elm;
5134
+ if (n2 !== n1) {
5135
+ if (isVNode(n1)) {
5136
+ if (isVNode(n2)) {
5137
+ // both vnodes are equivalent, and we just need to patch them
5138
+ patch(n1, n2);
5139
+ anchor = n2.elm;
5013
5140
  } else {
5014
5141
  // removing the old vnode since the new one is null
5015
- oldVNode.hook.remove(oldVNode, parentElm);
5142
+ unmount(n1, parent, true);
5016
5143
  }
5017
- } else if (isVNode(vnode)) {
5018
- // this condition is unnecessary
5019
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5020
-
5021
- vnode.hook.insert(vnode, parentElm, referenceElm);
5022
- referenceElm = vnode.elm;
5144
+ } else if (isVNode(n2)) {
5145
+ mount(n2, parent, anchor);
5146
+ anchor = n2.elm;
5023
5147
  }
5024
5148
  }
5025
5149
  }
5026
5150
  }
5027
-
5028
- function patchVnode(oldVnode, vnode) {
5029
- if (oldVnode !== vnode) {
5030
- vnode.elm = oldVnode.elm;
5031
- vnode.hook.update(oldVnode, vnode);
5032
- }
5033
- }
5034
5151
  /*
5035
5152
  * Copyright (c) 2018, salesforce.com, inc.
5036
5153
  * All rights reserved.
@@ -5046,7 +5163,7 @@ function addVNodeToChildLWC(vnode) {
5046
5163
  } // [h]tml node
5047
5164
 
5048
5165
 
5049
- function h(sel, data, children) {
5166
+ function h(sel, data, children = EmptyArray) {
5050
5167
  const vmBeingRendered = getVMBeingRendered();
5051
5168
 
5052
5169
  if (process.env.NODE_ENV !== 'production') {
@@ -5082,7 +5199,6 @@ function h(sel, data, children) {
5082
5199
  children,
5083
5200
  elm,
5084
5201
  key,
5085
- hook: ElementHook,
5086
5202
  owner: vmBeingRendered
5087
5203
  };
5088
5204
  } // [t]ab[i]ndex function
@@ -5169,7 +5285,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
5169
5285
  const {
5170
5286
  key
5171
5287
  } = data;
5172
- let elm;
5288
+ let elm, aChildren, vm;
5173
5289
  const vnode = {
5174
5290
  type: 3
5175
5291
  /* CustomElement */
@@ -5179,11 +5295,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
5179
5295
  children,
5180
5296
  elm,
5181
5297
  key,
5182
- hook: CustomElementHook,
5183
5298
  ctor: Ctor,
5184
5299
  owner: vmBeingRendered,
5185
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5186
-
5300
+ mode: 'open',
5301
+ aChildren,
5302
+ vm
5187
5303
  };
5188
5304
  addVNodeToChildLWC(vnode);
5189
5305
  return vnode;
@@ -5313,7 +5429,6 @@ function t(text) {
5313
5429
  text,
5314
5430
  elm,
5315
5431
  key,
5316
- hook: TextHook,
5317
5432
  owner: getVMBeingRendered()
5318
5433
  };
5319
5434
  } // [co]mment node
@@ -5329,7 +5444,6 @@ function co(text) {
5329
5444
  text,
5330
5445
  elm,
5331
5446
  key,
5332
- hook: CommentHook,
5333
5447
  owner: getVMBeingRendered()
5334
5448
  };
5335
5449
  } // [d]ynamic text
@@ -5444,7 +5558,7 @@ let dynamicImportedComponentCounter = 0;
5444
5558
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5445
5559
  */
5446
5560
 
5447
- function dc(sel, Ctor, data, children) {
5561
+ function dc(sel, Ctor, data, children = EmptyArray) {
5448
5562
  if (process.env.NODE_ENV !== 'production') {
5449
5563
  assert.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
5450
5564
  assert.isTrue(isObject(data), `dc() 3nd argument data must be an object.`);
@@ -5468,10 +5582,14 @@ function dc(sel, Ctor, data, children) {
5468
5582
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
5469
5583
  // to identify different constructors as vnodes with different keys to avoid reusing the
5470
5584
  // element used for previous constructors.
5585
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
5586
+ // hoisting optimization.
5471
5587
 
5472
5588
 
5473
- data.key = `dc:${idx}:${data.key}`;
5474
- return c(sel, Ctor, data, children);
5589
+ const newData = Object.assign(Object.assign({}, data), {
5590
+ key: `dc:${idx}:${data.key}`
5591
+ });
5592
+ return c(sel, Ctor, newData, children);
5475
5593
  }
5476
5594
  /**
5477
5595
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5591,12 +5709,14 @@ function updateStylesheetToken(vm, template) {
5591
5709
  hasTokenInAttribute: oldHasTokenInAttribute
5592
5710
  } = context;
5593
5711
 
5594
- if (oldHasTokenInClass) {
5595
- getClassList$1(elm).remove(makeHostToken(oldToken));
5596
- }
5712
+ if (!isUndefined$1(oldToken)) {
5713
+ if (oldHasTokenInClass) {
5714
+ getClassList$1(elm).remove(makeHostToken(oldToken));
5715
+ }
5597
5716
 
5598
- if (oldHasTokenInAttribute) {
5599
- removeAttribute$1(elm, makeHostToken(oldToken));
5717
+ if (oldHasTokenInAttribute) {
5718
+ removeAttribute$1(elm, makeHostToken(oldToken));
5719
+ }
5600
5720
  } // Apply the new template styling token to the host element, if the new template has any
5601
5721
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5602
5722
 
@@ -6138,6 +6258,10 @@ const signedTemplateMap = new Map();
6138
6258
  function registerComponent(Ctor, {
6139
6259
  tmpl
6140
6260
  }) {
6261
+ if (process.env.NODE_ENV !== 'production') {
6262
+ checkVersionMismatch(Ctor, 'component');
6263
+ }
6264
+
6141
6265
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6142
6266
  // without too much transformation
6143
6267
 
@@ -6459,7 +6583,11 @@ function computeShadowMode(vm) {
6459
6583
  /* Native */
6460
6584
  ;
6461
6585
  } else if (isNativeShadowDefined$1) {
6462
- if (def.shadowSupportMode === "any"
6586
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
6587
+ shadowMode = 1
6588
+ /* Synthetic */
6589
+ ;
6590
+ } else if (def.shadowSupportMode === "any"
6463
6591
  /* Any */
6464
6592
  ) {
6465
6593
  shadowMode = 0
@@ -6558,7 +6686,7 @@ function patchShadowRoot(vm, newCh) {
6558
6686
  , vm);
6559
6687
  }, () => {
6560
6688
  // job
6561
- patchChildren(renderRoot, oldCh, newCh);
6689
+ patchChildren(oldCh, newCh, renderRoot);
6562
6690
  }, () => {
6563
6691
  // post
6564
6692
  logOperationEnd(2
@@ -7287,7 +7415,7 @@ function setHooks(hooks) {
7287
7415
  hooksAreSet = true;
7288
7416
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7289
7417
  }
7290
- /* version: 2.7.4 */
7418
+ /* version: 2.10.0 */
7291
7419
 
7292
7420
  /*
7293
7421
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7827,7 +7955,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7827
7955
 
7828
7956
  freeze(LightningElement);
7829
7957
  seal(LightningElement.prototype);
7830
- /* version: 2.7.4 */
7958
+ /* version: 2.10.0 */
7831
7959
 
7832
7960
  exports.LightningElement = LightningElement;
7833
7961
  exports.api = api$1;