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
@@ -255,7 +255,7 @@ const KEY__SCOPED_CSS = '$scoped$';
255
255
  // The following list contains a mix of both void elements from the HTML and the XML namespace
256
256
  // without distinction.
257
257
 
258
- 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'];
258
+ 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'];
259
259
  const VOID_ELEMENTS_SET = new Set(VOID_ELEMENTS);
260
260
 
261
261
  function isVoidElement(name) {
@@ -339,7 +339,17 @@ function htmlPropertyToAttribute(propName) {
339
339
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
340
340
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
341
341
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
342
- /** version: 2.9.0 */
342
+ /*
343
+ * Copyright (c) 2018, salesforce.com, inc.
344
+ * All rights reserved.
345
+ * SPDX-License-Identifier: MIT
346
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
347
+ */
348
+ // Increment whenever the LWC template compiler changes
349
+
350
+ const LWC_VERSION = "2.10.0";
351
+ const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
352
+ /** version: 2.10.0 */
343
353
 
344
354
  /*
345
355
  * Copyright (c) 2020, salesforce.com, inc.
@@ -388,14 +398,15 @@ if (typeof CustomEvent !== 'function') {
388
398
 
389
399
 
390
400
  const features = {
391
- ENABLE_REACTIVE_SETTER: null,
392
- ENABLE_HMR: null,
393
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
401
+ DISABLE_MIXED_SHADOW_MODE: null,
394
402
  ENABLE_ELEMENT_PATCH: null,
395
403
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
396
- ENABLE_NODE_LIST_PATCH: null,
404
+ ENABLE_HMR: null,
397
405
  ENABLE_HTML_COLLECTIONS_PATCH: null,
406
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
407
+ ENABLE_NODE_LIST_PATCH: null,
398
408
  ENABLE_NODE_PATCH: null,
409
+ ENABLE_REACTIVE_SETTER: null,
399
410
  ENABLE_WIRE_SYNC_EMIT: null
400
411
  };
401
412
 
@@ -460,7 +471,7 @@ function setFeatureFlagForTest(name, value) {
460
471
  setFeatureFlag(name, value);
461
472
  }
462
473
  }
463
- /** version: 2.9.0 */
474
+ /** version: 2.10.0 */
464
475
 
465
476
  /* proxy-compat-disable */
466
477
 
@@ -513,7 +524,21 @@ function guid() {
513
524
 
514
525
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
515
526
  } // Borrowed from Vue template compiler.
516
- //
527
+
528
+
529
+ function flattenStylesheets(stylesheets) {
530
+ const list = [];
531
+
532
+ for (const stylesheet of stylesheets) {
533
+ if (!Array.isArray(stylesheet)) {
534
+ list.push(stylesheet);
535
+ } else {
536
+ list.push(...flattenStylesheets(stylesheet));
537
+ }
538
+ }
539
+
540
+ return list;
541
+ } //
517
542
  // Primitives
518
543
  //
519
544
 
@@ -3314,6 +3339,47 @@ function getDecoratorsMeta(Ctor) {
3314
3339
  const meta = signedDecoratorToMetaMap.get(Ctor);
3315
3340
  return isUndefined$1(meta) ? defaultMeta : meta;
3316
3341
  }
3342
+ /*
3343
+ * Copyright (c) 2018, salesforce.com, inc.
3344
+ * All rights reserved.
3345
+ * SPDX-License-Identifier: MIT
3346
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3347
+ */
3348
+
3349
+
3350
+ let warned = false;
3351
+
3352
+ if (process.env.NODE_ENV === 'development') {
3353
+ // @ts-ignore
3354
+ window.__lwcResetWarnedOnVersionMismatch = () => {
3355
+ warned = false;
3356
+ };
3357
+ }
3358
+
3359
+ function checkVersionMismatch(func, type) {
3360
+ const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3361
+
3362
+ if (!isNull(versionMatcher) && !warned) {
3363
+ const version = versionMatcher[1];
3364
+ const [major, minor] = version.split('.');
3365
+ const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
3366
+
3367
+ if (major !== expectedMajor || minor !== expectedMinor) {
3368
+ warned = true; // only warn once to avoid flooding the console
3369
+ // stylesheets and templates do not have user-meaningful names, but components do
3370
+
3371
+ const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
3372
+ 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.`);
3373
+ }
3374
+ }
3375
+ }
3376
+ /*
3377
+ * Copyright (c) 2018, salesforce.com, inc.
3378
+ * All rights reserved.
3379
+ * SPDX-License-Identifier: MIT
3380
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3381
+ */
3382
+
3317
3383
 
3318
3384
  const signedTemplateSet = new Set();
3319
3385
 
@@ -3326,6 +3392,16 @@ signedTemplateSet.add(defaultEmptyTemplate);
3326
3392
  function isTemplateRegistered(tpl) {
3327
3393
  return signedTemplateSet.has(tpl);
3328
3394
  }
3395
+
3396
+ function checkTemplateVersionMismatch(template) {
3397
+ checkVersionMismatch(template, 'template');
3398
+
3399
+ if (!isUndefined$1(template.stylesheets)) {
3400
+ for (const stylesheet of flattenStylesheets(template.stylesheets)) {
3401
+ checkVersionMismatch(stylesheet, 'stylesheet');
3402
+ }
3403
+ }
3404
+ }
3329
3405
  /**
3330
3406
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3331
3407
  * will prevent this function from being imported by userland code.
@@ -3333,6 +3409,10 @@ function isTemplateRegistered(tpl) {
3333
3409
 
3334
3410
 
3335
3411
  function registerTemplate(tpl) {
3412
+ if (process.env.NODE_ENV !== 'production') {
3413
+ checkTemplateVersionMismatch(tpl);
3414
+ }
3415
+
3336
3416
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3337
3417
  // assignment of templates easily, without too much transformation
3338
3418
 
@@ -3557,20 +3637,6 @@ const activeTemplates = new WeakMap();
3557
3637
  const activeComponents = new WeakMap();
3558
3638
  const activeStyles = new WeakMap();
3559
3639
 
3560
- function flattenStylesheets(stylesheets) {
3561
- const list = [];
3562
-
3563
- for (const stylesheet of stylesheets) {
3564
- if (!Array.isArray(stylesheet)) {
3565
- list.push(stylesheet);
3566
- } else {
3567
- list.push(...flattenStylesheets(stylesheet));
3568
- }
3569
- }
3570
-
3571
- return list;
3572
- }
3573
-
3574
3640
  function getTemplateOrSwappedTemplate(tpl) {
3575
3641
  if (process.env.NODE_ENV === 'production') {
3576
3642
  // this method should never leak to prod
@@ -4347,156 +4413,268 @@ function applyStaticStyleAttribute(vnode) {
4347
4413
  */
4348
4414
 
4349
4415
 
4350
- const TextHook = {
4351
- create: vnode => {
4352
- const {
4353
- owner
4354
- } = vnode;
4355
- const elm = createText$1(vnode.text);
4356
- linkNodeToShadow(elm, owner);
4357
- vnode.elm = elm;
4358
- },
4359
- update: updateNodeHook,
4360
- insert: insertNode,
4361
- move: insertNode,
4362
- remove: removeNode
4363
- };
4364
- const CommentHook = {
4365
- create: vnode => {
4366
- const {
4367
- owner,
4368
- text
4369
- } = vnode;
4370
- const elm = createComment$1(text);
4371
- linkNodeToShadow(elm, owner);
4372
- vnode.elm = elm;
4373
- },
4374
- update: updateNodeHook,
4375
- insert: insertNode,
4376
- move: insertNode,
4377
- remove: removeNode
4378
- }; // insert is called after update, which is used somewhere else (via a module)
4379
- // to mark the vm as inserted, that means we cannot use update as the main channel
4380
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4381
- // which breaks some invariants. For that reason, we have the following for any
4382
- // Custom Element that is inserted via a template.
4383
-
4384
- const ElementHook = {
4385
- create: vnode => {
4386
- const {
4387
- sel,
4388
- owner,
4389
- data: {
4390
- svg
4391
- }
4392
- } = vnode;
4393
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4394
- const elm = createElement$1(sel, namespace);
4395
- linkNodeToShadow(elm, owner);
4396
- fallbackElmHook(elm, vnode);
4397
- vnode.elm = elm;
4398
- patchElementPropsAndAttrs$1(null, vnode);
4399
- },
4400
- update: (oldVnode, vnode) => {
4401
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4402
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4403
- },
4404
- insert: (vnode, parentNode, referenceNode) => {
4405
- insertNode(vnode, parentNode, referenceNode);
4406
- createChildrenHook(vnode);
4407
- },
4408
- move: insertNode,
4409
- remove: (vnode, parentNode) => {
4410
- removeNode(vnode, parentNode);
4411
- removeChildren(vnode);
4416
+ function patchChildren(c1, c2, parent) {
4417
+ if (hasDynamicChildren(c2)) {
4418
+ updateDynamicChildren(c1, c2, parent);
4419
+ } else {
4420
+ updateStaticChildren(c1, c2, parent);
4421
+ }
4422
+ }
4423
+
4424
+ function patch(n1, n2) {
4425
+ if (n1 === n2) {
4426
+ return;
4412
4427
  }
4413
- };
4414
- const CustomElementHook = {
4415
- create: vnode => {
4416
- const {
4417
- sel,
4418
- owner
4419
- } = vnode;
4420
- const UpgradableConstructor = getUpgradableConstructor(sel);
4421
- /**
4422
- * Note: if the upgradable constructor does not expect, or throw when we new it
4423
- * with a callback as the first argument, we could implement a more advanced
4424
- * mechanism that only passes that argument if the constructor is known to be
4425
- * an upgradable custom element.
4426
- */
4427
-
4428
- let vm;
4429
- const elm = new UpgradableConstructor(elm => {
4430
- // the custom element from the registry is expecting an upgrade callback
4431
- vm = createViewModelHook(elm, vnode);
4432
- });
4433
- linkNodeToShadow(elm, owner);
4434
- vnode.elm = elm;
4435
4428
 
4436
- if (vm) {
4437
- allocateChildren(vnode, vm);
4438
- } else if (vnode.ctor !== UpgradableConstructor) {
4439
- throw new TypeError(`Incorrect Component Constructor`);
4429
+ if (process.env.NODE_ENV !== 'production') {
4430
+ if (!isSameVnode(n1, n2)) {
4431
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4432
+ sel: n1.sel,
4433
+ key: n1.key
4434
+ }) + ', ' + JSON.stringify({
4435
+ sel: n2.sel,
4436
+ key: n2.key
4437
+ }));
4440
4438
  }
4439
+ }
4441
4440
 
4442
- patchElementPropsAndAttrs$1(null, vnode);
4443
- },
4444
- update: (oldVnode, vnode) => {
4445
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4446
- const vm = getAssociatedVMIfPresent(vnode.elm);
4441
+ switch (n2.type) {
4442
+ case 0
4443
+ /* Text */
4444
+ :
4445
+ patchText(n1, n2);
4446
+ break;
4447
4447
 
4448
- if (vm) {
4449
- // in fallback mode, the allocation will always set children to
4450
- // empty and delegate the real allocation to the slot elements
4451
- allocateChildren(vnode, vm);
4452
- } // in fallback mode, the children will be always empty, so, nothing
4453
- // will happen, but in native, it does allocate the light dom
4448
+ case 1
4449
+ /* Comment */
4450
+ :
4451
+ patchComment(n1, n2);
4452
+ break;
4454
4453
 
4454
+ case 2
4455
+ /* Element */
4456
+ :
4457
+ patchElement(n1, n2);
4458
+ break;
4455
4459
 
4456
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4460
+ case 3
4461
+ /* CustomElement */
4462
+ :
4463
+ patchCustomElement(n1, n2);
4464
+ break;
4465
+ }
4466
+ }
4457
4467
 
4458
- if (vm) {
4459
- if (process.env.NODE_ENV !== 'production') {
4460
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4461
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4462
- // this is important to preserve the top to bottom synchronous rendering phase.
4468
+ function mount(node, parent, anchor) {
4469
+ switch (node.type) {
4470
+ case 0
4471
+ /* Text */
4472
+ :
4473
+ mountText(node, parent, anchor);
4474
+ break;
4463
4475
 
4476
+ case 1
4477
+ /* Comment */
4478
+ :
4479
+ mountComment(node, parent, anchor);
4480
+ break;
4481
+
4482
+ case 2
4483
+ /* Element */
4484
+ :
4485
+ mountElement(node, parent, anchor);
4486
+ break;
4487
+
4488
+ case 3
4489
+ /* CustomElement */
4490
+ :
4491
+ mountCustomElement(node, parent, anchor);
4492
+ break;
4493
+ }
4494
+ }
4495
+
4496
+ function patchText(n1, n2) {
4497
+ n2.elm = n1.elm;
4498
+
4499
+ if (n2.text !== n1.text) {
4500
+ updateTextContent(n2);
4501
+ }
4502
+ }
4503
+
4504
+ function mountText(node, parent, anchor) {
4505
+ const {
4506
+ owner
4507
+ } = node;
4508
+ const textNode = node.elm = createText$1(node.text);
4509
+ linkNodeToShadow(textNode, owner);
4510
+ insertNode(textNode, parent, anchor);
4511
+ }
4464
4512
 
4465
- rerenderVM(vm);
4513
+ function patchComment(n1, n2) {
4514
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4515
+ // it is the case today.
4516
+
4517
+ if (n2.text !== n1.text) {
4518
+ updateTextContent(n2);
4519
+ }
4520
+ }
4521
+
4522
+ function mountComment(node, parent, anchor) {
4523
+ const {
4524
+ owner
4525
+ } = node;
4526
+ const commentNode = node.elm = createComment$1(node.text);
4527
+ linkNodeToShadow(commentNode, owner);
4528
+ insertNode(commentNode, parent, anchor);
4529
+ }
4530
+
4531
+ function mountElement(vnode, parent, anchor) {
4532
+ const {
4533
+ sel,
4534
+ owner,
4535
+ data: {
4536
+ svg
4466
4537
  }
4467
- },
4468
- insert: (vnode, parentNode, referenceNode) => {
4469
- insertNode(vnode, parentNode, referenceNode);
4470
- const vm = getAssociatedVMIfPresent(vnode.elm);
4538
+ } = vnode;
4539
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4540
+ const elm = createElement$1(sel, namespace);
4541
+ linkNodeToShadow(elm, owner);
4542
+ fallbackElmHook(elm, vnode);
4543
+ vnode.elm = elm;
4544
+ patchElementPropsAndAttrs$1(null, vnode);
4545
+ insertNode(elm, parent, anchor);
4546
+ mountVNodes(vnode.children, elm, null);
4547
+ }
4471
4548
 
4472
- if (vm) {
4473
- if (process.env.NODE_ENV !== 'production') {
4474
- assert.isTrue(vm.state === 0
4475
- /* created */
4476
- , `${vm} cannot be recycled.`);
4477
- }
4549
+ function patchElement(n1, n2) {
4550
+ const elm = n2.elm = n1.elm;
4551
+ patchElementPropsAndAttrs$1(n1, n2);
4552
+ patchChildren(n1.children, n2.children, elm);
4553
+ }
4554
+
4555
+ function mountCustomElement(vnode, parent, anchor) {
4556
+ const {
4557
+ sel,
4558
+ owner
4559
+ } = vnode;
4560
+ const UpgradableConstructor = getUpgradableConstructor(sel);
4561
+ /**
4562
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4563
+ * with a callback as the first argument, we could implement a more advanced
4564
+ * mechanism that only passes that argument if the constructor is known to be
4565
+ * an upgradable custom element.
4566
+ */
4567
+
4568
+ let vm;
4569
+ const elm = new UpgradableConstructor(elm => {
4570
+ // the custom element from the registry is expecting an upgrade callback
4571
+ vm = createViewModelHook(elm, vnode);
4572
+ });
4573
+ linkNodeToShadow(elm, owner);
4574
+ vnode.elm = elm;
4575
+ vnode.vm = vm;
4478
4576
 
4479
- runConnectedCallback(vm);
4577
+ if (vm) {
4578
+ allocateChildren(vnode, vm);
4579
+ } else if (vnode.ctor !== UpgradableConstructor) {
4580
+ throw new TypeError(`Incorrect Component Constructor`);
4581
+ }
4582
+
4583
+ patchElementPropsAndAttrs$1(null, vnode);
4584
+ insertNode(elm, parent, anchor);
4585
+
4586
+ if (vm) {
4587
+ if (process.env.NODE_ENV !== 'production') {
4588
+ assert.isTrue(vm.state === 0
4589
+ /* created */
4590
+ , `${vm} cannot be recycled.`);
4480
4591
  }
4481
4592
 
4482
- createChildrenHook(vnode);
4593
+ runConnectedCallback(vm);
4594
+ }
4595
+
4596
+ mountVNodes(vnode.children, elm, null);
4597
+
4598
+ if (vm) {
4599
+ appendVM(vm);
4600
+ }
4601
+ }
4602
+
4603
+ function patchCustomElement(n1, n2) {
4604
+ const elm = n2.elm = n1.elm;
4605
+ const vm = n2.vm = n1.vm;
4606
+ patchElementPropsAndAttrs$1(n1, n2);
4607
+
4608
+ if (!isUndefined$1(vm)) {
4609
+ // in fallback mode, the allocation will always set children to
4610
+ // empty and delegate the real allocation to the slot elements
4611
+ allocateChildren(n2, vm);
4612
+ } // in fallback mode, the children will be always empty, so, nothing
4613
+ // will happen, but in native, it does allocate the light dom
4483
4614
 
4484
- if (vm) {
4485
- appendVM(vm);
4615
+
4616
+ patchChildren(n1.children, n2.children, elm);
4617
+
4618
+ if (!isUndefined$1(vm)) {
4619
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4620
+ // this is important to preserve the top to bottom synchronous rendering phase.
4621
+ rerenderVM(vm);
4622
+ }
4623
+ }
4624
+
4625
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
4626
+ for (; start < end; ++start) {
4627
+ const vnode = vnodes[start];
4628
+
4629
+ if (isVNode(vnode)) {
4630
+ mount(vnode, parent, anchor);
4486
4631
  }
4487
- },
4488
- move: insertNode,
4489
- remove: (vnode, parentNode) => {
4490
- removeNode(vnode, parentNode);
4491
- const vm = getAssociatedVMIfPresent(vnode.elm);
4632
+ }
4633
+ }
4634
+
4635
+ function unmount(vnode, parent, doRemove = false) {
4636
+ const {
4637
+ type,
4638
+ elm
4639
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4640
+ // subtree root, is the only element worth unmounting from the subtree.
4641
+
4642
+ if (doRemove) {
4643
+ removeNode(elm, parent);
4644
+ }
4645
+
4646
+ switch (type) {
4647
+ case 2
4648
+ /* Element */
4649
+ :
4650
+ unmountVNodes(vnode.children, elm);
4651
+ break;
4652
+
4653
+ case 3
4654
+ /* CustomElement */
4655
+ :
4656
+ {
4657
+ const {
4658
+ vm
4659
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
4660
+ // children.
4661
+
4662
+ if (!isUndefined$1(vm)) {
4663
+ removeVM(vm);
4664
+ }
4665
+ }
4666
+ }
4667
+ }
4492
4668
 
4493
- if (vm) {
4494
- // for custom elements we don't have to go recursively because the removeVM routine
4495
- // will take care of disconnecting any child VM attached to its shadow as well.
4496
- removeVM(vm);
4669
+ function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
4670
+ for (; start < end; ++start) {
4671
+ const ch = vnodes[start];
4672
+
4673
+ if (isVNode(ch)) {
4674
+ unmount(ch, parent, doRemove);
4497
4675
  }
4498
4676
  }
4499
- };
4677
+ }
4500
4678
 
4501
4679
  function isVNode(vnode) {
4502
4680
  return vnode != null;
@@ -4541,43 +4719,41 @@ function linkNodeToShadow(elm, owner) {
4541
4719
  }
4542
4720
  }
4543
4721
 
4544
- function updateNodeHook(oldVnode, vnode) {
4722
+ function updateTextContent(vnode) {
4545
4723
  const {
4546
4724
  elm,
4547
4725
  text
4548
4726
  } = vnode;
4549
4727
 
4550
- if (oldVnode.text !== text) {
4551
- if (process.env.NODE_ENV !== 'production') {
4552
- unlockDomMutation();
4553
- }
4728
+ if (process.env.NODE_ENV !== 'production') {
4729
+ unlockDomMutation();
4730
+ }
4554
4731
 
4555
- setText$1(elm, text);
4732
+ setText$1(elm, text);
4556
4733
 
4557
- if (process.env.NODE_ENV !== 'production') {
4558
- lockDomMutation();
4559
- }
4734
+ if (process.env.NODE_ENV !== 'production') {
4735
+ lockDomMutation();
4560
4736
  }
4561
4737
  }
4562
4738
 
4563
- function insertNode(vnode, parentNode, referenceNode) {
4739
+ function insertNode(node, parent, anchor) {
4564
4740
  if (process.env.NODE_ENV !== 'production') {
4565
4741
  unlockDomMutation();
4566
4742
  }
4567
4743
 
4568
- insert$1(vnode.elm, parentNode, referenceNode);
4744
+ insert$1(node, parent, anchor);
4569
4745
 
4570
4746
  if (process.env.NODE_ENV !== 'production') {
4571
4747
  lockDomMutation();
4572
4748
  }
4573
4749
  }
4574
4750
 
4575
- function removeNode(vnode, parentNode) {
4751
+ function removeNode(node, parent) {
4576
4752
  if (process.env.NODE_ENV !== 'production') {
4577
4753
  unlockDomMutation();
4578
4754
  }
4579
4755
 
4580
- remove$1(vnode.elm, parentNode);
4756
+ remove$1(node, parent);
4581
4757
 
4582
4758
  if (process.env.NODE_ENV !== 'production') {
4583
4759
  lockDomMutation();
@@ -4650,14 +4826,6 @@ function fallbackElmHook(elm, vnode) {
4650
4826
  }
4651
4827
  }
4652
4828
 
4653
- function patchChildren(parent, oldCh, newCh) {
4654
- if (hasDynamicChildren(newCh)) {
4655
- updateDynamicChildren(parent, oldCh, newCh);
4656
- } else {
4657
- updateStaticChildren(parent, oldCh, newCh);
4658
- }
4659
- }
4660
-
4661
4829
  function allocateChildren(vnode, vm) {
4662
4830
  // A component with slots will re-render because:
4663
4831
  // 1- There is a change of the internal state.
@@ -4733,40 +4901,6 @@ function createViewModelHook(elm, vnode) {
4733
4901
  return vm;
4734
4902
  }
4735
4903
 
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
4904
  function allocateInSlot(vm, children) {
4771
4905
  var _a;
4772
4906
 
@@ -4863,28 +4997,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
4863
4997
  return map;
4864
4998
  }
4865
4999
 
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) {
5000
+ function updateDynamicChildren(oldCh, newCh, parent) {
4888
5001
  let oldStartIdx = 0;
4889
5002
  let newStartIdx = 0;
4890
5003
  let oldEndIdx = oldCh.length - 1;
@@ -4910,23 +5023,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4910
5023
  } else if (!isVNode(newEndVnode)) {
4911
5024
  newEndVnode = newCh[--newEndIdx];
4912
5025
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4913
- patchVnode(oldStartVnode, newStartVnode);
5026
+ patch(oldStartVnode, newStartVnode);
4914
5027
  oldStartVnode = oldCh[++oldStartIdx];
4915
5028
  newStartVnode = newCh[++newStartIdx];
4916
5029
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4917
- patchVnode(oldEndVnode, newEndVnode);
5030
+ patch(oldEndVnode, newEndVnode);
4918
5031
  oldEndVnode = oldCh[--oldEndIdx];
4919
5032
  newEndVnode = newCh[--newEndIdx];
4920
5033
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4921
5034
  // Vnode moved right
4922
- patchVnode(oldStartVnode, newEndVnode);
4923
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5035
+ patch(oldStartVnode, newEndVnode);
5036
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4924
5037
  oldStartVnode = oldCh[++oldStartIdx];
4925
5038
  newEndVnode = newCh[--newEndIdx];
4926
5039
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4927
5040
  // Vnode moved left
4928
- patchVnode(oldEndVnode, newStartVnode);
4929
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5041
+ patch(oldEndVnode, newStartVnode);
5042
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4930
5043
  oldEndVnode = oldCh[--oldEndIdx];
4931
5044
  newStartVnode = newCh[++newStartIdx];
4932
5045
  } else {
@@ -4938,8 +5051,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4938
5051
 
4939
5052
  if (isUndefined$1(idxInOld)) {
4940
5053
  // New element
4941
- newStartVnode.hook.create(newStartVnode);
4942
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5054
+ mount(newStartVnode, parent, oldStartVnode.elm);
4943
5055
  newStartVnode = newCh[++newStartIdx];
4944
5056
  } else {
4945
5057
  elmToMove = oldCh[idxInOld];
@@ -4947,10 +5059,9 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4947
5059
  if (isVNode(elmToMove)) {
4948
5060
  if (elmToMove.sel !== newStartVnode.sel) {
4949
5061
  // New element
4950
- newStartVnode.hook.create(newStartVnode);
4951
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5062
+ mount(newStartVnode, parent, oldStartVnode.elm);
4952
5063
  } else {
4953
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5064
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
4954
5065
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4955
5066
  // so we only care about the `oldCh` object inside this function.
4956
5067
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -4963,7 +5074,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4963
5074
 
4964
5075
 
4965
5076
  oldCh[idxInOld] = undefined;
4966
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5077
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4967
5078
  }
4968
5079
  }
4969
5080
 
@@ -4984,65 +5095,55 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4984
5095
  } while (!isVNode(n) && i < newChEnd);
4985
5096
 
4986
5097
  before = isVNode(n) ? n.elm : null;
4987
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5098
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4988
5099
  } else {
4989
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5100
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4990
5101
  }
4991
5102
  }
4992
5103
  }
4993
5104
 
4994
- function updateStaticChildren(parentElm, oldCh, newCh) {
4995
- const oldChLength = oldCh.length;
4996
- const newChLength = newCh.length;
5105
+ function updateStaticChildren(c1, c2, parent) {
5106
+ const c1Length = c1.length;
5107
+ const c2Length = c2.length;
4997
5108
 
4998
- if (oldChLength === 0) {
5109
+ if (c1Length === 0) {
4999
5110
  // the old list is empty, we can directly insert anything new
5000
- addVnodes(parentElm, null, newCh, 0, newChLength);
5111
+ mountVNodes(c2, parent, null);
5001
5112
  return;
5002
5113
  }
5003
5114
 
5004
- if (newChLength === 0) {
5115
+ if (c2Length === 0) {
5005
5116
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5006
5117
  // this is the case in which the dynamic children of an if-directive should be removed
5007
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5118
+ unmountVNodes(c1, parent, true);
5008
5119
  return;
5009
5120
  } // if the old list is not empty, the new list MUST have the same
5010
5121
  // amount of nodes, that's why we call this static children
5011
5122
 
5012
5123
 
5013
- let referenceElm = null;
5124
+ let anchor = null;
5014
5125
 
5015
- for (let i = newChLength - 1; i >= 0; i -= 1) {
5016
- const vnode = newCh[i];
5017
- const oldVNode = oldCh[i];
5126
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
5127
+ const n1 = c1[i];
5128
+ const n2 = c2[i];
5018
5129
 
5019
- if (vnode !== oldVNode) {
5020
- if (isVNode(oldVNode)) {
5021
- if (isVNode(vnode)) {
5022
- // both vnodes must be equivalent, and se just need to patch them
5023
- patchVnode(oldVNode, vnode);
5024
- referenceElm = vnode.elm;
5130
+ if (n2 !== n1) {
5131
+ if (isVNode(n1)) {
5132
+ if (isVNode(n2)) {
5133
+ // both vnodes are equivalent, and we just need to patch them
5134
+ patch(n1, n2);
5135
+ anchor = n2.elm;
5025
5136
  } else {
5026
5137
  // removing the old vnode since the new one is null
5027
- oldVNode.hook.remove(oldVNode, parentElm);
5138
+ unmount(n1, parent, true);
5028
5139
  }
5029
- } else if (isVNode(vnode)) {
5030
- // this condition is unnecessary
5031
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5032
-
5033
- vnode.hook.insert(vnode, parentElm, referenceElm);
5034
- referenceElm = vnode.elm;
5140
+ } else if (isVNode(n2)) {
5141
+ mount(n2, parent, anchor);
5142
+ anchor = n2.elm;
5035
5143
  }
5036
5144
  }
5037
5145
  }
5038
5146
  }
5039
-
5040
- function patchVnode(oldVnode, vnode) {
5041
- if (oldVnode !== vnode) {
5042
- vnode.elm = oldVnode.elm;
5043
- vnode.hook.update(oldVnode, vnode);
5044
- }
5045
- }
5046
5147
  /*
5047
5148
  * Copyright (c) 2018, salesforce.com, inc.
5048
5149
  * All rights reserved.
@@ -5094,7 +5195,6 @@ function h(sel, data, children = EmptyArray) {
5094
5195
  children,
5095
5196
  elm,
5096
5197
  key,
5097
- hook: ElementHook,
5098
5198
  owner: vmBeingRendered
5099
5199
  };
5100
5200
  } // [t]ab[i]ndex function
@@ -5181,7 +5281,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
5181
5281
  const {
5182
5282
  key
5183
5283
  } = data;
5184
- let elm;
5284
+ let elm, aChildren, vm;
5185
5285
  const vnode = {
5186
5286
  type: 3
5187
5287
  /* CustomElement */
@@ -5191,11 +5291,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
5191
5291
  children,
5192
5292
  elm,
5193
5293
  key,
5194
- hook: CustomElementHook,
5195
5294
  ctor: Ctor,
5196
5295
  owner: vmBeingRendered,
5197
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5198
-
5296
+ mode: 'open',
5297
+ aChildren,
5298
+ vm
5199
5299
  };
5200
5300
  addVNodeToChildLWC(vnode);
5201
5301
  return vnode;
@@ -5325,7 +5425,6 @@ function t(text) {
5325
5425
  text,
5326
5426
  elm,
5327
5427
  key,
5328
- hook: TextHook,
5329
5428
  owner: getVMBeingRendered()
5330
5429
  };
5331
5430
  } // [co]mment node
@@ -5341,7 +5440,6 @@ function co(text) {
5341
5440
  text,
5342
5441
  elm,
5343
5442
  key,
5344
- hook: CommentHook,
5345
5443
  owner: getVMBeingRendered()
5346
5444
  };
5347
5445
  } // [d]ynamic text
@@ -6156,6 +6254,10 @@ const signedTemplateMap = new Map();
6156
6254
  function registerComponent(Ctor, {
6157
6255
  tmpl
6158
6256
  }) {
6257
+ if (process.env.NODE_ENV !== 'production') {
6258
+ checkVersionMismatch(Ctor, 'component');
6259
+ }
6260
+
6159
6261
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6160
6262
  // without too much transformation
6161
6263
 
@@ -6477,7 +6579,11 @@ function computeShadowMode(vm) {
6477
6579
  /* Native */
6478
6580
  ;
6479
6581
  } else if (isNativeShadowDefined$1) {
6480
- if (def.shadowSupportMode === "any"
6582
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
6583
+ shadowMode = 1
6584
+ /* Synthetic */
6585
+ ;
6586
+ } else if (def.shadowSupportMode === "any"
6481
6587
  /* Any */
6482
6588
  ) {
6483
6589
  shadowMode = 0
@@ -6576,7 +6682,7 @@ function patchShadowRoot(vm, newCh) {
6576
6682
  , vm);
6577
6683
  }, () => {
6578
6684
  // job
6579
- patchChildren(renderRoot, oldCh, newCh);
6685
+ patchChildren(oldCh, newCh, renderRoot);
6580
6686
  }, () => {
6581
6687
  // post
6582
6688
  logOperationEnd(2
@@ -7305,7 +7411,7 @@ function setHooks(hooks) {
7305
7411
  hooksAreSet = true;
7306
7412
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7307
7413
  }
7308
- /* version: 2.9.0 */
7414
+ /* version: 2.10.0 */
7309
7415
 
7310
7416
  /*
7311
7417
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7845,6 +7951,6 @@ function renderComponent(tagName, Ctor, props = {}) {
7845
7951
 
7846
7952
  freeze(LightningElement);
7847
7953
  seal(LightningElement.prototype);
7848
- /* version: 2.9.0 */
7954
+ /* version: 2.10.0 */
7849
7955
 
7850
7956
  export { LightningElement, api$1 as api, createContextProvider, getComponentDef, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };