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
@@ -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.9.0 */
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.9.0 */
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;
4467
4479
 
4480
+ case 1
4481
+ /* Comment */
4482
+ :
4483
+ mountComment(node, parent, anchor);
4484
+ break;
4485
+
4486
+ case 2
4487
+ /* Element */
4488
+ :
4489
+ mountElement(node, parent, anchor);
4490
+ break;
4491
+
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
+ }
4468
4516
 
4469
- rerenderVM(vm);
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
+ }
4558
+
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;
4482
4580
 
4483
- runConnectedCallback(vm);
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
4487
4618
 
4488
- if (vm) {
4489
- appendVM(vm);
4619
+
4620
+ patchChildren(n1.children, n2.children, elm);
4621
+
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
+ }
4649
+
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
+ }
4496
4672
 
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);
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();
@@ -4654,14 +4830,6 @@ function fallbackElmHook(elm, vnode) {
4654
4830
  }
4655
4831
  }
4656
4832
 
4657
- function patchChildren(parent, oldCh, newCh) {
4658
- if (hasDynamicChildren(newCh)) {
4659
- updateDynamicChildren(parent, oldCh, newCh);
4660
- } else {
4661
- updateStaticChildren(parent, oldCh, newCh);
4662
- }
4663
- }
4664
-
4665
4833
  function allocateChildren(vnode, vm) {
4666
4834
  // A component with slots will re-render because:
4667
4835
  // 1- There is a change of the internal state.
@@ -4737,40 +4905,6 @@ function createViewModelHook(elm, vnode) {
4737
4905
  return vm;
4738
4906
  }
4739
4907
 
4740
- function createChildrenHook(vnode) {
4741
- const {
4742
- elm,
4743
- children
4744
- } = vnode;
4745
-
4746
- for (let j = 0; j < children.length; ++j) {
4747
- const ch = children[j];
4748
-
4749
- if (ch != null) {
4750
- ch.hook.create(ch);
4751
- ch.hook.insert(ch, elm, null);
4752
- }
4753
- }
4754
- }
4755
-
4756
- function removeChildren(vnode) {
4757
- // this method only needs to search on child vnodes from template
4758
- // to trigger the remove hook just in case some of those children
4759
- // are custom elements.
4760
- const {
4761
- children,
4762
- elm
4763
- } = vnode;
4764
-
4765
- for (let j = 0, len = children.length; j < len; ++j) {
4766
- const ch = children[j];
4767
-
4768
- if (!isNull(ch)) {
4769
- ch.hook.remove(ch, elm);
4770
- }
4771
- }
4772
- }
4773
-
4774
4908
  function allocateInSlot(vm, children) {
4775
4909
  var _a;
4776
4910
 
@@ -4867,28 +5001,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
4867
5001
  return map;
4868
5002
  }
4869
5003
 
4870
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
4871
- for (; startIdx <= endIdx; ++startIdx) {
4872
- const ch = vnodes[startIdx];
4873
-
4874
- if (isVNode(ch)) {
4875
- ch.hook.create(ch);
4876
- ch.hook.insert(ch, parentElm, before);
4877
- }
4878
- }
4879
- }
4880
-
4881
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
4882
- for (; startIdx <= endIdx; ++startIdx) {
4883
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
4884
-
4885
- if (isVNode(ch)) {
4886
- ch.hook.remove(ch, parentElm);
4887
- }
4888
- }
4889
- }
4890
-
4891
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5004
+ function updateDynamicChildren(oldCh, newCh, parent) {
4892
5005
  let oldStartIdx = 0;
4893
5006
  let newStartIdx = 0;
4894
5007
  let oldEndIdx = oldCh.length - 1;
@@ -4914,23 +5027,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4914
5027
  } else if (!isVNode(newEndVnode)) {
4915
5028
  newEndVnode = newCh[--newEndIdx];
4916
5029
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4917
- patchVnode(oldStartVnode, newStartVnode);
5030
+ patch(oldStartVnode, newStartVnode);
4918
5031
  oldStartVnode = oldCh[++oldStartIdx];
4919
5032
  newStartVnode = newCh[++newStartIdx];
4920
5033
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4921
- patchVnode(oldEndVnode, newEndVnode);
5034
+ patch(oldEndVnode, newEndVnode);
4922
5035
  oldEndVnode = oldCh[--oldEndIdx];
4923
5036
  newEndVnode = newCh[--newEndIdx];
4924
5037
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4925
5038
  // Vnode moved right
4926
- patchVnode(oldStartVnode, newEndVnode);
4927
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5039
+ patch(oldStartVnode, newEndVnode);
5040
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
4928
5041
  oldStartVnode = oldCh[++oldStartIdx];
4929
5042
  newEndVnode = newCh[--newEndIdx];
4930
5043
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4931
5044
  // Vnode moved left
4932
- patchVnode(oldEndVnode, newStartVnode);
4933
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5045
+ patch(oldEndVnode, newStartVnode);
5046
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
4934
5047
  oldEndVnode = oldCh[--oldEndIdx];
4935
5048
  newStartVnode = newCh[++newStartIdx];
4936
5049
  } else {
@@ -4942,8 +5055,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4942
5055
 
4943
5056
  if (isUndefined$1(idxInOld)) {
4944
5057
  // New element
4945
- newStartVnode.hook.create(newStartVnode);
4946
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5058
+ mount(newStartVnode, parent, oldStartVnode.elm);
4947
5059
  newStartVnode = newCh[++newStartIdx];
4948
5060
  } else {
4949
5061
  elmToMove = oldCh[idxInOld];
@@ -4951,10 +5063,9 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4951
5063
  if (isVNode(elmToMove)) {
4952
5064
  if (elmToMove.sel !== newStartVnode.sel) {
4953
5065
  // New element
4954
- newStartVnode.hook.create(newStartVnode);
4955
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5066
+ mount(newStartVnode, parent, oldStartVnode.elm);
4956
5067
  } else {
4957
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5068
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
4958
5069
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4959
5070
  // so we only care about the `oldCh` object inside this function.
4960
5071
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -4967,7 +5078,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4967
5078
 
4968
5079
 
4969
5080
  oldCh[idxInOld] = undefined;
4970
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5081
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
4971
5082
  }
4972
5083
  }
4973
5084
 
@@ -4988,65 +5099,55 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
4988
5099
  } while (!isVNode(n) && i < newChEnd);
4989
5100
 
4990
5101
  before = isVNode(n) ? n.elm : null;
4991
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5102
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
4992
5103
  } else {
4993
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5104
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
4994
5105
  }
4995
5106
  }
4996
5107
  }
4997
5108
 
4998
- function updateStaticChildren(parentElm, oldCh, newCh) {
4999
- const oldChLength = oldCh.length;
5000
- const newChLength = newCh.length;
5109
+ function updateStaticChildren(c1, c2, parent) {
5110
+ const c1Length = c1.length;
5111
+ const c2Length = c2.length;
5001
5112
 
5002
- if (oldChLength === 0) {
5113
+ if (c1Length === 0) {
5003
5114
  // the old list is empty, we can directly insert anything new
5004
- addVnodes(parentElm, null, newCh, 0, newChLength);
5115
+ mountVNodes(c2, parent, null);
5005
5116
  return;
5006
5117
  }
5007
5118
 
5008
- if (newChLength === 0) {
5119
+ if (c2Length === 0) {
5009
5120
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5010
5121
  // this is the case in which the dynamic children of an if-directive should be removed
5011
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5122
+ unmountVNodes(c1, parent, true);
5012
5123
  return;
5013
5124
  } // if the old list is not empty, the new list MUST have the same
5014
5125
  // amount of nodes, that's why we call this static children
5015
5126
 
5016
5127
 
5017
- let referenceElm = null;
5128
+ let anchor = null;
5018
5129
 
5019
- for (let i = newChLength - 1; i >= 0; i -= 1) {
5020
- const vnode = newCh[i];
5021
- const oldVNode = oldCh[i];
5130
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
5131
+ const n1 = c1[i];
5132
+ const n2 = c2[i];
5022
5133
 
5023
- if (vnode !== oldVNode) {
5024
- if (isVNode(oldVNode)) {
5025
- if (isVNode(vnode)) {
5026
- // both vnodes must be equivalent, and se just need to patch them
5027
- patchVnode(oldVNode, vnode);
5028
- 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;
5029
5140
  } else {
5030
5141
  // removing the old vnode since the new one is null
5031
- oldVNode.hook.remove(oldVNode, parentElm);
5142
+ unmount(n1, parent, true);
5032
5143
  }
5033
- } else if (isVNode(vnode)) {
5034
- // this condition is unnecessary
5035
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5036
-
5037
- vnode.hook.insert(vnode, parentElm, referenceElm);
5038
- referenceElm = vnode.elm;
5144
+ } else if (isVNode(n2)) {
5145
+ mount(n2, parent, anchor);
5146
+ anchor = n2.elm;
5039
5147
  }
5040
5148
  }
5041
5149
  }
5042
5150
  }
5043
-
5044
- function patchVnode(oldVnode, vnode) {
5045
- if (oldVnode !== vnode) {
5046
- vnode.elm = oldVnode.elm;
5047
- vnode.hook.update(oldVnode, vnode);
5048
- }
5049
- }
5050
5151
  /*
5051
5152
  * Copyright (c) 2018, salesforce.com, inc.
5052
5153
  * All rights reserved.
@@ -5098,7 +5199,6 @@ function h(sel, data, children = EmptyArray) {
5098
5199
  children,
5099
5200
  elm,
5100
5201
  key,
5101
- hook: ElementHook,
5102
5202
  owner: vmBeingRendered
5103
5203
  };
5104
5204
  } // [t]ab[i]ndex function
@@ -5185,7 +5285,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
5185
5285
  const {
5186
5286
  key
5187
5287
  } = data;
5188
- let elm;
5288
+ let elm, aChildren, vm;
5189
5289
  const vnode = {
5190
5290
  type: 3
5191
5291
  /* CustomElement */
@@ -5195,11 +5295,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
5195
5295
  children,
5196
5296
  elm,
5197
5297
  key,
5198
- hook: CustomElementHook,
5199
5298
  ctor: Ctor,
5200
5299
  owner: vmBeingRendered,
5201
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5202
-
5300
+ mode: 'open',
5301
+ aChildren,
5302
+ vm
5203
5303
  };
5204
5304
  addVNodeToChildLWC(vnode);
5205
5305
  return vnode;
@@ -5329,7 +5429,6 @@ function t(text) {
5329
5429
  text,
5330
5430
  elm,
5331
5431
  key,
5332
- hook: TextHook,
5333
5432
  owner: getVMBeingRendered()
5334
5433
  };
5335
5434
  } // [co]mment node
@@ -5345,7 +5444,6 @@ function co(text) {
5345
5444
  text,
5346
5445
  elm,
5347
5446
  key,
5348
- hook: CommentHook,
5349
5447
  owner: getVMBeingRendered()
5350
5448
  };
5351
5449
  } // [d]ynamic text
@@ -6160,6 +6258,10 @@ const signedTemplateMap = new Map();
6160
6258
  function registerComponent(Ctor, {
6161
6259
  tmpl
6162
6260
  }) {
6261
+ if (process.env.NODE_ENV !== 'production') {
6262
+ checkVersionMismatch(Ctor, 'component');
6263
+ }
6264
+
6163
6265
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6164
6266
  // without too much transformation
6165
6267
 
@@ -6481,7 +6583,11 @@ function computeShadowMode(vm) {
6481
6583
  /* Native */
6482
6584
  ;
6483
6585
  } else if (isNativeShadowDefined$1) {
6484
- if (def.shadowSupportMode === "any"
6586
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
6587
+ shadowMode = 1
6588
+ /* Synthetic */
6589
+ ;
6590
+ } else if (def.shadowSupportMode === "any"
6485
6591
  /* Any */
6486
6592
  ) {
6487
6593
  shadowMode = 0
@@ -6580,7 +6686,7 @@ function patchShadowRoot(vm, newCh) {
6580
6686
  , vm);
6581
6687
  }, () => {
6582
6688
  // job
6583
- patchChildren(renderRoot, oldCh, newCh);
6689
+ patchChildren(oldCh, newCh, renderRoot);
6584
6690
  }, () => {
6585
6691
  // post
6586
6692
  logOperationEnd(2
@@ -7309,7 +7415,7 @@ function setHooks(hooks) {
7309
7415
  hooksAreSet = true;
7310
7416
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7311
7417
  }
7312
- /* version: 2.9.0 */
7418
+ /* version: 2.10.0 */
7313
7419
 
7314
7420
  /*
7315
7421
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7849,7 +7955,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7849
7955
 
7850
7956
  freeze(LightningElement);
7851
7957
  seal(LightningElement.prototype);
7852
- /* version: 2.9.0 */
7958
+ /* version: 2.10.0 */
7853
7959
 
7854
7960
  exports.LightningElement = LightningElement;
7855
7961
  exports.api = api$1;