lwc 2.22.0 → 2.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +1222 -947
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1222 -946
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1129 -882
  5. package/dist/engine-dom/iife/es5/engine-dom.js +524 -499
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +475 -457
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1222 -946
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1129 -882
  11. package/dist/engine-dom/umd/es5/engine-dom.js +524 -499
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +475 -457
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +809 -626
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +809 -626
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +30 -27
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +30 -27
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +29 -26
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +32 -31
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +31 -30
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +30 -27
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +29 -26
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +32 -31
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +31 -30
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -313,24 +313,36 @@ function isBooleanAttribute(attrName, tagName) {
313
313
  return (allowedTagNames !== undefined &&
314
314
  (allowedTagNames.size === 0 || allowedTagNames.has(tagName)));
315
315
  }
316
+ // This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
316
317
  const GLOBAL_ATTRIBUTE = new Set([
317
- 'role',
318
318
  'accesskey',
319
+ 'autocapitalize',
320
+ 'autofocus',
319
321
  'class',
320
322
  'contenteditable',
321
323
  'contextmenu',
322
324
  'dir',
323
325
  'draggable',
324
- 'dropzone',
326
+ 'enterkeyhint',
327
+ 'exportparts',
325
328
  'hidden',
326
329
  'id',
330
+ 'inputmode',
331
+ 'is',
332
+ 'itemid',
327
333
  'itemprop',
334
+ 'itemref',
335
+ 'itemscope',
336
+ 'itemtype',
328
337
  'lang',
338
+ 'nonce',
339
+ 'part',
329
340
  'slot',
330
341
  'spellcheck',
331
342
  'style',
332
343
  'tabindex',
333
344
  'title',
345
+ 'translate',
334
346
  ]);
335
347
  function isGlobalHtmlAttribute(attrName) {
336
348
  return GLOBAL_ATTRIBUTE.has(attrName);
@@ -415,9 +427,9 @@ function htmlEscape(str, attrMode = false) {
415
427
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
416
428
  */
417
429
  // Increment whenever the LWC template compiler changes
418
- const LWC_VERSION = "2.22.0";
430
+ const LWC_VERSION = "2.23.2";
419
431
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
420
- /** version: 2.22.0 */
432
+ /** version: 2.23.2 */
421
433
 
422
434
  /*
423
435
  * Copyright (c) 2020, salesforce.com, inc.
@@ -469,6 +481,7 @@ const features = {
469
481
  ENABLE_HTML_COLLECTIONS_PATCH: null,
470
482
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
471
483
  ENABLE_MIXED_SHADOW_MODE: null,
484
+ ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
472
485
  ENABLE_NODE_LIST_PATCH: null,
473
486
  ENABLE_NODE_PATCH: null,
474
487
  ENABLE_REACTIVE_SETTER: null,
@@ -477,7 +490,7 @@ const features = {
477
490
  if (!_globalThis.lwcRuntimeFlags) {
478
491
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
479
492
  }
480
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
493
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
481
494
  /**
482
495
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
483
496
  * flag. It is meant to be used during the app initialization.
@@ -504,17 +517,17 @@ function setFeatureFlag(name, value) {
504
517
  }
505
518
  if (process.env.NODE_ENV !== 'production') {
506
519
  // Allow the same flag to be set more than once outside of production to enable testing
507
- runtimeFlags[name] = value;
520
+ lwcRuntimeFlags[name] = value;
508
521
  }
509
522
  else {
510
523
  // Disallow the same flag to be set more than once in production
511
- const runtimeValue = runtimeFlags[name];
524
+ const runtimeValue = lwcRuntimeFlags[name];
512
525
  if (!isUndefined$1(runtimeValue)) {
513
526
  // eslint-disable-next-line no-console
514
527
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
515
528
  return;
516
529
  }
517
- defineProperty(runtimeFlags, name, { value });
530
+ defineProperty(lwcRuntimeFlags, name, { value });
518
531
  }
519
532
  }
520
533
  /**
@@ -526,7 +539,7 @@ function setFeatureFlagForTest(name, value) {
526
539
  setFeatureFlag(name, value);
527
540
  }
528
541
  }
529
- /** version: 2.22.0 */
542
+ /** version: 2.23.2 */
530
543
 
531
544
  /* proxy-compat-disable */
532
545
 
@@ -542,7 +555,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
542
555
  window.addEventListener('test-dummy-flag', () => {
543
556
  let hasFlag = false;
544
557
 
545
- if (runtimeFlags.DUMMY_TEST_FLAG) {
558
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
546
559
  hasFlag = true;
547
560
  }
548
561
 
@@ -1175,6 +1188,13 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1175
1188
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1176
1189
  }
1177
1190
 
1191
+ function updateComponentValue(vm, key, newValue) {
1192
+ const { cmpFields } = vm;
1193
+ if (newValue !== cmpFields[key]) {
1194
+ cmpFields[key] = newValue;
1195
+ }
1196
+ }
1197
+
1178
1198
  /**
1179
1199
  * Copyright (C) 2017 salesforce.com, inc.
1180
1200
  */
@@ -1799,9 +1819,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1799
1819
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1800
1820
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1801
1821
  }
1802
- if (newValue !== vm.cmpProps[propName]) {
1803
- vm.cmpProps[propName] = newValue;
1804
- }
1822
+ updateComponentValue(vm, propName, newValue);
1805
1823
  return set.call(vm.elm, newValue);
1806
1824
  },
1807
1825
  };
@@ -2094,9 +2112,7 @@ function createObservedFieldPropertyDescriptor(key) {
2094
2112
  },
2095
2113
  set(newValue) {
2096
2114
  const vm = getAssociatedVM(this);
2097
- if (newValue !== vm.cmpFields[key]) {
2098
- vm.cmpFields[key] = newValue;
2099
- }
2115
+ updateComponentValue(vm, key, newValue);
2100
2116
  },
2101
2117
  enumerable: true,
2102
2118
  configurable: true,
@@ -2201,7 +2217,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2201
2217
  }
2202
2218
 
2203
2219
  if (set) {
2204
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2220
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2205
2221
  let ro = vm.oar[key];
2206
2222
 
2207
2223
  if (isUndefined$1(ro)) {
@@ -2258,9 +2274,7 @@ function internalTrackDecorator(key) {
2258
2274
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2259
2275
  }
2260
2276
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2261
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2262
- vm.cmpFields[key] = reactiveOrAnyValue;
2263
- }
2277
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2264
2278
  },
2265
2279
  enumerable: true,
2266
2280
  configurable: true,
@@ -2298,9 +2312,7 @@ function internalWireFieldDecorator(key) {
2298
2312
  * letting the author to do the wrong thing, but it will keep our
2299
2313
  * system to be backward compatible.
2300
2314
  */
2301
- if (value !== vm.cmpFields[key]) {
2302
- vm.cmpFields[key] = value;
2303
- }
2315
+ updateComponentValue(vm, key, value);
2304
2316
  },
2305
2317
  enumerable: true,
2306
2318
  configurable: true,
@@ -2784,7 +2796,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2784
2796
  throw new ReferenceError();
2785
2797
  }
2786
2798
 
2787
- if (runtimeFlags.ENABLE_HMR) {
2799
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2788
2800
  const visited = new Set();
2789
2801
 
2790
2802
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2801,7 +2813,7 @@ function getComponentOrSwappedComponent(Ctor) {
2801
2813
  throw new ReferenceError();
2802
2814
  }
2803
2815
 
2804
- if (runtimeFlags.ENABLE_HMR) {
2816
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2805
2817
  const visited = new Set();
2806
2818
 
2807
2819
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -2818,7 +2830,7 @@ function getStyleOrSwappedStyle(style) {
2818
2830
  throw new ReferenceError();
2819
2831
  }
2820
2832
 
2821
- if (runtimeFlags.ENABLE_HMR) {
2833
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2822
2834
  const visited = new Set();
2823
2835
 
2824
2836
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -2835,7 +2847,7 @@ function setActiveVM(vm) {
2835
2847
  throw new ReferenceError();
2836
2848
  }
2837
2849
 
2838
- if (runtimeFlags.ENABLE_HMR) {
2850
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2839
2851
  // tracking active component
2840
2852
  const Ctor = vm.def.ctor;
2841
2853
  let componentVMs = activeComponents.get(Ctor);
@@ -2892,7 +2904,7 @@ function removeActiveVM(vm) {
2892
2904
  throw new ReferenceError();
2893
2905
  }
2894
2906
 
2895
- if (runtimeFlags.ENABLE_HMR) {
2907
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2896
2908
  // tracking inactive component
2897
2909
  const Ctor = vm.def.ctor;
2898
2910
  let list = activeComponents.get(Ctor);
@@ -3258,38 +3270,20 @@ function getScopeTokenClass(owner) {
3258
3270
  const { cmpTemplate, context } = owner;
3259
3271
  return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
3260
3272
  }
3261
- function getNearestNativeShadowComponent(vm) {
3262
- const owner = getNearestShadowComponent(vm);
3263
- if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3264
- // Synthetic-within-native is impossible. So if the nearest shadow component is
3265
- // synthetic, we know we won't find a native component if we go any further.
3266
- return null;
3267
- }
3268
- return owner;
3269
- }
3270
3273
  function createStylesheet(vm, stylesheets) {
3271
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3274
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3272
3275
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3273
3276
  for (let i = 0; i < stylesheets.length; i++) {
3274
3277
  insertStylesheet(stylesheets[i]);
3275
3278
  }
3276
3279
  }
3277
- else if (ssr || vm.hydrated) {
3280
+ else {
3278
3281
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3279
3282
  // This works in the client, because the stylesheets are created, and cached in the VM
3280
3283
  // the first time the VM renders.
3281
3284
  // native shadow or light DOM, SSR
3282
3285
  return ArrayMap.call(stylesheets, createInlineStyleVNode);
3283
3286
  }
3284
- else {
3285
- // native shadow or light DOM, DOM renderer
3286
- const root = getNearestNativeShadowComponent(vm);
3287
- // null root means a global style
3288
- const target = isNull(root) ? undefined : root.shadowRoot;
3289
- for (let i = 0; i < stylesheets.length; i++) {
3290
- insertStylesheet(stylesheets[i], target);
3291
- }
3292
- }
3293
3287
  return null;
3294
3288
  }
3295
3289
 
@@ -3299,30 +3293,67 @@ function createStylesheet(vm, stylesheets) {
3299
3293
  * SPDX-License-Identifier: MIT
3300
3294
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3301
3295
  */
3296
+
3297
+ function checkHasVM(elm) {
3298
+ const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
3299
+
3300
+ if (process.env.NODE_ENV !== 'production' && !hasVM) {
3301
+ // Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
3302
+ // we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
3303
+ logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
3304
+ }
3305
+
3306
+ return hasVM;
3307
+ }
3308
+
3302
3309
  function getUpgradableConstructor(tagName, renderer) {
3303
- const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
3304
- // Should never get a tag with upper case letter at this point, the compiler should
3305
- // produce only tags with lowercase letters
3306
- // But, for backwards compatibility, we will lower case the tagName
3307
- tagName = tagName.toLowerCase();
3308
- let CE = getCustomElement(tagName);
3309
- if (!isUndefined$1(CE)) {
3310
- return CE;
3310
+ const {
3311
+ getCustomElement,
3312
+ HTMLElementExported: RendererHTMLElement,
3313
+ defineCustomElement
3314
+ } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
3315
+ // produce only tags with lowercase letters
3316
+ // But, for backwards compatibility, we will lower case the tagName
3317
+
3318
+ tagName = tagName.toLowerCase();
3319
+ let CE = getCustomElement(tagName);
3320
+
3321
+ if (!isUndefined$1(CE)) {
3322
+ return CE;
3323
+ }
3324
+ /**
3325
+ * LWC Upgradable Element reference to an element that was created
3326
+ * via the scoped registry mechanism, and that is ready to be upgraded.
3327
+ */
3328
+
3329
+
3330
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
3331
+ constructor(upgradeCallback) {
3332
+ super();
3333
+
3334
+ if (isFunction$1(upgradeCallback)) {
3335
+ upgradeCallback(this); // nothing to do with the result for now
3336
+ }
3311
3337
  }
3312
- /**
3313
- * LWC Upgradable Element reference to an element that was created
3314
- * via the scoped registry mechanism, and that is ready to be upgraded.
3315
- */
3316
- CE = class LWCUpgradableElement extends RendererHTMLElement {
3317
- constructor(upgradeCallback) {
3318
- super();
3319
- if (isFunction$1(upgradeCallback)) {
3320
- upgradeCallback(this); // nothing to do with the result for now
3321
- }
3322
- }
3338
+
3339
+ };
3340
+
3341
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
3342
+ CE.prototype.connectedCallback = function () {
3343
+ if (checkHasVM(this)) {
3344
+ connectRootElement(this);
3345
+ }
3323
3346
  };
3324
- defineCustomElement(tagName, CE);
3325
- return CE;
3347
+
3348
+ CE.prototype.disconnectedCallback = function () {
3349
+ if (checkHasVM(this)) {
3350
+ disconnectRootElement(this);
3351
+ }
3352
+ };
3353
+ }
3354
+
3355
+ defineCustomElement(tagName, CE);
3356
+ return CE;
3326
3357
  }
3327
3358
 
3328
3359
  /*
@@ -3568,569 +3599,790 @@ function applyStaticStyleAttribute(vnode, renderer) {
3568
3599
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3569
3600
  */
3570
3601
  function patchChildren(c1, c2, parent, renderer) {
3571
- if (hasDynamicChildren(c2)) {
3572
- updateDynamicChildren(c1, c2, parent, renderer);
3573
- }
3574
- else {
3575
- updateStaticChildren(c1, c2, parent, renderer);
3576
- }
3602
+ if (hasDynamicChildren(c2)) {
3603
+ updateDynamicChildren(c1, c2, parent, renderer);
3604
+ } else {
3605
+ updateStaticChildren(c1, c2, parent, renderer);
3606
+ }
3577
3607
  }
3578
- function patch(n1, n2, renderer) {
3579
- var _a, _b;
3580
- if (n1 === n2) {
3581
- return;
3582
- }
3583
- if (process.env.NODE_ENV !== 'production') {
3584
- if (!isSameVnode(n1, n2)) {
3585
- throw new Error('Expected these VNodes to be the same: ' +
3586
- JSON.stringify({ sel: n1.sel, key: n1.key }) +
3587
- ', ' +
3588
- JSON.stringify({ sel: n2.sel, key: n2.key }));
3589
- }
3590
- }
3591
- switch (n2.type) {
3592
- case 0 /* VNodeType.Text */:
3593
- // VText has no special capability, fallback to the owner's renderer
3594
- patchText(n1, n2, renderer);
3595
- break;
3596
- case 1 /* VNodeType.Comment */:
3597
- // VComment has no special capability, fallback to the owner's renderer
3598
- patchComment(n1, n2, renderer);
3599
- break;
3600
- case 4 /* VNodeType.Static */:
3601
- n2.elm = n1.elm;
3602
- break;
3603
- case 2 /* VNodeType.Element */:
3604
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3605
- break;
3606
- case 3 /* VNodeType.CustomElement */:
3607
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3608
- break;
3608
+
3609
+ function patch(n1, n2, parent, renderer) {
3610
+ var _a, _b;
3611
+
3612
+ if (n1 === n2) {
3613
+ return;
3614
+ }
3615
+
3616
+ if (process.env.NODE_ENV !== 'production') {
3617
+ if (!isSameVnode(n1, n2)) {
3618
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
3619
+ sel: n1.sel,
3620
+ key: n1.key
3621
+ }) + ', ' + JSON.stringify({
3622
+ sel: n2.sel,
3623
+ key: n2.key
3624
+ }));
3609
3625
  }
3626
+ }
3627
+
3628
+ switch (n2.type) {
3629
+ case 0
3630
+ /* VNodeType.Text */
3631
+ :
3632
+ // VText has no special capability, fallback to the owner's renderer
3633
+ patchText(n1, n2, renderer);
3634
+ break;
3635
+
3636
+ case 1
3637
+ /* VNodeType.Comment */
3638
+ :
3639
+ // VComment has no special capability, fallback to the owner's renderer
3640
+ patchComment(n1, n2, renderer);
3641
+ break;
3642
+
3643
+ case 4
3644
+ /* VNodeType.Static */
3645
+ :
3646
+ n2.elm = n1.elm;
3647
+ break;
3648
+
3649
+ case 2
3650
+ /* VNodeType.Element */
3651
+ :
3652
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3653
+ break;
3654
+
3655
+ case 3
3656
+ /* VNodeType.CustomElement */
3657
+ :
3658
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3659
+ break;
3660
+ }
3610
3661
  }
3662
+
3611
3663
  function mount(node, parent, renderer, anchor) {
3612
- var _a, _b;
3613
- switch (node.type) {
3614
- case 0 /* VNodeType.Text */:
3615
- // VText has no special capability, fallback to the owner's renderer
3616
- mountText(node, parent, anchor, renderer);
3617
- break;
3618
- case 1 /* VNodeType.Comment */:
3619
- // VComment has no special capability, fallback to the owner's renderer
3620
- mountComment(node, parent, anchor, renderer);
3621
- break;
3622
- case 4 /* VNodeType.Static */:
3623
- // VStatic cannot have a custom renderer associated to them, using owner's renderer
3624
- mountStatic(node, parent, anchor, renderer);
3625
- break;
3626
- case 2 /* VNodeType.Element */:
3627
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3628
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3629
- break;
3630
- case 3 /* VNodeType.CustomElement */:
3631
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
3632
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3633
- break;
3634
- }
3664
+ var _a, _b;
3665
+
3666
+ switch (node.type) {
3667
+ case 0
3668
+ /* VNodeType.Text */
3669
+ :
3670
+ // VText has no special capability, fallback to the owner's renderer
3671
+ mountText(node, parent, anchor, renderer);
3672
+ break;
3673
+
3674
+ case 1
3675
+ /* VNodeType.Comment */
3676
+ :
3677
+ // VComment has no special capability, fallback to the owner's renderer
3678
+ mountComment(node, parent, anchor, renderer);
3679
+ break;
3680
+
3681
+ case 4
3682
+ /* VNodeType.Static */
3683
+ :
3684
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
3685
+ mountStatic(node, parent, anchor, renderer);
3686
+ break;
3687
+
3688
+ case 2
3689
+ /* VNodeType.Element */
3690
+ :
3691
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3692
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3693
+ break;
3694
+
3695
+ case 3
3696
+ /* VNodeType.CustomElement */
3697
+ :
3698
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
3699
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3700
+ break;
3701
+ }
3635
3702
  }
3703
+
3636
3704
  function patchText(n1, n2, renderer) {
3637
- n2.elm = n1.elm;
3638
- if (n2.text !== n1.text) {
3639
- updateTextContent(n2, renderer);
3640
- }
3705
+ n2.elm = n1.elm;
3706
+
3707
+ if (n2.text !== n1.text) {
3708
+ updateTextContent(n2, renderer);
3709
+ }
3641
3710
  }
3711
+
3642
3712
  function mountText(vnode, parent, anchor, renderer) {
3643
- const { owner } = vnode;
3644
- const { createText } = renderer;
3645
- const textNode = (vnode.elm = createText(vnode.text));
3646
- linkNodeToShadow(textNode, owner, renderer);
3647
- insertNode(textNode, parent, anchor, renderer);
3713
+ const {
3714
+ owner
3715
+ } = vnode;
3716
+ const {
3717
+ createText
3718
+ } = renderer;
3719
+ const textNode = vnode.elm = createText(vnode.text);
3720
+ linkNodeToShadow(textNode, owner, renderer);
3721
+ insertNode(textNode, parent, anchor, renderer);
3648
3722
  }
3723
+
3649
3724
  function patchComment(n1, n2, renderer) {
3650
- n2.elm = n1.elm;
3651
- // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3652
- // it is the case today.
3653
- if (n2.text !== n1.text) {
3654
- updateTextContent(n2, renderer);
3655
- }
3725
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3726
+ // it is the case today.
3727
+
3728
+ if (n2.text !== n1.text) {
3729
+ updateTextContent(n2, renderer);
3730
+ }
3656
3731
  }
3732
+
3657
3733
  function mountComment(vnode, parent, anchor, renderer) {
3658
- const { owner } = vnode;
3659
- const { createComment } = renderer;
3660
- const commentNode = (vnode.elm = createComment(vnode.text));
3661
- linkNodeToShadow(commentNode, owner, renderer);
3662
- insertNode(commentNode, parent, anchor, renderer);
3734
+ const {
3735
+ owner
3736
+ } = vnode;
3737
+ const {
3738
+ createComment
3739
+ } = renderer;
3740
+ const commentNode = vnode.elm = createComment(vnode.text);
3741
+ linkNodeToShadow(commentNode, owner, renderer);
3742
+ insertNode(commentNode, parent, anchor, renderer);
3663
3743
  }
3744
+
3664
3745
  function mountElement(vnode, parent, anchor, renderer) {
3665
- const { sel, owner, data: { svg }, } = vnode;
3666
- const { createElement } = renderer;
3667
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3668
- const elm = (vnode.elm = createElement(sel, namespace));
3669
- linkNodeToShadow(elm, owner, renderer);
3670
- applyStyleScoping(elm, owner, renderer);
3671
- applyDomManual(elm, vnode);
3672
- applyElementRestrictions(elm, vnode);
3673
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3674
- insertNode(elm, parent, anchor, renderer);
3675
- mountVNodes(vnode.children, elm, renderer, null);
3746
+ const {
3747
+ sel,
3748
+ owner,
3749
+ data: {
3750
+ svg
3751
+ }
3752
+ } = vnode;
3753
+ const {
3754
+ createElement
3755
+ } = renderer;
3756
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3757
+ const elm = vnode.elm = createElement(sel, namespace);
3758
+ linkNodeToShadow(elm, owner, renderer);
3759
+ applyStyleScoping(elm, owner, renderer);
3760
+ applyDomManual(elm, vnode);
3761
+ applyElementRestrictions(elm, vnode);
3762
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3763
+ insertNode(elm, parent, anchor, renderer);
3764
+ mountVNodes(vnode.children, elm, renderer, null);
3676
3765
  }
3766
+
3677
3767
  function patchElement(n1, n2, renderer) {
3678
- const elm = (n2.elm = n1.elm);
3679
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3680
- patchChildren(n1.children, n2.children, elm, renderer);
3768
+ const elm = n2.elm = n1.elm;
3769
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3770
+ patchChildren(n1.children, n2.children, elm, renderer);
3681
3771
  }
3772
+
3682
3773
  function mountStatic(vnode, parent, anchor, renderer) {
3683
- const { owner } = vnode;
3684
- const { cloneNode, isSyntheticShadowDefined } = renderer;
3685
- const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3686
- linkNodeToShadow(elm, owner, renderer);
3687
- applyElementRestrictions(elm, vnode);
3688
- // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3689
- const { renderMode, shadowMode } = owner;
3690
- if (isSyntheticShadowDefined) {
3691
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3692
- elm[KEY__SHADOW_STATIC] = true;
3693
- }
3774
+ const {
3775
+ owner
3776
+ } = vnode;
3777
+ const {
3778
+ cloneNode,
3779
+ isSyntheticShadowDefined
3780
+ } = renderer;
3781
+ const elm = vnode.elm = cloneNode(vnode.fragment, true);
3782
+ linkNodeToShadow(elm, owner, renderer);
3783
+ applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3784
+
3785
+ const {
3786
+ renderMode,
3787
+ shadowMode
3788
+ } = owner;
3789
+
3790
+ if (isSyntheticShadowDefined) {
3791
+ if (shadowMode === 1
3792
+ /* ShadowMode.Synthetic */
3793
+ || renderMode === 0
3794
+ /* RenderMode.Light */
3795
+ ) {
3796
+ elm[KEY__SHADOW_STATIC] = true;
3694
3797
  }
3695
- insertNode(elm, parent, anchor, renderer);
3798
+ }
3799
+
3800
+ insertNode(elm, parent, anchor, renderer);
3696
3801
  }
3802
+
3697
3803
  function mountCustomElement(vnode, parent, anchor, renderer) {
3698
- const { sel, owner } = vnode;
3699
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3700
- /**
3701
- * Note: if the upgradable constructor does not expect, or throw when we new it
3702
- * with a callback as the first argument, we could implement a more advanced
3703
- * mechanism that only passes that argument if the constructor is known to be
3704
- * an upgradable custom element.
3705
- */
3706
- let vm;
3707
- const elm = new UpgradableConstructor((elm) => {
3708
- // the custom element from the registry is expecting an upgrade callback
3709
- vm = createViewModelHook(elm, vnode, renderer);
3710
- });
3711
- vnode.elm = elm;
3712
- vnode.vm = vm;
3713
- linkNodeToShadow(elm, owner, renderer);
3714
- applyStyleScoping(elm, owner, renderer);
3715
- if (vm) {
3716
- allocateChildren(vnode, vm);
3717
- }
3718
- else if (vnode.ctor !== UpgradableConstructor) {
3719
- throw new TypeError(`Incorrect Component Constructor`);
3720
- }
3721
- patchElementPropsAndAttrs$1(null, vnode, renderer);
3722
- insertNode(elm, parent, anchor, renderer);
3723
- if (vm) {
3724
- if (process.env.NODE_ENV !== 'production') {
3725
- assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
3726
- }
3727
- runConnectedCallback(vm);
3728
- }
3729
- mountVNodes(vnode.children, elm, renderer, null);
3730
- if (vm) {
3731
- appendVM(vm);
3804
+ const {
3805
+ sel,
3806
+ owner
3807
+ } = vnode;
3808
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
3809
+ /**
3810
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3811
+ * with a callback as the first argument, we could implement a more advanced
3812
+ * mechanism that only passes that argument if the constructor is known to be
3813
+ * an upgradable custom element.
3814
+ */
3815
+
3816
+ let vm;
3817
+ const elm = new UpgradableConstructor(elm => {
3818
+ // the custom element from the registry is expecting an upgrade callback
3819
+ vm = createViewModelHook(elm, vnode, renderer);
3820
+ });
3821
+ vnode.elm = elm;
3822
+ vnode.vm = vm;
3823
+ linkNodeToShadow(elm, owner, renderer);
3824
+ applyStyleScoping(elm, owner, renderer);
3825
+
3826
+ if (vm) {
3827
+ allocateChildren(vnode, vm);
3828
+ } else if (vnode.ctor !== UpgradableConstructor) {
3829
+ throw new TypeError(`Incorrect Component Constructor`);
3830
+ }
3831
+
3832
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
3833
+ insertNode(elm, parent, anchor, renderer);
3834
+
3835
+ if (vm) {
3836
+ {
3837
+ // On the server, we don't have native custom element lifecycle callbacks, so we must
3838
+ // manually invoke the connectedCallback for a child component.
3839
+ runConnectedCallback(vm);
3732
3840
  }
3841
+ }
3842
+
3843
+ mountVNodes(vnode.children, elm, renderer, null);
3844
+
3845
+ if (vm) {
3846
+ appendVM(vm);
3847
+ }
3733
3848
  }
3734
- function patchCustomElement(n1, n2, renderer) {
3735
- const elm = (n2.elm = n1.elm);
3736
- const vm = (n2.vm = n1.vm);
3849
+
3850
+ function patchCustomElement(n1, n2, parent, renderer) {
3851
+ if (n1.ctor !== n2.ctor) {
3852
+ // If the constructor, unmount the current component and mount a new one using the new
3853
+ // constructor.
3854
+ const anchor = renderer.nextSibling(n1.elm);
3855
+ unmount(n1, parent, renderer, true);
3856
+ mountCustomElement(n2, parent, anchor, renderer);
3857
+ } else {
3858
+ // Otherwise patch the existing component with new props/attrs/etc.
3859
+ const elm = n2.elm = n1.elm;
3860
+ const vm = n2.vm = n1.vm;
3737
3861
  patchElementPropsAndAttrs$1(n1, n2, renderer);
3862
+
3738
3863
  if (!isUndefined$1(vm)) {
3739
- // in fallback mode, the allocation will always set children to
3740
- // empty and delegate the real allocation to the slot elements
3741
- allocateChildren(n2, vm);
3742
- }
3743
- // in fallback mode, the children will be always empty, so, nothing
3864
+ // in fallback mode, the allocation will always set children to
3865
+ // empty and delegate the real allocation to the slot elements
3866
+ allocateChildren(n2, vm);
3867
+ } // in fallback mode, the children will be always empty, so, nothing
3744
3868
  // will happen, but in native, it does allocate the light dom
3869
+
3870
+
3745
3871
  patchChildren(n1.children, n2.children, elm, renderer);
3872
+
3746
3873
  if (!isUndefined$1(vm)) {
3747
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3748
- // this is important to preserve the top to bottom synchronous rendering phase.
3749
- rerenderVM(vm);
3874
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3875
+ // this is important to preserve the top to bottom synchronous rendering phase.
3876
+ rerenderVM(vm);
3750
3877
  }
3878
+ }
3751
3879
  }
3880
+
3752
3881
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
3753
- for (; start < end; ++start) {
3754
- const vnode = vnodes[start];
3755
- if (isVNode(vnode)) {
3756
- mount(vnode, parent, renderer, anchor);
3757
- }
3882
+ for (; start < end; ++start) {
3883
+ const vnode = vnodes[start];
3884
+
3885
+ if (isVNode(vnode)) {
3886
+ mount(vnode, parent, renderer, anchor);
3758
3887
  }
3888
+ }
3759
3889
  }
3890
+
3760
3891
  function unmount(vnode, parent, renderer, doRemove = false) {
3761
- const { type, elm, sel } = vnode;
3762
- // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3763
- // subtree root, is the only element worth unmounting from the subtree.
3764
- if (doRemove) {
3765
- // The vnode might or might not have a data.renderer associated to it
3766
- // but the removal used here is from the owner instead.
3767
- removeNode(elm, parent, renderer);
3768
- }
3769
- switch (type) {
3770
- case 2 /* VNodeType.Element */: {
3771
- // Slot content is removed to trigger slotchange event when removing slot.
3772
- // Only required for synthetic shadow.
3773
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
3774
- unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3775
- break;
3776
- }
3777
- case 3 /* VNodeType.CustomElement */: {
3778
- const { vm } = vnode;
3779
- // No need to unmount the children here, `removeVM` will take care of removing the
3780
- // children.
3781
- if (!isUndefined$1(vm)) {
3782
- removeVM(vm);
3783
- }
3892
+ const {
3893
+ type,
3894
+ elm,
3895
+ sel
3896
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3897
+ // subtree root, is the only element worth unmounting from the subtree.
3898
+
3899
+ if (doRemove) {
3900
+ // The vnode might or might not have a data.renderer associated to it
3901
+ // but the removal used here is from the owner instead.
3902
+ removeNode(elm, parent, renderer);
3903
+ }
3904
+
3905
+ switch (type) {
3906
+ case 2
3907
+ /* VNodeType.Element */
3908
+ :
3909
+ {
3910
+ // Slot content is removed to trigger slotchange event when removing slot.
3911
+ // Only required for synthetic shadow.
3912
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
3913
+ /* ShadowMode.Synthetic */
3914
+ ;
3915
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3916
+ break;
3917
+ }
3918
+
3919
+ case 3
3920
+ /* VNodeType.CustomElement */
3921
+ :
3922
+ {
3923
+ const {
3924
+ vm
3925
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3926
+ // children.
3927
+
3928
+ if (!isUndefined$1(vm)) {
3929
+ removeVM(vm);
3784
3930
  }
3785
- }
3931
+ }
3932
+ }
3786
3933
  }
3934
+
3787
3935
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
3788
- for (; start < end; ++start) {
3789
- const ch = vnodes[start];
3790
- if (isVNode(ch)) {
3791
- unmount(ch, parent, renderer, doRemove);
3792
- }
3936
+ for (; start < end; ++start) {
3937
+ const ch = vnodes[start];
3938
+
3939
+ if (isVNode(ch)) {
3940
+ unmount(ch, parent, renderer, doRemove);
3793
3941
  }
3942
+ }
3794
3943
  }
3944
+
3795
3945
  function isVNode(vnode) {
3796
- return vnode != null;
3946
+ return vnode != null;
3797
3947
  }
3948
+
3798
3949
  function linkNodeToShadow(elm, owner, renderer) {
3799
- const { renderRoot, renderMode, shadowMode } = owner;
3800
- const { isSyntheticShadowDefined } = renderer;
3801
- // TODO [#1164]: this should eventually be done by the polyfill directly
3802
- if (isSyntheticShadowDefined) {
3803
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3804
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3805
- }
3950
+ const {
3951
+ renderRoot,
3952
+ renderMode,
3953
+ shadowMode
3954
+ } = owner;
3955
+ const {
3956
+ isSyntheticShadowDefined
3957
+ } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
3958
+
3959
+ if (isSyntheticShadowDefined) {
3960
+ if (shadowMode === 1
3961
+ /* ShadowMode.Synthetic */
3962
+ || renderMode === 0
3963
+ /* RenderMode.Light */
3964
+ ) {
3965
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3806
3966
  }
3967
+ }
3807
3968
  }
3969
+
3808
3970
  function updateTextContent(vnode, renderer) {
3809
- const { elm, text } = vnode;
3810
- const { setText } = renderer;
3811
- if (process.env.NODE_ENV !== 'production') {
3812
- unlockDomMutation();
3813
- }
3814
- setText(elm, text);
3815
- if (process.env.NODE_ENV !== 'production') {
3816
- lockDomMutation();
3817
- }
3971
+ const {
3972
+ elm,
3973
+ text
3974
+ } = vnode;
3975
+ const {
3976
+ setText
3977
+ } = renderer;
3978
+
3979
+ if (process.env.NODE_ENV !== 'production') {
3980
+ unlockDomMutation();
3981
+ }
3982
+
3983
+ setText(elm, text);
3984
+
3985
+ if (process.env.NODE_ENV !== 'production') {
3986
+ lockDomMutation();
3987
+ }
3818
3988
  }
3989
+
3819
3990
  function insertNode(node, parent, anchor, renderer) {
3820
- if (process.env.NODE_ENV !== 'production') {
3821
- unlockDomMutation();
3822
- }
3823
- renderer.insert(node, parent, anchor);
3824
- if (process.env.NODE_ENV !== 'production') {
3825
- lockDomMutation();
3826
- }
3991
+ if (process.env.NODE_ENV !== 'production') {
3992
+ unlockDomMutation();
3993
+ }
3994
+
3995
+ renderer.insert(node, parent, anchor);
3996
+
3997
+ if (process.env.NODE_ENV !== 'production') {
3998
+ lockDomMutation();
3999
+ }
3827
4000
  }
4001
+
3828
4002
  function removeNode(node, parent, renderer) {
3829
- if (process.env.NODE_ENV !== 'production') {
3830
- unlockDomMutation();
3831
- }
3832
- renderer.remove(node, parent);
3833
- if (process.env.NODE_ENV !== 'production') {
3834
- lockDomMutation();
3835
- }
4003
+ if (process.env.NODE_ENV !== 'production') {
4004
+ unlockDomMutation();
4005
+ }
4006
+
4007
+ renderer.remove(node, parent);
4008
+
4009
+ if (process.env.NODE_ENV !== 'production') {
4010
+ lockDomMutation();
4011
+ }
3836
4012
  }
4013
+
3837
4014
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3838
- if (isNull(oldVnode)) {
3839
- applyEventListeners(vnode, renderer);
3840
- applyStaticClassAttribute(vnode, renderer);
3841
- applyStaticStyleAttribute(vnode, renderer);
3842
- }
3843
- // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3844
- // value is set before type=radio.
3845
- patchClassAttribute(oldVnode, vnode, renderer);
3846
- patchStyleAttribute(oldVnode, vnode, renderer);
3847
- patchAttributes(oldVnode, vnode, renderer);
3848
- patchProps(oldVnode, vnode, renderer);
4015
+ if (isNull(oldVnode)) {
4016
+ applyEventListeners(vnode, renderer);
4017
+ applyStaticClassAttribute(vnode, renderer);
4018
+ applyStaticStyleAttribute(vnode, renderer);
4019
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4020
+ // value is set before type=radio.
4021
+
4022
+
4023
+ patchClassAttribute(oldVnode, vnode, renderer);
4024
+ patchStyleAttribute(oldVnode, vnode, renderer);
4025
+ patchAttributes(oldVnode, vnode, renderer);
4026
+ patchProps(oldVnode, vnode, renderer);
3849
4027
  }
4028
+
3850
4029
  function applyStyleScoping(elm, owner, renderer) {
3851
- // Set the class name for `*.scoped.css` style scoping.
3852
- const scopeToken = getScopeTokenClass(owner);
3853
- if (!isNull(scopeToken)) {
3854
- const { getClassList } = renderer;
3855
- // TODO [#2762]: this dot notation with add is probably problematic
3856
- // probably we should have a renderer api for just the add operation
3857
- getClassList(elm).add(scopeToken);
3858
- }
3859
- // Set property element for synthetic shadow DOM style scoping.
3860
- const { stylesheetToken: syntheticToken } = owner.context;
3861
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3862
- elm.$shadowToken$ = syntheticToken;
3863
- }
4030
+ // Set the class name for `*.scoped.css` style scoping.
4031
+ const scopeToken = getScopeTokenClass(owner);
4032
+
4033
+ if (!isNull(scopeToken)) {
4034
+ const {
4035
+ getClassList
4036
+ } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
4037
+ // probably we should have a renderer api for just the add operation
4038
+
4039
+ getClassList(elm).add(scopeToken);
4040
+ } // Set property element for synthetic shadow DOM style scoping.
4041
+
4042
+
4043
+ const {
4044
+ stylesheetToken: syntheticToken
4045
+ } = owner.context;
4046
+
4047
+ if (owner.shadowMode === 1
4048
+ /* ShadowMode.Synthetic */
4049
+ && !isUndefined$1(syntheticToken)) {
4050
+ elm.$shadowToken$ = syntheticToken;
4051
+ }
3864
4052
  }
4053
+
3865
4054
  function applyDomManual(elm, vnode) {
3866
- var _a;
3867
- const { owner, data: { context }, } = vnode;
3868
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
3869
- elm.$domManual$ = true;
4055
+ var _a;
4056
+
4057
+ const {
4058
+ owner,
4059
+ data: {
4060
+ context
3870
4061
  }
4062
+ } = vnode;
4063
+
4064
+ if (owner.shadowMode === 1
4065
+ /* ShadowMode.Synthetic */
4066
+ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
4067
+ /* LwcDomMode.Manual */
4068
+ ) {
4069
+ elm.$domManual$ = true;
4070
+ }
3871
4071
  }
4072
+
3872
4073
  function applyElementRestrictions(elm, vnode) {
3873
- var _a, _b;
3874
- if (process.env.NODE_ENV !== 'production') {
3875
- const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
3876
- const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
3877
- patchElementWithRestrictions(elm, {
3878
- isPortal,
3879
- isLight,
3880
- });
3881
- }
4074
+ var _a, _b;
4075
+
4076
+ if (process.env.NODE_ENV !== 'production') {
4077
+ const isPortal = vnode.type === 2
4078
+ /* VNodeType.Element */
4079
+ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
4080
+ /* LwcDomMode.Manual */
4081
+ ;
4082
+ const isLight = vnode.owner.renderMode === 0
4083
+ /* RenderMode.Light */
4084
+ ;
4085
+ patchElementWithRestrictions(elm, {
4086
+ isPortal,
4087
+ isLight
4088
+ });
4089
+ }
3882
4090
  }
4091
+
3883
4092
  function allocateChildren(vnode, vm) {
3884
- // A component with slots will re-render because:
3885
- // 1- There is a change of the internal state.
3886
- // 2- There is a change on the external api (ex: slots)
3887
- //
3888
- // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3889
- // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3890
- // in a reused VCustomElement, there won't be any slotted children.
3891
- // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3892
- //
3893
- // In case #2, we will always get a fresh VCustomElement.
3894
- const children = vnode.aChildren || vnode.children;
3895
- vm.aChildren = children;
3896
- const { renderMode, shadowMode } = vm;
3897
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3898
- // slow path
3899
- allocateInSlot(vm, children);
3900
- // save the allocated children in case this vnode is reused.
3901
- vnode.aChildren = children;
3902
- // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3903
- vnode.children = EmptyArray;
3904
- }
4093
+ // A component with slots will re-render because:
4094
+ // 1- There is a change of the internal state.
4095
+ // 2- There is a change on the external api (ex: slots)
4096
+ //
4097
+ // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
4098
+ // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
4099
+ // in a reused VCustomElement, there won't be any slotted children.
4100
+ // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
4101
+ //
4102
+ // In case #2, we will always get a fresh VCustomElement.
4103
+ const children = vnode.aChildren || vnode.children;
4104
+ vm.aChildren = children;
4105
+ const {
4106
+ renderMode,
4107
+ shadowMode
4108
+ } = vm;
4109
+
4110
+ if (shadowMode === 1
4111
+ /* ShadowMode.Synthetic */
4112
+ || renderMode === 0
4113
+ /* RenderMode.Light */
4114
+ ) {
4115
+ // slow path
4116
+ allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
4117
+
4118
+ vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
4119
+
4120
+ vnode.children = EmptyArray;
4121
+ }
3905
4122
  }
4123
+
3906
4124
  function createViewModelHook(elm, vnode, renderer) {
3907
- let vm = getAssociatedVMIfPresent(elm);
3908
- // There is a possibility that a custom element is registered under tagName, in which case, the
3909
- // initialization is already carry on, and there is nothing else to do here since this hook is
3910
- // called right after invoking `document.createElement`.
3911
- if (!isUndefined$1(vm)) {
3912
- return vm;
3913
- }
3914
- const { sel, mode, ctor, owner } = vnode;
3915
- vm = createVM(elm, ctor, renderer, {
3916
- mode,
3917
- owner,
3918
- tagName: sel,
3919
- });
3920
- if (process.env.NODE_ENV !== 'production') {
3921
- assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
3922
- }
4125
+ let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
4126
+ // initialization is already carry on, and there is nothing else to do here since this hook is
4127
+ // called right after invoking `document.createElement`.
4128
+
4129
+ if (!isUndefined$1(vm)) {
3923
4130
  return vm;
4131
+ }
4132
+
4133
+ const {
4134
+ sel,
4135
+ mode,
4136
+ ctor,
4137
+ owner
4138
+ } = vnode;
4139
+ vm = createVM(elm, ctor, renderer, {
4140
+ mode,
4141
+ owner,
4142
+ tagName: sel
4143
+ });
4144
+
4145
+ if (process.env.NODE_ENV !== 'production') {
4146
+ assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
4147
+ }
4148
+
4149
+ return vm;
3924
4150
  }
4151
+
3925
4152
  function allocateInSlot(vm, children) {
3926
- var _a;
3927
- const { cmpSlots: oldSlots } = vm;
3928
- const cmpSlots = (vm.cmpSlots = create(null));
3929
- for (let i = 0, len = children.length; i < len; i += 1) {
3930
- const vnode = children[i];
3931
- if (isNull(vnode)) {
3932
- continue;
3933
- }
3934
- let slotName = '';
3935
- if (isVBaseElement(vnode)) {
3936
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3937
- }
3938
- const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3939
- ArrayPush$1.call(vnodes, vnode);
3940
- }
3941
- if (isFalse(vm.isDirty)) {
3942
- // We need to determine if the old allocation is really different from the new one
3943
- // and mark the vm as dirty
3944
- const oldKeys = keys(oldSlots);
3945
- if (oldKeys.length !== keys(cmpSlots).length) {
3946
- markComponentAsDirty(vm);
3947
- return;
3948
- }
3949
- for (let i = 0, len = oldKeys.length; i < len; i += 1) {
3950
- const key = oldKeys[i];
3951
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3952
- markComponentAsDirty(vm);
3953
- return;
3954
- }
3955
- const oldVNodes = oldSlots[key];
3956
- const vnodes = cmpSlots[key];
3957
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3958
- if (oldVNodes[j] !== vnodes[j]) {
3959
- markComponentAsDirty(vm);
3960
- return;
3961
- }
3962
- }
4153
+ var _a;
4154
+
4155
+ const {
4156
+ cmpSlots: oldSlots
4157
+ } = vm;
4158
+ const cmpSlots = vm.cmpSlots = create(null);
4159
+
4160
+ for (let i = 0, len = children.length; i < len; i += 1) {
4161
+ const vnode = children[i];
4162
+
4163
+ if (isNull(vnode)) {
4164
+ continue;
4165
+ }
4166
+
4167
+ let slotName = '';
4168
+
4169
+ if (isVBaseElement(vnode)) {
4170
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4171
+ }
4172
+
4173
+ const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
4174
+ ArrayPush$1.call(vnodes, vnode);
4175
+ }
4176
+
4177
+ if (isFalse(vm.isDirty)) {
4178
+ // We need to determine if the old allocation is really different from the new one
4179
+ // and mark the vm as dirty
4180
+ const oldKeys = keys(oldSlots);
4181
+
4182
+ if (oldKeys.length !== keys(cmpSlots).length) {
4183
+ markComponentAsDirty(vm);
4184
+ return;
4185
+ }
4186
+
4187
+ for (let i = 0, len = oldKeys.length; i < len; i += 1) {
4188
+ const key = oldKeys[i];
4189
+
4190
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4191
+ markComponentAsDirty(vm);
4192
+ return;
4193
+ }
4194
+
4195
+ const oldVNodes = oldSlots[key];
4196
+ const vnodes = cmpSlots[key];
4197
+
4198
+ for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
4199
+ if (oldVNodes[j] !== vnodes[j]) {
4200
+ markComponentAsDirty(vm);
4201
+ return;
3963
4202
  }
4203
+ }
3964
4204
  }
3965
- }
3966
- // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3967
- const FromIteration = new WeakMap();
3968
- // dynamic children means it was generated by an iteration
4205
+ }
4206
+ } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
4207
+
4208
+
4209
+ const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
3969
4210
  // in a template, and will require a more complex diffing algo.
4211
+
3970
4212
  function markAsDynamicChildren(children) {
3971
- FromIteration.set(children, 1);
4213
+ FromIteration.set(children, 1);
3972
4214
  }
4215
+
3973
4216
  function hasDynamicChildren(children) {
3974
- return FromIteration.has(children);
4217
+ return FromIteration.has(children);
3975
4218
  }
4219
+
3976
4220
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3977
- const map = {};
3978
- // TODO [#1637]: simplify this by assuming that all vnodes has keys
3979
- for (let j = beginIdx; j <= endIdx; ++j) {
3980
- const ch = children[j];
3981
- if (isVNode(ch)) {
3982
- const { key } = ch;
3983
- if (key !== undefined) {
3984
- map[key] = j;
3985
- }
3986
- }
4221
+ const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
4222
+
4223
+ for (let j = beginIdx; j <= endIdx; ++j) {
4224
+ const ch = children[j];
4225
+
4226
+ if (isVNode(ch)) {
4227
+ const {
4228
+ key
4229
+ } = ch;
4230
+
4231
+ if (key !== undefined) {
4232
+ map[key] = j;
4233
+ }
3987
4234
  }
3988
- return map;
4235
+ }
4236
+
4237
+ return map;
3989
4238
  }
4239
+
3990
4240
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3991
- let oldStartIdx = 0;
3992
- let newStartIdx = 0;
3993
- let oldEndIdx = oldCh.length - 1;
3994
- let oldStartVnode = oldCh[0];
3995
- let oldEndVnode = oldCh[oldEndIdx];
3996
- const newChEnd = newCh.length - 1;
3997
- let newEndIdx = newChEnd;
3998
- let newStartVnode = newCh[0];
3999
- let newEndVnode = newCh[newEndIdx];
4000
- let oldKeyToIdx;
4001
- let idxInOld;
4002
- let elmToMove;
4003
- let before;
4004
- let clonedOldCh = false;
4005
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4006
- if (!isVNode(oldStartVnode)) {
4007
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4008
- }
4009
- else if (!isVNode(oldEndVnode)) {
4010
- oldEndVnode = oldCh[--oldEndIdx];
4011
- }
4012
- else if (!isVNode(newStartVnode)) {
4013
- newStartVnode = newCh[++newStartIdx];
4014
- }
4015
- else if (!isVNode(newEndVnode)) {
4016
- newEndVnode = newCh[--newEndIdx];
4017
- }
4018
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
4019
- patch(oldStartVnode, newStartVnode, renderer);
4020
- oldStartVnode = oldCh[++oldStartIdx];
4021
- newStartVnode = newCh[++newStartIdx];
4022
- }
4023
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
4024
- patch(oldEndVnode, newEndVnode, renderer);
4025
- oldEndVnode = oldCh[--oldEndIdx];
4026
- newEndVnode = newCh[--newEndIdx];
4027
- }
4028
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
4029
- // Vnode moved right
4030
- patch(oldStartVnode, newEndVnode, renderer);
4031
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4032
- oldStartVnode = oldCh[++oldStartIdx];
4033
- newEndVnode = newCh[--newEndIdx];
4034
- }
4035
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
4036
- // Vnode moved left
4037
- patch(oldEndVnode, newStartVnode, renderer);
4038
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4039
- oldEndVnode = oldCh[--oldEndIdx];
4040
- newStartVnode = newCh[++newStartIdx];
4041
- }
4042
- else {
4043
- if (oldKeyToIdx === undefined) {
4044
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4045
- }
4046
- idxInOld = oldKeyToIdx[newStartVnode.key];
4047
- if (isUndefined$1(idxInOld)) {
4048
- // New element
4049
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4050
- newStartVnode = newCh[++newStartIdx];
4051
- }
4052
- else {
4053
- elmToMove = oldCh[idxInOld];
4054
- if (isVNode(elmToMove)) {
4055
- if (elmToMove.sel !== newStartVnode.sel) {
4056
- // New element
4057
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4058
- }
4059
- else {
4060
- patch(elmToMove, newStartVnode, renderer);
4061
- // Delete the old child, but copy the array since it is read-only.
4062
- // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4063
- // so we only care about the `oldCh` object inside this function.
4064
- // To avoid cloning over and over again, we check `clonedOldCh`
4065
- // and only clone once.
4066
- if (!clonedOldCh) {
4067
- clonedOldCh = true;
4068
- oldCh = [...oldCh];
4069
- }
4070
- // We've already cloned at least once, so it's no longer read-only
4071
- oldCh[idxInOld] = undefined;
4072
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4073
- }
4074
- }
4075
- newStartVnode = newCh[++newStartIdx];
4076
- }
4241
+ let oldStartIdx = 0;
4242
+ let newStartIdx = 0;
4243
+ let oldEndIdx = oldCh.length - 1;
4244
+ let oldStartVnode = oldCh[0];
4245
+ let oldEndVnode = oldCh[oldEndIdx];
4246
+ const newChEnd = newCh.length - 1;
4247
+ let newEndIdx = newChEnd;
4248
+ let newStartVnode = newCh[0];
4249
+ let newEndVnode = newCh[newEndIdx];
4250
+ let oldKeyToIdx;
4251
+ let idxInOld;
4252
+ let elmToMove;
4253
+ let before;
4254
+ let clonedOldCh = false;
4255
+
4256
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4257
+ if (!isVNode(oldStartVnode)) {
4258
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
4259
+ } else if (!isVNode(oldEndVnode)) {
4260
+ oldEndVnode = oldCh[--oldEndIdx];
4261
+ } else if (!isVNode(newStartVnode)) {
4262
+ newStartVnode = newCh[++newStartIdx];
4263
+ } else if (!isVNode(newEndVnode)) {
4264
+ newEndVnode = newCh[--newEndIdx];
4265
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
4266
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4267
+ oldStartVnode = oldCh[++oldStartIdx];
4268
+ newStartVnode = newCh[++newStartIdx];
4269
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
4270
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4271
+ oldEndVnode = oldCh[--oldEndIdx];
4272
+ newEndVnode = newCh[--newEndIdx];
4273
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
4274
+ // Vnode moved right
4275
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4276
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4277
+ oldStartVnode = oldCh[++oldStartIdx];
4278
+ newEndVnode = newCh[--newEndIdx];
4279
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
4280
+ // Vnode moved left
4281
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4282
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4283
+ oldEndVnode = oldCh[--oldEndIdx];
4284
+ newStartVnode = newCh[++newStartIdx];
4285
+ } else {
4286
+ if (oldKeyToIdx === undefined) {
4287
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
4288
+ }
4289
+
4290
+ idxInOld = oldKeyToIdx[newStartVnode.key];
4291
+
4292
+ if (isUndefined$1(idxInOld)) {
4293
+ // New element
4294
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4295
+ newStartVnode = newCh[++newStartIdx];
4296
+ } else {
4297
+ elmToMove = oldCh[idxInOld];
4298
+
4299
+ if (isVNode(elmToMove)) {
4300
+ if (elmToMove.sel !== newStartVnode.sel) {
4301
+ // New element
4302
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4303
+ } else {
4304
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
4305
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4306
+ // so we only care about the `oldCh` object inside this function.
4307
+ // To avoid cloning over and over again, we check `clonedOldCh`
4308
+ // and only clone once.
4309
+
4310
+ if (!clonedOldCh) {
4311
+ clonedOldCh = true;
4312
+ oldCh = [...oldCh];
4313
+ } // We've already cloned at least once, so it's no longer read-only
4314
+
4315
+
4316
+ oldCh[idxInOld] = undefined;
4317
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
4318
+ }
4077
4319
  }
4320
+
4321
+ newStartVnode = newCh[++newStartIdx];
4322
+ }
4078
4323
  }
4079
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4080
- if (oldStartIdx > oldEndIdx) {
4081
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4082
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4083
- let i = newEndIdx;
4084
- let n;
4085
- do {
4086
- n = newCh[++i];
4087
- } while (!isVNode(n) && i < newChEnd);
4088
- before = isVNode(n) ? n.elm : null;
4089
- mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4090
- }
4091
- else {
4092
- unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4093
- }
4324
+ }
4325
+
4326
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
4327
+ if (oldStartIdx > oldEndIdx) {
4328
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
4329
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
4330
+ let i = newEndIdx;
4331
+ let n;
4332
+
4333
+ do {
4334
+ n = newCh[++i];
4335
+ } while (!isVNode(n) && i < newChEnd);
4336
+
4337
+ before = isVNode(n) ? n.elm : null;
4338
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
4339
+ } else {
4340
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
4094
4341
  }
4342
+ }
4095
4343
  }
4344
+
4096
4345
  function updateStaticChildren(c1, c2, parent, renderer) {
4097
- const c1Length = c1.length;
4098
- const c2Length = c2.length;
4099
- if (c1Length === 0) {
4100
- // the old list is empty, we can directly insert anything new
4101
- mountVNodes(c2, parent, renderer, null);
4102
- return;
4103
- }
4104
- if (c2Length === 0) {
4105
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4106
- // this is the case in which the dynamic children of an if-directive should be removed
4107
- unmountVNodes(c1, parent, renderer, true);
4108
- return;
4109
- }
4110
- // if the old list is not empty, the new list MUST have the same
4111
- // amount of nodes, that's why we call this static children
4112
- let anchor = null;
4113
- for (let i = c2Length - 1; i >= 0; i -= 1) {
4114
- const n1 = c1[i];
4115
- const n2 = c2[i];
4116
- if (n2 !== n1) {
4117
- if (isVNode(n1)) {
4118
- if (isVNode(n2)) {
4119
- // both vnodes are equivalent, and we just need to patch them
4120
- patch(n1, n2, renderer);
4121
- anchor = n2.elm;
4122
- }
4123
- else {
4124
- // removing the old vnode since the new one is null
4125
- unmount(n1, parent, renderer, true);
4126
- }
4127
- }
4128
- else if (isVNode(n2)) {
4129
- mount(n2, parent, renderer, anchor);
4130
- anchor = n2.elm;
4131
- }
4346
+ const c1Length = c1.length;
4347
+ const c2Length = c2.length;
4348
+
4349
+ if (c1Length === 0) {
4350
+ // the old list is empty, we can directly insert anything new
4351
+ mountVNodes(c2, parent, renderer, null);
4352
+ return;
4353
+ }
4354
+
4355
+ if (c2Length === 0) {
4356
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4357
+ // this is the case in which the dynamic children of an if-directive should be removed
4358
+ unmountVNodes(c1, parent, renderer, true);
4359
+ return;
4360
+ } // if the old list is not empty, the new list MUST have the same
4361
+ // amount of nodes, that's why we call this static children
4362
+
4363
+
4364
+ let anchor = null;
4365
+
4366
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4367
+ const n1 = c1[i];
4368
+ const n2 = c2[i];
4369
+
4370
+ if (n2 !== n1) {
4371
+ if (isVNode(n1)) {
4372
+ if (isVNode(n2)) {
4373
+ // both vnodes are equivalent, and we just need to patch them
4374
+ patch(n1, n2, parent, renderer);
4375
+ anchor = n2.elm;
4376
+ } else {
4377
+ // removing the old vnode since the new one is null
4378
+ unmount(n1, parent, renderer, true);
4132
4379
  }
4380
+ } else if (isVNode(n2)) {
4381
+ mount(n2, parent, renderer, anchor);
4382
+ anchor = n2.elm;
4383
+ }
4133
4384
  }
4385
+ }
4134
4386
  }
4135
4387
 
4136
4388
  /*
@@ -4451,13 +4703,6 @@ function fid(url) {
4451
4703
  }
4452
4704
  return url;
4453
4705
  }
4454
- /**
4455
- * Map to store an index value assigned to any dynamic component reference ingested
4456
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4457
- * component reference to avoid diffing algo mismatches.
4458
- */
4459
- const DynamicImportedComponentMap = new Map();
4460
- let dynamicImportedComponentCounter = 0;
4461
4706
  /**
4462
4707
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4463
4708
  */
@@ -4474,18 +4719,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4474
4719
  if (!isComponentConstructor(Ctor)) {
4475
4720
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4476
4721
  }
4477
- let idx = DynamicImportedComponentMap.get(Ctor);
4478
- if (isUndefined$1(idx)) {
4479
- idx = dynamicImportedComponentCounter++;
4480
- DynamicImportedComponentMap.set(Ctor, idx);
4481
- }
4482
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4483
- // to identify different constructors as vnodes with different keys to avoid reusing the
4484
- // element used for previous constructors.
4485
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4486
- // hoisting optimization.
4487
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4488
- return c(sel, Ctor, newData, children);
4722
+ return c(sel, Ctor, data, children);
4489
4723
  }
4490
4724
  /**
4491
4725
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5166,7 +5400,7 @@ function createVM(elm, ctor, renderer, options) {
5166
5400
  return `[object:vm ${def.name} (${vm.idx})]`;
5167
5401
  };
5168
5402
 
5169
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5403
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5170
5404
  vm.shadowMode = 0
5171
5405
  /* ShadowMode.Native */
5172
5406
  ;
@@ -5205,7 +5439,7 @@ function computeShadowMode(vm, renderer) {
5205
5439
  } else if (isNativeShadowDefined) {
5206
5440
  // Not combined with above condition because @lwc/features only supports identifiers in
5207
5441
  // the if-condition.
5208
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5442
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5209
5443
  if (def.shadowSupportMode === "any"
5210
5444
  /* ShadowSupportMode.Any */
5211
5445
  ) {
@@ -5321,46 +5555,7 @@ function patchShadowRoot(vm, newCh) {
5321
5555
 
5322
5556
  if (vm.state === 1
5323
5557
  /* VMState.connected */
5324
- ) {
5325
- // If the element is connected, that means connectedCallback was already issued, and
5326
- // any successive rendering should finish with the call to renderedCallback, otherwise
5327
- // the connectedCallback will take care of calling it in the right order at the end of
5328
- // the current rehydration process.
5329
- runRenderedCallback(vm);
5330
- }
5331
- }
5332
-
5333
- function runRenderedCallback(vm) {
5334
- const {
5335
- def: {
5336
- renderedCallback
5337
- },
5338
- renderer: {
5339
- ssr
5340
- }
5341
- } = vm;
5342
-
5343
- if (isTrue(ssr)) {
5344
- return;
5345
- }
5346
-
5347
- const {
5348
- rendered
5349
- } = Services;
5350
-
5351
- if (rendered) {
5352
- invokeServiceHook(vm, rendered);
5353
- }
5354
-
5355
- if (!isUndefined$1(renderedCallback)) {
5356
- logOperationStart(4
5357
- /* OperationId.RenderedCallback */
5358
- , vm);
5359
- invokeComponentCallback(vm, renderedCallback);
5360
- logOperationEnd(4
5361
- /* OperationId.RenderedCallback */
5362
- , vm);
5363
- }
5558
+ ) ;
5364
5559
  }
5365
5560
 
5366
5561
  function runConnectedCallback(vm) {
@@ -5627,14 +5822,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5627
5822
  }
5628
5823
 
5629
5824
  function createFieldDataCallback(vm, name) {
5630
- const {
5631
- cmpFields
5632
- } = vm;
5633
5825
  return value => {
5634
- if (value !== vm.cmpFields[name]) {
5635
- // storing the value in the underlying storage
5636
- cmpFields[name] = value;
5637
- }
5826
+ updateComponentValue(vm, name, value);
5638
5827
  };
5639
5828
  }
5640
5829
 
@@ -5839,7 +6028,7 @@ function installWireAdapters(vm) {
5839
6028
  ArrayPush$1.call(wiredConnecting, () => {
5840
6029
  connector.connect();
5841
6030
 
5842
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6031
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5843
6032
  if (hasDynamicParams) {
5844
6033
  Promise.resolve().then(computeConfigAndUpdate);
5845
6034
  return;
@@ -6048,7 +6237,7 @@ function freezeTemplate(tmpl) {
6048
6237
  });
6049
6238
  }
6050
6239
  }
6051
- /* version: 2.22.0 */
6240
+ /* version: 2.23.2 */
6052
6241
 
6053
6242
  /*
6054
6243
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6131,10 +6320,6 @@ class HTMLElementImpl {
6131
6320
  return createElement(tagName);
6132
6321
  }
6133
6322
  }
6134
- const ssr = true;
6135
- function isHydrating() {
6136
- return false;
6137
- }
6138
6323
  const isNativeShadowDefined = false;
6139
6324
  const isSyntheticShadowDefined = false;
6140
6325
  function insert(node, parent, anchor) {
@@ -6373,11 +6558,9 @@ const HTMLElementExported = HTMLElementImpl;
6373
6558
  /* noop */
6374
6559
  const assertInstanceOfHTMLElement = noop;
6375
6560
  const renderer = {
6376
- ssr,
6377
6561
  isNativeShadowDefined,
6378
6562
  isSyntheticShadowDefined,
6379
6563
  HTMLElementExported,
6380
- isHydrating,
6381
6564
  insert,
6382
6565
  remove,
6383
6566
  cloneNode,
@@ -6524,6 +6707,6 @@ function renderComponent(tagName, Ctor, props = {}) {
6524
6707
  */
6525
6708
  freeze(LightningElement);
6526
6709
  seal(LightningElement.prototype);
6527
- /* version: 2.22.0 */
6710
+ /* version: 2.23.2 */
6528
6711
 
6529
6712
  export { LightningElement, api$1 as api, createContextProvider, freezeTemplate, getComponentDef, isComponentConstructor, parseFragment, parseFragment as parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };