lwc 2.23.0 → 2.23.3

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 +1208 -877
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +1208 -876
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1115 -812
  5. package/dist/engine-dom/iife/es5/engine-dom.js +473 -386
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +424 -344
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +1208 -876
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1115 -812
  11. package/dist/engine-dom/umd/es5/engine-dom.js +473 -386
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +424 -344
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +803 -537
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +803 -537
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +20 -20
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +20 -20
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +19 -19
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +20 -20
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +19 -19
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +20 -20
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +19 -19
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +20 -20
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +19 -19
  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 +17 -9
@@ -294,7 +294,11 @@
294
294
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
295
295
  return attributeName;
296
296
  }
297
- /** version: 2.23.0 */
297
+ /** version: 2.23.3 */
298
+
299
+ /**
300
+ * Copyright (C) 2018 salesforce.com, inc.
301
+ */
298
302
 
299
303
  /*
300
304
  * Copyright (c) 2018, salesforce.com, inc.
@@ -303,7 +307,7 @@
303
307
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
304
308
  */
305
309
  function detect(propName) {
306
- return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
310
+ return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
307
311
  }
308
312
 
309
313
  /*
@@ -372,6 +376,7 @@
372
376
  patch$1(propName);
373
377
  }
374
378
  }
379
+ /** version: 2.23.3 */
375
380
 
376
381
  /**
377
382
  * Copyright (C) 2018 salesforce.com, inc.
@@ -391,6 +396,7 @@
391
396
  ENABLE_HTML_COLLECTIONS_PATCH: null,
392
397
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
393
398
  ENABLE_MIXED_SHADOW_MODE: null,
399
+ ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
394
400
  ENABLE_NODE_LIST_PATCH: null,
395
401
  ENABLE_NODE_PATCH: null,
396
402
  ENABLE_REACTIVE_SETTER: null,
@@ -399,7 +405,7 @@
399
405
  if (!_globalThis.lwcRuntimeFlags) {
400
406
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
401
407
  }
402
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
408
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
403
409
  /**
404
410
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
405
411
  * flag. It is meant to be used during the app initialization.
@@ -423,13 +429,13 @@
423
429
  }
424
430
  {
425
431
  // Disallow the same flag to be set more than once in production
426
- const runtimeValue = runtimeFlags[name];
432
+ const runtimeValue = lwcRuntimeFlags[name];
427
433
  if (!isUndefined$1(runtimeValue)) {
428
434
  // eslint-disable-next-line no-console
429
435
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
430
436
  return;
431
437
  }
432
- defineProperty(runtimeFlags, name, { value });
438
+ defineProperty(lwcRuntimeFlags, name, { value });
433
439
  }
434
440
  }
435
441
  /**
@@ -704,8 +710,8 @@
704
710
  */
705
711
  // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
706
712
  // to inject at runtime.
707
- const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
708
- const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
713
+ const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
714
+ const HTMLElementPrototype = HTMLElementConstructor.prototype;
709
715
 
710
716
  /*
711
717
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1686,7 +1692,7 @@
1686
1692
  const vm = getAssociatedVM(this);
1687
1693
 
1688
1694
  if (set) {
1689
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
1695
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
1690
1696
  let ro = vm.oar[key];
1691
1697
 
1692
1698
  if (isUndefined$1(ro)) {
@@ -2095,7 +2101,7 @@
2095
2101
  defineProperties(HTMLBridgeElement.prototype, descriptors);
2096
2102
  return HTMLBridgeElement;
2097
2103
  }
2098
- const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2104
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2099
2105
  freeze(BaseBridgeElement);
2100
2106
  seal(BaseBridgeElement.prototype);
2101
2107
  function setActiveVM(vm) {
@@ -2106,7 +2112,7 @@
2106
2112
  }
2107
2113
  function swapTemplate(oldTpl, newTpl) {
2108
2114
 
2109
- if (!runtimeFlags.ENABLE_HMR) {
2115
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2110
2116
  throw new Error('HMR is not enabled');
2111
2117
  }
2112
2118
 
@@ -2114,7 +2120,7 @@
2114
2120
  }
2115
2121
  function swapComponent(oldComponent, newComponent) {
2116
2122
 
2117
- if (!runtimeFlags.ENABLE_HMR) {
2123
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2118
2124
  throw new Error('HMR is not enabled');
2119
2125
  }
2120
2126
 
@@ -2122,7 +2128,7 @@
2122
2128
  }
2123
2129
  function swapStyle(oldStyle, newStyle) {
2124
2130
 
2125
- if (!runtimeFlags.ENABLE_HMR) {
2131
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2126
2132
  throw new Error('HMR is not enabled');
2127
2133
  }
2128
2134
 
@@ -2470,30 +2476,61 @@
2470
2476
  * SPDX-License-Identifier: MIT
2471
2477
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2472
2478
  */
2479
+
2480
+ function checkHasVM(elm) {
2481
+ const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
2482
+
2483
+ return hasVM;
2484
+ }
2485
+
2473
2486
  function getUpgradableConstructor(tagName, renderer) {
2474
- const { getCustomElement, HTMLElementExported: RendererHTMLElement, defineCustomElement, } = renderer;
2475
- // Should never get a tag with upper case letter at this point, the compiler should
2476
- // produce only tags with lowercase letters
2477
- // But, for backwards compatibility, we will lower case the tagName
2478
- tagName = tagName.toLowerCase();
2479
- let CE = getCustomElement(tagName);
2480
- if (!isUndefined$1(CE)) {
2481
- return CE;
2487
+ const {
2488
+ getCustomElement,
2489
+ HTMLElementExported: RendererHTMLElement,
2490
+ defineCustomElement
2491
+ } = renderer; // Should never get a tag with upper case letter at this point, the compiler should
2492
+ // produce only tags with lowercase letters
2493
+ // But, for backwards compatibility, we will lower case the tagName
2494
+
2495
+ tagName = tagName.toLowerCase();
2496
+ let CE = getCustomElement(tagName);
2497
+
2498
+ if (!isUndefined$1(CE)) {
2499
+ return CE;
2500
+ }
2501
+ /**
2502
+ * LWC Upgradable Element reference to an element that was created
2503
+ * via the scoped registry mechanism, and that is ready to be upgraded.
2504
+ */
2505
+
2506
+
2507
+ CE = class LWCUpgradableElement extends RendererHTMLElement {
2508
+ constructor(upgradeCallback) {
2509
+ super();
2510
+
2511
+ if (isFunction$1(upgradeCallback)) {
2512
+ upgradeCallback(this); // nothing to do with the result for now
2513
+ }
2482
2514
  }
2483
- /**
2484
- * LWC Upgradable Element reference to an element that was created
2485
- * via the scoped registry mechanism, and that is ready to be upgraded.
2486
- */
2487
- CE = class LWCUpgradableElement extends RendererHTMLElement {
2488
- constructor(upgradeCallback) {
2489
- super();
2490
- if (isFunction$1(upgradeCallback)) {
2491
- upgradeCallback(this); // nothing to do with the result for now
2492
- }
2493
- }
2515
+
2516
+ };
2517
+
2518
+ if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
2519
+ CE.prototype.connectedCallback = function () {
2520
+ if (checkHasVM(this)) {
2521
+ connectRootElement(this);
2522
+ }
2494
2523
  };
2495
- defineCustomElement(tagName, CE);
2496
- return CE;
2524
+
2525
+ CE.prototype.disconnectedCallback = function () {
2526
+ if (checkHasVM(this)) {
2527
+ disconnectRootElement(this);
2528
+ }
2529
+ };
2530
+ }
2531
+
2532
+ defineCustomElement(tagName, CE);
2533
+ return CE;
2497
2534
  }
2498
2535
 
2499
2536
  /*
@@ -2735,534 +2772,732 @@
2735
2772
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2736
2773
  */
2737
2774
  function patchChildren(c1, c2, parent, renderer) {
2738
- if (hasDynamicChildren(c2)) {
2739
- updateDynamicChildren(c1, c2, parent, renderer);
2740
- }
2741
- else {
2742
- updateStaticChildren(c1, c2, parent, renderer);
2743
- }
2775
+ if (hasDynamicChildren(c2)) {
2776
+ updateDynamicChildren(c1, c2, parent, renderer);
2777
+ } else {
2778
+ updateStaticChildren(c1, c2, parent, renderer);
2779
+ }
2744
2780
  }
2781
+
2745
2782
  function patch(n1, n2, parent, renderer) {
2746
- var _a, _b;
2747
- if (n1 === n2) {
2748
- return;
2749
- }
2750
- switch (n2.type) {
2751
- case 0 /* VNodeType.Text */:
2752
- // VText has no special capability, fallback to the owner's renderer
2753
- patchText(n1, n2, renderer);
2754
- break;
2755
- case 1 /* VNodeType.Comment */:
2756
- // VComment has no special capability, fallback to the owner's renderer
2757
- patchComment(n1, n2, renderer);
2758
- break;
2759
- case 4 /* VNodeType.Static */:
2760
- n2.elm = n1.elm;
2761
- break;
2762
- case 2 /* VNodeType.Element */:
2763
- patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2764
- break;
2765
- case 3 /* VNodeType.CustomElement */:
2766
- patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2767
- break;
2768
- }
2783
+ var _a, _b;
2784
+
2785
+ if (n1 === n2) {
2786
+ return;
2787
+ }
2788
+
2789
+ switch (n2.type) {
2790
+ case 0
2791
+ /* VNodeType.Text */
2792
+ :
2793
+ // VText has no special capability, fallback to the owner's renderer
2794
+ patchText(n1, n2, renderer);
2795
+ break;
2796
+
2797
+ case 1
2798
+ /* VNodeType.Comment */
2799
+ :
2800
+ // VComment has no special capability, fallback to the owner's renderer
2801
+ patchComment(n1, n2, renderer);
2802
+ break;
2803
+
2804
+ case 4
2805
+ /* VNodeType.Static */
2806
+ :
2807
+ n2.elm = n1.elm;
2808
+ break;
2809
+
2810
+ case 2
2811
+ /* VNodeType.Element */
2812
+ :
2813
+ patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2814
+ break;
2815
+
2816
+ case 3
2817
+ /* VNodeType.CustomElement */
2818
+ :
2819
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2820
+ break;
2821
+ }
2769
2822
  }
2823
+
2770
2824
  function mount(node, parent, renderer, anchor) {
2771
- var _a, _b;
2772
- switch (node.type) {
2773
- case 0 /* VNodeType.Text */:
2774
- // VText has no special capability, fallback to the owner's renderer
2775
- mountText(node, parent, anchor, renderer);
2776
- break;
2777
- case 1 /* VNodeType.Comment */:
2778
- // VComment has no special capability, fallback to the owner's renderer
2779
- mountComment(node, parent, anchor, renderer);
2780
- break;
2781
- case 4 /* VNodeType.Static */:
2782
- // VStatic cannot have a custom renderer associated to them, using owner's renderer
2783
- mountStatic(node, parent, anchor, renderer);
2784
- break;
2785
- case 2 /* VNodeType.Element */:
2786
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
2787
- mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2788
- break;
2789
- case 3 /* VNodeType.CustomElement */:
2790
- // If the vnode data has a renderer override use it, else fallback to owner's renderer
2791
- mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2792
- break;
2793
- }
2825
+ var _a, _b;
2826
+
2827
+ switch (node.type) {
2828
+ case 0
2829
+ /* VNodeType.Text */
2830
+ :
2831
+ // VText has no special capability, fallback to the owner's renderer
2832
+ mountText(node, parent, anchor, renderer);
2833
+ break;
2834
+
2835
+ case 1
2836
+ /* VNodeType.Comment */
2837
+ :
2838
+ // VComment has no special capability, fallback to the owner's renderer
2839
+ mountComment(node, parent, anchor, renderer);
2840
+ break;
2841
+
2842
+ case 4
2843
+ /* VNodeType.Static */
2844
+ :
2845
+ // VStatic cannot have a custom renderer associated to them, using owner's renderer
2846
+ mountStatic(node, parent, anchor, renderer);
2847
+ break;
2848
+
2849
+ case 2
2850
+ /* VNodeType.Element */
2851
+ :
2852
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
2853
+ mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2854
+ break;
2855
+
2856
+ case 3
2857
+ /* VNodeType.CustomElement */
2858
+ :
2859
+ // If the vnode data has a renderer override use it, else fallback to owner's renderer
2860
+ mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2861
+ break;
2862
+ }
2794
2863
  }
2864
+
2795
2865
  function patchText(n1, n2, renderer) {
2796
- n2.elm = n1.elm;
2797
- if (n2.text !== n1.text) {
2798
- updateTextContent(n2, renderer);
2799
- }
2866
+ n2.elm = n1.elm;
2867
+
2868
+ if (n2.text !== n1.text) {
2869
+ updateTextContent(n2, renderer);
2870
+ }
2800
2871
  }
2872
+
2801
2873
  function mountText(vnode, parent, anchor, renderer) {
2802
- const { owner } = vnode;
2803
- const { createText } = renderer;
2804
- const textNode = (vnode.elm = createText(vnode.text));
2805
- linkNodeToShadow(textNode, owner, renderer);
2806
- insertNode(textNode, parent, anchor, renderer);
2874
+ const {
2875
+ owner
2876
+ } = vnode;
2877
+ const {
2878
+ createText
2879
+ } = renderer;
2880
+ const textNode = vnode.elm = createText(vnode.text);
2881
+ linkNodeToShadow(textNode, owner, renderer);
2882
+ insertNode(textNode, parent, anchor, renderer);
2807
2883
  }
2884
+
2808
2885
  function patchComment(n1, n2, renderer) {
2809
- n2.elm = n1.elm;
2810
- // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
2811
- // it is the case today.
2812
- if (n2.text !== n1.text) {
2813
- updateTextContent(n2, renderer);
2814
- }
2886
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
2887
+ // it is the case today.
2888
+
2889
+ if (n2.text !== n1.text) {
2890
+ updateTextContent(n2, renderer);
2891
+ }
2815
2892
  }
2893
+
2816
2894
  function mountComment(vnode, parent, anchor, renderer) {
2817
- const { owner } = vnode;
2818
- const { createComment } = renderer;
2819
- const commentNode = (vnode.elm = createComment(vnode.text));
2820
- linkNodeToShadow(commentNode, owner, renderer);
2821
- insertNode(commentNode, parent, anchor, renderer);
2895
+ const {
2896
+ owner
2897
+ } = vnode;
2898
+ const {
2899
+ createComment
2900
+ } = renderer;
2901
+ const commentNode = vnode.elm = createComment(vnode.text);
2902
+ linkNodeToShadow(commentNode, owner, renderer);
2903
+ insertNode(commentNode, parent, anchor, renderer);
2822
2904
  }
2905
+
2823
2906
  function mountElement(vnode, parent, anchor, renderer) {
2824
- const { sel, owner, data: { svg }, } = vnode;
2825
- const { createElement } = renderer;
2826
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
2827
- const elm = (vnode.elm = createElement(sel, namespace));
2828
- linkNodeToShadow(elm, owner, renderer);
2829
- applyStyleScoping(elm, owner, renderer);
2830
- applyDomManual(elm, vnode);
2831
- patchElementPropsAndAttrs$1(null, vnode, renderer);
2832
- insertNode(elm, parent, anchor, renderer);
2833
- mountVNodes(vnode.children, elm, renderer, null);
2907
+ const {
2908
+ sel,
2909
+ owner,
2910
+ data: {
2911
+ svg
2912
+ }
2913
+ } = vnode;
2914
+ const {
2915
+ createElement
2916
+ } = renderer;
2917
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
2918
+ const elm = vnode.elm = createElement(sel, namespace);
2919
+ linkNodeToShadow(elm, owner, renderer);
2920
+ applyStyleScoping(elm, owner, renderer);
2921
+ applyDomManual(elm, vnode);
2922
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
2923
+ insertNode(elm, parent, anchor, renderer);
2924
+ mountVNodes(vnode.children, elm, renderer, null);
2834
2925
  }
2926
+
2835
2927
  function patchElement(n1, n2, renderer) {
2836
- const elm = (n2.elm = n1.elm);
2837
- patchElementPropsAndAttrs$1(n1, n2, renderer);
2838
- patchChildren(n1.children, n2.children, elm, renderer);
2928
+ const elm = n2.elm = n1.elm;
2929
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
2930
+ patchChildren(n1.children, n2.children, elm, renderer);
2839
2931
  }
2932
+
2840
2933
  function mountStatic(vnode, parent, anchor, renderer) {
2841
- const { owner } = vnode;
2842
- const { cloneNode, isSyntheticShadowDefined } = renderer;
2843
- const elm = (vnode.elm = cloneNode(vnode.fragment, true));
2844
- linkNodeToShadow(elm, owner, renderer);
2845
- // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
2846
- const { renderMode, shadowMode } = owner;
2847
- if (isSyntheticShadowDefined) {
2848
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
2849
- elm[KEY__SHADOW_STATIC] = true;
2850
- }
2934
+ const {
2935
+ owner
2936
+ } = vnode;
2937
+ const {
2938
+ cloneNode,
2939
+ isSyntheticShadowDefined
2940
+ } = renderer;
2941
+ const elm = vnode.elm = cloneNode(vnode.fragment, true);
2942
+ linkNodeToShadow(elm, owner, renderer);
2943
+
2944
+ const {
2945
+ renderMode,
2946
+ shadowMode
2947
+ } = owner;
2948
+
2949
+ if (isSyntheticShadowDefined) {
2950
+ if (shadowMode === 1
2951
+ /* ShadowMode.Synthetic */
2952
+ || renderMode === 0
2953
+ /* RenderMode.Light */
2954
+ ) {
2955
+ elm[KEY__SHADOW_STATIC] = true;
2851
2956
  }
2852
- insertNode(elm, parent, anchor, renderer);
2957
+ }
2958
+
2959
+ insertNode(elm, parent, anchor, renderer);
2853
2960
  }
2961
+
2854
2962
  function mountCustomElement(vnode, parent, anchor, renderer) {
2855
- const { sel, owner } = vnode;
2856
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
2857
- /**
2858
- * Note: if the upgradable constructor does not expect, or throw when we new it
2859
- * with a callback as the first argument, we could implement a more advanced
2860
- * mechanism that only passes that argument if the constructor is known to be
2861
- * an upgradable custom element.
2862
- */
2863
- let vm;
2864
- const elm = new UpgradableConstructor((elm) => {
2865
- // the custom element from the registry is expecting an upgrade callback
2866
- vm = createViewModelHook(elm, vnode, renderer);
2867
- });
2868
- vnode.elm = elm;
2869
- vnode.vm = vm;
2870
- linkNodeToShadow(elm, owner, renderer);
2871
- applyStyleScoping(elm, owner, renderer);
2872
- if (vm) {
2873
- allocateChildren(vnode, vm);
2874
- }
2875
- else if (vnode.ctor !== UpgradableConstructor) {
2876
- throw new TypeError(`Incorrect Component Constructor`);
2877
- }
2878
- patchElementPropsAndAttrs$1(null, vnode, renderer);
2879
- insertNode(elm, parent, anchor, renderer);
2880
- if (vm) {
2963
+ const {
2964
+ sel,
2965
+ owner
2966
+ } = vnode;
2967
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
2968
+ /**
2969
+ * Note: if the upgradable constructor does not expect, or throw when we new it
2970
+ * with a callback as the first argument, we could implement a more advanced
2971
+ * mechanism that only passes that argument if the constructor is known to be
2972
+ * an upgradable custom element.
2973
+ */
2974
+
2975
+ let vm;
2976
+ const elm = new UpgradableConstructor(elm => {
2977
+ // the custom element from the registry is expecting an upgrade callback
2978
+ vm = createViewModelHook(elm, vnode, renderer);
2979
+ });
2980
+ vnode.elm = elm;
2981
+ vnode.vm = vm;
2982
+ linkNodeToShadow(elm, owner, renderer);
2983
+ applyStyleScoping(elm, owner, renderer);
2984
+
2985
+ if (vm) {
2986
+ allocateChildren(vnode, vm);
2987
+ } else if (vnode.ctor !== UpgradableConstructor) {
2988
+ throw new TypeError(`Incorrect Component Constructor`);
2989
+ }
2990
+
2991
+ patchElementPropsAndAttrs$1(null, vnode, renderer);
2992
+ insertNode(elm, parent, anchor, renderer);
2993
+
2994
+ if (vm) {
2995
+ {
2996
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
2997
+
2881
2998
  runConnectedCallback(vm);
2999
+ }
2882
3000
  }
2883
- mountVNodes(vnode.children, elm, renderer, null);
2884
- if (vm) {
2885
- appendVM(vm);
2886
- }
3001
+ }
3002
+
3003
+ mountVNodes(vnode.children, elm, renderer, null);
3004
+
3005
+ if (vm) {
3006
+ appendVM(vm);
3007
+ }
2887
3008
  }
3009
+
2888
3010
  function patchCustomElement(n1, n2, parent, renderer) {
2889
- if (n1.ctor !== n2.ctor) {
2890
- // If the constructor, unmount the current component and mount a new one using the new
2891
- // constructor.
2892
- const anchor = renderer.nextSibling(n1.elm);
2893
- unmount(n1, parent, renderer, true);
2894
- mountCustomElement(n2, parent, anchor, renderer);
2895
- }
2896
- else {
2897
- // Otherwise patch the existing component with new props/attrs/etc.
2898
- const elm = (n2.elm = n1.elm);
2899
- const vm = (n2.vm = n1.vm);
2900
- patchElementPropsAndAttrs$1(n1, n2, renderer);
2901
- if (!isUndefined$1(vm)) {
2902
- // in fallback mode, the allocation will always set children to
2903
- // empty and delegate the real allocation to the slot elements
2904
- allocateChildren(n2, vm);
2905
- }
2906
- // in fallback mode, the children will be always empty, so, nothing
2907
- // will happen, but in native, it does allocate the light dom
2908
- patchChildren(n1.children, n2.children, elm, renderer);
2909
- if (!isUndefined$1(vm)) {
2910
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
2911
- // this is important to preserve the top to bottom synchronous rendering phase.
2912
- rerenderVM(vm);
2913
- }
3011
+ if (n1.ctor !== n2.ctor) {
3012
+ // If the constructor, unmount the current component and mount a new one using the new
3013
+ // constructor.
3014
+ const anchor = renderer.nextSibling(n1.elm);
3015
+ unmount(n1, parent, renderer, true);
3016
+ mountCustomElement(n2, parent, anchor, renderer);
3017
+ } else {
3018
+ // Otherwise patch the existing component with new props/attrs/etc.
3019
+ const elm = n2.elm = n1.elm;
3020
+ const vm = n2.vm = n1.vm;
3021
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3022
+
3023
+ if (!isUndefined$1(vm)) {
3024
+ // in fallback mode, the allocation will always set children to
3025
+ // empty and delegate the real allocation to the slot elements
3026
+ allocateChildren(n2, vm);
3027
+ } // in fallback mode, the children will be always empty, so, nothing
3028
+ // will happen, but in native, it does allocate the light dom
3029
+
3030
+
3031
+ patchChildren(n1.children, n2.children, elm, renderer);
3032
+
3033
+ if (!isUndefined$1(vm)) {
3034
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3035
+ // this is important to preserve the top to bottom synchronous rendering phase.
3036
+ rerenderVM(vm);
2914
3037
  }
3038
+ }
2915
3039
  }
3040
+
2916
3041
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
2917
- for (; start < end; ++start) {
2918
- const vnode = vnodes[start];
2919
- if (isVNode(vnode)) {
2920
- mount(vnode, parent, renderer, anchor);
2921
- }
3042
+ for (; start < end; ++start) {
3043
+ const vnode = vnodes[start];
3044
+
3045
+ if (isVNode(vnode)) {
3046
+ mount(vnode, parent, renderer, anchor);
2922
3047
  }
3048
+ }
2923
3049
  }
3050
+
2924
3051
  function unmount(vnode, parent, renderer, doRemove = false) {
2925
- const { type, elm, sel } = vnode;
2926
- // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
2927
- // subtree root, is the only element worth unmounting from the subtree.
2928
- if (doRemove) {
2929
- // The vnode might or might not have a data.renderer associated to it
2930
- // but the removal used here is from the owner instead.
2931
- removeNode(elm, parent, renderer);
2932
- }
2933
- switch (type) {
2934
- case 2 /* VNodeType.Element */: {
2935
- // Slot content is removed to trigger slotchange event when removing slot.
2936
- // Only required for synthetic shadow.
2937
- const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
2938
- unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
2939
- break;
2940
- }
2941
- case 3 /* VNodeType.CustomElement */: {
2942
- const { vm } = vnode;
2943
- // No need to unmount the children here, `removeVM` will take care of removing the
2944
- // children.
2945
- if (!isUndefined$1(vm)) {
2946
- removeVM(vm);
2947
- }
3052
+ const {
3053
+ type,
3054
+ elm,
3055
+ sel
3056
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3057
+ // subtree root, is the only element worth unmounting from the subtree.
3058
+
3059
+ if (doRemove) {
3060
+ // The vnode might or might not have a data.renderer associated to it
3061
+ // but the removal used here is from the owner instead.
3062
+ removeNode(elm, parent, renderer);
3063
+ }
3064
+
3065
+ switch (type) {
3066
+ case 2
3067
+ /* VNodeType.Element */
3068
+ :
3069
+ {
3070
+ // Slot content is removed to trigger slotchange event when removing slot.
3071
+ // Only required for synthetic shadow.
3072
+ const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
3073
+ /* ShadowMode.Synthetic */
3074
+ ;
3075
+ unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
3076
+ break;
3077
+ }
3078
+
3079
+ case 3
3080
+ /* VNodeType.CustomElement */
3081
+ :
3082
+ {
3083
+ const {
3084
+ vm
3085
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3086
+ // children.
3087
+
3088
+ if (!isUndefined$1(vm)) {
3089
+ removeVM(vm);
2948
3090
  }
2949
- }
3091
+ }
3092
+ }
2950
3093
  }
3094
+
2951
3095
  function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
2952
- for (; start < end; ++start) {
2953
- const ch = vnodes[start];
2954
- if (isVNode(ch)) {
2955
- unmount(ch, parent, renderer, doRemove);
2956
- }
3096
+ for (; start < end; ++start) {
3097
+ const ch = vnodes[start];
3098
+
3099
+ if (isVNode(ch)) {
3100
+ unmount(ch, parent, renderer, doRemove);
2957
3101
  }
3102
+ }
2958
3103
  }
3104
+
2959
3105
  function isVNode(vnode) {
2960
- return vnode != null;
3106
+ return vnode != null;
2961
3107
  }
3108
+
2962
3109
  function linkNodeToShadow(elm, owner, renderer) {
2963
- const { renderRoot, renderMode, shadowMode } = owner;
2964
- const { isSyntheticShadowDefined } = renderer;
2965
- // TODO [#1164]: this should eventually be done by the polyfill directly
2966
- if (isSyntheticShadowDefined) {
2967
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
2968
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
2969
- }
3110
+ const {
3111
+ renderRoot,
3112
+ renderMode,
3113
+ shadowMode
3114
+ } = owner;
3115
+ const {
3116
+ isSyntheticShadowDefined
3117
+ } = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
3118
+
3119
+ if (isSyntheticShadowDefined) {
3120
+ if (shadowMode === 1
3121
+ /* ShadowMode.Synthetic */
3122
+ || renderMode === 0
3123
+ /* RenderMode.Light */
3124
+ ) {
3125
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
2970
3126
  }
3127
+ }
2971
3128
  }
3129
+
2972
3130
  function updateTextContent(vnode, renderer) {
2973
- const { elm, text } = vnode;
2974
- const { setText } = renderer;
2975
- setText(elm, text);
3131
+ const {
3132
+ elm,
3133
+ text
3134
+ } = vnode;
3135
+ const {
3136
+ setText
3137
+ } = renderer;
3138
+
3139
+ setText(elm, text);
2976
3140
  }
3141
+
2977
3142
  function insertNode(node, parent, anchor, renderer) {
2978
- renderer.insert(node, parent, anchor);
3143
+
3144
+ renderer.insert(node, parent, anchor);
2979
3145
  }
3146
+
2980
3147
  function removeNode(node, parent, renderer) {
2981
- renderer.remove(node, parent);
3148
+
3149
+ renderer.remove(node, parent);
2982
3150
  }
3151
+
2983
3152
  function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
2984
- if (isNull(oldVnode)) {
2985
- applyEventListeners(vnode, renderer);
2986
- applyStaticClassAttribute(vnode, renderer);
2987
- applyStaticStyleAttribute(vnode, renderer);
2988
- }
2989
- // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
2990
- // value is set before type=radio.
2991
- patchClassAttribute(oldVnode, vnode, renderer);
2992
- patchStyleAttribute(oldVnode, vnode, renderer);
2993
- patchAttributes(oldVnode, vnode, renderer);
2994
- patchProps(oldVnode, vnode, renderer);
3153
+ if (isNull(oldVnode)) {
3154
+ applyEventListeners(vnode, renderer);
3155
+ applyStaticClassAttribute(vnode, renderer);
3156
+ applyStaticStyleAttribute(vnode, renderer);
3157
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3158
+ // value is set before type=radio.
3159
+
3160
+
3161
+ patchClassAttribute(oldVnode, vnode, renderer);
3162
+ patchStyleAttribute(oldVnode, vnode, renderer);
3163
+ patchAttributes(oldVnode, vnode, renderer);
3164
+ patchProps(oldVnode, vnode, renderer);
2995
3165
  }
3166
+
2996
3167
  function applyStyleScoping(elm, owner, renderer) {
2997
- // Set the class name for `*.scoped.css` style scoping.
2998
- const scopeToken = getScopeTokenClass(owner);
2999
- if (!isNull(scopeToken)) {
3000
- const { getClassList } = renderer;
3001
- // TODO [#2762]: this dot notation with add is probably problematic
3002
- // probably we should have a renderer api for just the add operation
3003
- getClassList(elm).add(scopeToken);
3004
- }
3005
- // Set property element for synthetic shadow DOM style scoping.
3006
- const { stylesheetToken: syntheticToken } = owner.context;
3007
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3008
- elm.$shadowToken$ = syntheticToken;
3009
- }
3168
+ // Set the class name for `*.scoped.css` style scoping.
3169
+ const scopeToken = getScopeTokenClass(owner);
3170
+
3171
+ if (!isNull(scopeToken)) {
3172
+ const {
3173
+ getClassList
3174
+ } = renderer; // TODO [#2762]: this dot notation with add is probably problematic
3175
+ // probably we should have a renderer api for just the add operation
3176
+
3177
+ getClassList(elm).add(scopeToken);
3178
+ } // Set property element for synthetic shadow DOM style scoping.
3179
+
3180
+
3181
+ const {
3182
+ stylesheetToken: syntheticToken
3183
+ } = owner.context;
3184
+
3185
+ if (owner.shadowMode === 1
3186
+ /* ShadowMode.Synthetic */
3187
+ && !isUndefined$1(syntheticToken)) {
3188
+ elm.$shadowToken$ = syntheticToken;
3189
+ }
3010
3190
  }
3191
+
3011
3192
  function applyDomManual(elm, vnode) {
3012
- var _a;
3013
- const { owner, data: { context }, } = vnode;
3014
- 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 */) {
3015
- elm.$domManual$ = true;
3193
+ var _a;
3194
+
3195
+ const {
3196
+ owner,
3197
+ data: {
3198
+ context
3016
3199
  }
3200
+ } = vnode;
3201
+
3202
+ if (owner.shadowMode === 1
3203
+ /* ShadowMode.Synthetic */
3204
+ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
3205
+ /* LwcDomMode.Manual */
3206
+ ) {
3207
+ elm.$domManual$ = true;
3208
+ }
3017
3209
  }
3210
+
3018
3211
  function allocateChildren(vnode, vm) {
3019
- // A component with slots will re-render because:
3020
- // 1- There is a change of the internal state.
3021
- // 2- There is a change on the external api (ex: slots)
3022
- //
3023
- // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3024
- // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3025
- // in a reused VCustomElement, there won't be any slotted children.
3026
- // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3027
- //
3028
- // In case #2, we will always get a fresh VCustomElement.
3029
- const children = vnode.aChildren || vnode.children;
3030
- vm.aChildren = children;
3031
- const { renderMode, shadowMode } = vm;
3032
- if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
3033
- // slow path
3034
- allocateInSlot(vm, children);
3035
- // save the allocated children in case this vnode is reused.
3036
- vnode.aChildren = children;
3037
- // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3038
- vnode.children = EmptyArray;
3039
- }
3212
+ // A component with slots will re-render because:
3213
+ // 1- There is a change of the internal state.
3214
+ // 2- There is a change on the external api (ex: slots)
3215
+ //
3216
+ // In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
3217
+ // slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
3218
+ // in a reused VCustomElement, there won't be any slotted children.
3219
+ // For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
3220
+ //
3221
+ // In case #2, we will always get a fresh VCustomElement.
3222
+ const children = vnode.aChildren || vnode.children;
3223
+ vm.aChildren = children;
3224
+ const {
3225
+ renderMode,
3226
+ shadowMode
3227
+ } = vm;
3228
+
3229
+ if (shadowMode === 1
3230
+ /* ShadowMode.Synthetic */
3231
+ || renderMode === 0
3232
+ /* RenderMode.Light */
3233
+ ) {
3234
+ // slow path
3235
+ allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
3236
+
3237
+ vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
3238
+
3239
+ vnode.children = EmptyArray;
3240
+ }
3040
3241
  }
3242
+
3041
3243
  function createViewModelHook(elm, vnode, renderer) {
3042
- let vm = getAssociatedVMIfPresent(elm);
3043
- // There is a possibility that a custom element is registered under tagName, in which case, the
3044
- // initialization is already carry on, and there is nothing else to do here since this hook is
3045
- // called right after invoking `document.createElement`.
3046
- if (!isUndefined$1(vm)) {
3047
- return vm;
3048
- }
3049
- const { sel, mode, ctor, owner } = vnode;
3050
- vm = createVM(elm, ctor, renderer, {
3051
- mode,
3052
- owner,
3053
- tagName: sel,
3054
- });
3244
+ let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
3245
+ // initialization is already carry on, and there is nothing else to do here since this hook is
3246
+ // called right after invoking `document.createElement`.
3247
+
3248
+ if (!isUndefined$1(vm)) {
3055
3249
  return vm;
3056
- }
3057
- function allocateInSlot(vm, children) {
3058
- var _a;
3059
- const { cmpSlots: oldSlots } = vm;
3060
- const cmpSlots = (vm.cmpSlots = create(null));
3061
- for (let i = 0, len = children.length; i < len; i += 1) {
3062
- const vnode = children[i];
3063
- if (isNull(vnode)) {
3064
- continue;
3065
- }
3066
- let slotName = '';
3067
- if (isVBaseElement(vnode)) {
3068
- slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3069
- }
3070
- const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3071
- ArrayPush$1.call(vnodes, vnode);
3072
- }
3073
- if (isFalse(vm.isDirty)) {
3074
- // We need to determine if the old allocation is really different from the new one
3075
- // and mark the vm as dirty
3076
- const oldKeys = keys(oldSlots);
3077
- if (oldKeys.length !== keys(cmpSlots).length) {
3078
- markComponentAsDirty(vm);
3079
- return;
3080
- }
3081
- for (let i = 0, len = oldKeys.length; i < len; i += 1) {
3082
- const key = oldKeys[i];
3083
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3084
- markComponentAsDirty(vm);
3085
- return;
3086
- }
3087
- const oldVNodes = oldSlots[key];
3088
- const vnodes = cmpSlots[key];
3089
- for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3090
- if (oldVNodes[j] !== vnodes[j]) {
3091
- markComponentAsDirty(vm);
3092
- return;
3093
- }
3094
- }
3250
+ }
3251
+
3252
+ const {
3253
+ sel,
3254
+ mode,
3255
+ ctor,
3256
+ owner
3257
+ } = vnode;
3258
+ vm = createVM(elm, ctor, renderer, {
3259
+ mode,
3260
+ owner,
3261
+ tagName: sel
3262
+ });
3263
+
3264
+ return vm;
3265
+ }
3266
+
3267
+ function allocateInSlot(vm, children) {
3268
+ var _a;
3269
+
3270
+ const {
3271
+ cmpSlots: oldSlots
3272
+ } = vm;
3273
+ const cmpSlots = vm.cmpSlots = create(null);
3274
+
3275
+ for (let i = 0, len = children.length; i < len; i += 1) {
3276
+ const vnode = children[i];
3277
+
3278
+ if (isNull(vnode)) {
3279
+ continue;
3280
+ }
3281
+
3282
+ let slotName = '';
3283
+
3284
+ if (isVBaseElement(vnode)) {
3285
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3286
+ }
3287
+
3288
+ const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
3289
+ ArrayPush$1.call(vnodes, vnode);
3290
+ }
3291
+
3292
+ if (isFalse(vm.isDirty)) {
3293
+ // We need to determine if the old allocation is really different from the new one
3294
+ // and mark the vm as dirty
3295
+ const oldKeys = keys(oldSlots);
3296
+
3297
+ if (oldKeys.length !== keys(cmpSlots).length) {
3298
+ markComponentAsDirty(vm);
3299
+ return;
3300
+ }
3301
+
3302
+ for (let i = 0, len = oldKeys.length; i < len; i += 1) {
3303
+ const key = oldKeys[i];
3304
+
3305
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3306
+ markComponentAsDirty(vm);
3307
+ return;
3308
+ }
3309
+
3310
+ const oldVNodes = oldSlots[key];
3311
+ const vnodes = cmpSlots[key];
3312
+
3313
+ for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3314
+ if (oldVNodes[j] !== vnodes[j]) {
3315
+ markComponentAsDirty(vm);
3316
+ return;
3095
3317
  }
3318
+ }
3096
3319
  }
3097
- }
3098
- // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3099
- const FromIteration = new WeakMap();
3100
- // dynamic children means it was generated by an iteration
3320
+ }
3321
+ } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3322
+
3323
+
3324
+ const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
3101
3325
  // in a template, and will require a more complex diffing algo.
3326
+
3102
3327
  function markAsDynamicChildren(children) {
3103
- FromIteration.set(children, 1);
3328
+ FromIteration.set(children, 1);
3104
3329
  }
3330
+
3105
3331
  function hasDynamicChildren(children) {
3106
- return FromIteration.has(children);
3332
+ return FromIteration.has(children);
3107
3333
  }
3334
+
3108
3335
  function createKeyToOldIdx(children, beginIdx, endIdx) {
3109
- const map = {};
3110
- // TODO [#1637]: simplify this by assuming that all vnodes has keys
3111
- for (let j = beginIdx; j <= endIdx; ++j) {
3112
- const ch = children[j];
3113
- if (isVNode(ch)) {
3114
- const { key } = ch;
3115
- if (key !== undefined) {
3116
- map[key] = j;
3117
- }
3118
- }
3336
+ const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
3337
+
3338
+ for (let j = beginIdx; j <= endIdx; ++j) {
3339
+ const ch = children[j];
3340
+
3341
+ if (isVNode(ch)) {
3342
+ const {
3343
+ key
3344
+ } = ch;
3345
+
3346
+ if (key !== undefined) {
3347
+ map[key] = j;
3348
+ }
3119
3349
  }
3120
- return map;
3350
+ }
3351
+
3352
+ return map;
3121
3353
  }
3354
+
3122
3355
  function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3123
- let oldStartIdx = 0;
3124
- let newStartIdx = 0;
3125
- let oldEndIdx = oldCh.length - 1;
3126
- let oldStartVnode = oldCh[0];
3127
- let oldEndVnode = oldCh[oldEndIdx];
3128
- const newChEnd = newCh.length - 1;
3129
- let newEndIdx = newChEnd;
3130
- let newStartVnode = newCh[0];
3131
- let newEndVnode = newCh[newEndIdx];
3132
- let oldKeyToIdx;
3133
- let idxInOld;
3134
- let elmToMove;
3135
- let before;
3136
- let clonedOldCh = false;
3137
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3138
- if (!isVNode(oldStartVnode)) {
3139
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
3140
- }
3141
- else if (!isVNode(oldEndVnode)) {
3142
- oldEndVnode = oldCh[--oldEndIdx];
3143
- }
3144
- else if (!isVNode(newStartVnode)) {
3145
- newStartVnode = newCh[++newStartIdx];
3146
- }
3147
- else if (!isVNode(newEndVnode)) {
3148
- newEndVnode = newCh[--newEndIdx];
3149
- }
3150
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
3151
- patch(oldStartVnode, newStartVnode, parent, renderer);
3152
- oldStartVnode = oldCh[++oldStartIdx];
3153
- newStartVnode = newCh[++newStartIdx];
3154
- }
3155
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
3156
- patch(oldEndVnode, newEndVnode, parent, renderer);
3157
- oldEndVnode = oldCh[--oldEndIdx];
3158
- newEndVnode = newCh[--newEndIdx];
3159
- }
3160
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
3161
- // Vnode moved right
3162
- patch(oldStartVnode, newEndVnode, parent, renderer);
3163
- insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3164
- oldStartVnode = oldCh[++oldStartIdx];
3165
- newEndVnode = newCh[--newEndIdx];
3166
- }
3167
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
3168
- // Vnode moved left
3169
- patch(oldEndVnode, newStartVnode, parent, renderer);
3170
- insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3171
- oldEndVnode = oldCh[--oldEndIdx];
3172
- newStartVnode = newCh[++newStartIdx];
3173
- }
3174
- else {
3175
- if (oldKeyToIdx === undefined) {
3176
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
3177
- }
3178
- idxInOld = oldKeyToIdx[newStartVnode.key];
3179
- if (isUndefined$1(idxInOld)) {
3180
- // New element
3181
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3182
- newStartVnode = newCh[++newStartIdx];
3183
- }
3184
- else {
3185
- elmToMove = oldCh[idxInOld];
3186
- if (isVNode(elmToMove)) {
3187
- if (elmToMove.sel !== newStartVnode.sel) {
3188
- // New element
3189
- mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3190
- }
3191
- else {
3192
- patch(elmToMove, newStartVnode, parent, renderer);
3193
- // Delete the old child, but copy the array since it is read-only.
3194
- // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3195
- // so we only care about the `oldCh` object inside this function.
3196
- // To avoid cloning over and over again, we check `clonedOldCh`
3197
- // and only clone once.
3198
- if (!clonedOldCh) {
3199
- clonedOldCh = true;
3200
- oldCh = [...oldCh];
3201
- }
3202
- // We've already cloned at least once, so it's no longer read-only
3203
- oldCh[idxInOld] = undefined;
3204
- insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
3205
- }
3206
- }
3207
- newStartVnode = newCh[++newStartIdx];
3208
- }
3356
+ let oldStartIdx = 0;
3357
+ let newStartIdx = 0;
3358
+ let oldEndIdx = oldCh.length - 1;
3359
+ let oldStartVnode = oldCh[0];
3360
+ let oldEndVnode = oldCh[oldEndIdx];
3361
+ const newChEnd = newCh.length - 1;
3362
+ let newEndIdx = newChEnd;
3363
+ let newStartVnode = newCh[0];
3364
+ let newEndVnode = newCh[newEndIdx];
3365
+ let oldKeyToIdx;
3366
+ let idxInOld;
3367
+ let elmToMove;
3368
+ let before;
3369
+ let clonedOldCh = false;
3370
+
3371
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3372
+ if (!isVNode(oldStartVnode)) {
3373
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
3374
+ } else if (!isVNode(oldEndVnode)) {
3375
+ oldEndVnode = oldCh[--oldEndIdx];
3376
+ } else if (!isVNode(newStartVnode)) {
3377
+ newStartVnode = newCh[++newStartIdx];
3378
+ } else if (!isVNode(newEndVnode)) {
3379
+ newEndVnode = newCh[--newEndIdx];
3380
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3381
+ patch(oldStartVnode, newStartVnode, parent, renderer);
3382
+ oldStartVnode = oldCh[++oldStartIdx];
3383
+ newStartVnode = newCh[++newStartIdx];
3384
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3385
+ patch(oldEndVnode, newEndVnode, parent, renderer);
3386
+ oldEndVnode = oldCh[--oldEndIdx];
3387
+ newEndVnode = newCh[--newEndIdx];
3388
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3389
+ // Vnode moved right
3390
+ patch(oldStartVnode, newEndVnode, parent, renderer);
3391
+ insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3392
+ oldStartVnode = oldCh[++oldStartIdx];
3393
+ newEndVnode = newCh[--newEndIdx];
3394
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3395
+ // Vnode moved left
3396
+ patch(oldEndVnode, newStartVnode, parent, renderer);
3397
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3398
+ oldEndVnode = oldCh[--oldEndIdx];
3399
+ newStartVnode = newCh[++newStartIdx];
3400
+ } else {
3401
+ if (oldKeyToIdx === undefined) {
3402
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
3403
+ }
3404
+
3405
+ idxInOld = oldKeyToIdx[newStartVnode.key];
3406
+
3407
+ if (isUndefined$1(idxInOld)) {
3408
+ // New element
3409
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3410
+ newStartVnode = newCh[++newStartIdx];
3411
+ } else {
3412
+ elmToMove = oldCh[idxInOld];
3413
+
3414
+ if (isVNode(elmToMove)) {
3415
+ if (elmToMove.sel !== newStartVnode.sel) {
3416
+ // New element
3417
+ mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3418
+ } else {
3419
+ patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
3420
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3421
+ // so we only care about the `oldCh` object inside this function.
3422
+ // To avoid cloning over and over again, we check `clonedOldCh`
3423
+ // and only clone once.
3424
+
3425
+ if (!clonedOldCh) {
3426
+ clonedOldCh = true;
3427
+ oldCh = [...oldCh];
3428
+ } // We've already cloned at least once, so it's no longer read-only
3429
+
3430
+
3431
+ oldCh[idxInOld] = undefined;
3432
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
3433
+ }
3209
3434
  }
3435
+
3436
+ newStartVnode = newCh[++newStartIdx];
3437
+ }
3210
3438
  }
3211
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
3212
- if (oldStartIdx > oldEndIdx) {
3213
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3214
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3215
- let i = newEndIdx;
3216
- let n;
3217
- do {
3218
- n = newCh[++i];
3219
- } while (!isVNode(n) && i < newChEnd);
3220
- before = isVNode(n) ? n.elm : null;
3221
- mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3222
- }
3223
- else {
3224
- unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3225
- }
3439
+ }
3440
+
3441
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
3442
+ if (oldStartIdx > oldEndIdx) {
3443
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3444
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3445
+ let i = newEndIdx;
3446
+ let n;
3447
+
3448
+ do {
3449
+ n = newCh[++i];
3450
+ } while (!isVNode(n) && i < newChEnd);
3451
+
3452
+ before = isVNode(n) ? n.elm : null;
3453
+ mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
3454
+ } else {
3455
+ unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
3226
3456
  }
3457
+ }
3227
3458
  }
3459
+
3228
3460
  function updateStaticChildren(c1, c2, parent, renderer) {
3229
- const c1Length = c1.length;
3230
- const c2Length = c2.length;
3231
- if (c1Length === 0) {
3232
- // the old list is empty, we can directly insert anything new
3233
- mountVNodes(c2, parent, renderer, null);
3234
- return;
3235
- }
3236
- if (c2Length === 0) {
3237
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3238
- // this is the case in which the dynamic children of an if-directive should be removed
3239
- unmountVNodes(c1, parent, renderer, true);
3240
- return;
3241
- }
3242
- // if the old list is not empty, the new list MUST have the same
3243
- // amount of nodes, that's why we call this static children
3244
- let anchor = null;
3245
- for (let i = c2Length - 1; i >= 0; i -= 1) {
3246
- const n1 = c1[i];
3247
- const n2 = c2[i];
3248
- if (n2 !== n1) {
3249
- if (isVNode(n1)) {
3250
- if (isVNode(n2)) {
3251
- // both vnodes are equivalent, and we just need to patch them
3252
- patch(n1, n2, parent, renderer);
3253
- anchor = n2.elm;
3254
- }
3255
- else {
3256
- // removing the old vnode since the new one is null
3257
- unmount(n1, parent, renderer, true);
3258
- }
3259
- }
3260
- else if (isVNode(n2)) {
3261
- mount(n2, parent, renderer, anchor);
3262
- anchor = n2.elm;
3263
- }
3461
+ const c1Length = c1.length;
3462
+ const c2Length = c2.length;
3463
+
3464
+ if (c1Length === 0) {
3465
+ // the old list is empty, we can directly insert anything new
3466
+ mountVNodes(c2, parent, renderer, null);
3467
+ return;
3468
+ }
3469
+
3470
+ if (c2Length === 0) {
3471
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3472
+ // this is the case in which the dynamic children of an if-directive should be removed
3473
+ unmountVNodes(c1, parent, renderer, true);
3474
+ return;
3475
+ } // if the old list is not empty, the new list MUST have the same
3476
+ // amount of nodes, that's why we call this static children
3477
+
3478
+
3479
+ let anchor = null;
3480
+
3481
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
3482
+ const n1 = c1[i];
3483
+ const n2 = c2[i];
3484
+
3485
+ if (n2 !== n1) {
3486
+ if (isVNode(n1)) {
3487
+ if (isVNode(n2)) {
3488
+ // both vnodes are equivalent, and we just need to patch them
3489
+ patch(n1, n2, parent, renderer);
3490
+ anchor = n2.elm;
3491
+ } else {
3492
+ // removing the old vnode since the new one is null
3493
+ unmount(n1, parent, renderer, true);
3264
3494
  }
3495
+ } else if (isVNode(n2)) {
3496
+ mount(n2, parent, renderer, anchor);
3497
+ anchor = n2.elm;
3498
+ }
3265
3499
  }
3500
+ }
3266
3501
  }
3267
3502
 
3268
3503
  /*
@@ -4096,7 +4331,7 @@
4096
4331
  } else if (isNativeShadowDefined) {
4097
4332
  // Not combined with above condition because @lwc/features only supports identifiers in
4098
4333
  // the if-condition.
4099
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
4334
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
4100
4335
  if (def.shadowSupportMode === "any"
4101
4336
  /* ShadowSupportMode.Any */
4102
4337
  ) {
@@ -4757,7 +4992,7 @@
4757
4992
  ArrayPush$1.call(wiredConnecting, () => {
4758
4993
  connector.connect();
4759
4994
 
4760
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
4995
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
4761
4996
  if (hasDynamicParams) {
4762
4997
  Promise.resolve().then(computeConfigAndUpdate);
4763
4998
  return;
@@ -4897,6 +5132,7 @@
4897
5132
  }
4898
5133
  return renderer.nextSibling(hydratedNode);
4899
5134
  }
5135
+ const NODE_VALUE_PROP = 'nodeValue';
4900
5136
  function hydrateText(node, vnode, renderer) {
4901
5137
  var _a;
4902
5138
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -4913,7 +5149,7 @@
4913
5149
  return handleMismatch(node, vnode, renderer);
4914
5150
  }
4915
5151
  const { setProperty } = renderer;
4916
- setProperty(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5152
+ setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
4917
5153
  vnode.elm = node;
4918
5154
  return node;
4919
5155
  }
@@ -5134,13 +5370,13 @@
5134
5370
  if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
5135
5371
  return false;
5136
5372
  }
5137
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
5373
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
5138
5374
  }
5139
5375
  if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
5140
5376
  if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
5141
5377
  return false;
5142
5378
  }
5143
- return getProperty(client, 'nodeValue') === getProperty(ssr, 'nodeValue');
5379
+ return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
5144
5380
  }
5145
5381
  if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
5146
5382
  return false;
@@ -5198,7 +5434,7 @@
5198
5434
  }
5199
5435
  return ctor;
5200
5436
  }
5201
- /* version: 2.23.0 */
5437
+ /* version: 2.23.3 */
5202
5438
 
5203
5439
  /*
5204
5440
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5339,61 +5575,303 @@
5339
5575
  * SPDX-License-Identifier: MIT
5340
5576
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5341
5577
  */
5342
- const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
5343
- let createFragment;
5344
- if (SUPPORTS_TEMPLATE) {
5345
- // Parse the fragment HTML string into DOM
5346
- createFragment = function (html) {
5347
- const template = document.createElement('template');
5348
- template.innerHTML = html;
5349
- return template.content.firstChild;
5350
- };
5351
- }
5352
- else {
5353
- // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
5354
- // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
5355
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
5356
- // With other elements added from:
5357
- // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
5358
- // Using the test:
5359
- // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
5360
- // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
5361
- const topLevelWrappingMap = {
5362
- caption: ['table'],
5363
- col: ['colgroup', 'table'],
5364
- colgroup: ['table'],
5365
- option: ['select'],
5366
- tbody: ['table'],
5367
- td: ['tr', 'tbody', 'table'],
5368
- th: ['tr', 'tbody', 'table'],
5369
- thead: ['table'],
5370
- tfoot: ['table'],
5371
- tr: ['tbody', 'table'],
5372
- };
5373
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
5374
- const getTagName = function (text) {
5375
- return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
5376
- };
5377
- // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
5378
- createFragment = function (html) {
5379
- const wrapperTags = topLevelWrappingMap[getTagName(html)];
5380
- if (!isUndefined$1(wrapperTags)) {
5381
- for (const wrapperTag of wrapperTags) {
5382
- html = `<${wrapperTag}>${html}</${wrapperTag}>`;
5578
+ /**
5579
+ * A factory function that produces a renderer.
5580
+ * Renderer encapsulates operations that are required to render an LWC component into the underlying
5581
+ * runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
5582
+ * Example usage:
5583
+ * import { renderer, rendererFactory } from 'lwc';
5584
+ * const customRenderer = rendererFactory(renderer);
5585
+ *
5586
+ * @param baseRenderer Either null or the base renderer imported from 'lwc'.
5587
+ */
5588
+ function rendererFactory(baseRenderer) {
5589
+ // Util functions
5590
+ function assertInvariant(value, msg) {
5591
+ if (!value) {
5592
+ throw new Error(`Invariant Violation: ${msg}`);
5593
+ }
5594
+ }
5595
+ function isNull(obj) {
5596
+ return obj === null;
5597
+ }
5598
+ function isUndefined(obj) {
5599
+ return obj === undefined;
5600
+ }
5601
+ let getCustomElement;
5602
+ let defineCustomElement;
5603
+ let HTMLElementConstructor;
5604
+ function isCustomElementRegistryAvailable() {
5605
+ if (typeof customElements === 'undefined') {
5606
+ return false;
5607
+ }
5608
+ try {
5609
+ // dereference HTMLElement global because babel wraps globals in compat mode with a
5610
+ // _wrapNativeSuper()
5611
+ // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
5612
+ // get wrapped by babel.
5613
+ const HTMLElementAlias = HTMLElement;
5614
+ // In case we use compat mode with a modern browser, the compat mode transformation
5615
+ // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
5616
+ // which are not equipped to be initialized that way.
5617
+ class clazz extends HTMLElementAlias {
5383
5618
  }
5619
+ customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
5620
+ new clazz();
5621
+ return true;
5622
+ }
5623
+ catch (_a) {
5624
+ return false;
5384
5625
  }
5385
- // For IE11, the document title must not be undefined, but it can be an empty string
5386
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
5387
- const doc = document.implementation.createHTMLDocument('');
5388
- doc.body.innerHTML = html;
5389
- let content = doc.body;
5390
- if (!isUndefined$1(wrapperTags)) {
5391
- for (let i = 0; i < wrapperTags.length; i++) {
5392
- content = content.firstChild;
5626
+ }
5627
+ if (isCustomElementRegistryAvailable()) {
5628
+ getCustomElement = customElements.get.bind(customElements);
5629
+ defineCustomElement = customElements.define.bind(customElements);
5630
+ HTMLElementConstructor = HTMLElement;
5631
+ }
5632
+ else {
5633
+ const registry = Object.create(null);
5634
+ const reverseRegistry = new WeakMap();
5635
+ defineCustomElement = function define(name, ctor) {
5636
+ if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
5637
+ throw new TypeError(`Invalid Registration`);
5638
+ }
5639
+ registry[name] = ctor;
5640
+ reverseRegistry.set(ctor, name);
5641
+ };
5642
+ getCustomElement = function get(name) {
5643
+ return registry[name];
5644
+ };
5645
+ HTMLElementConstructor = function HTMLElement() {
5646
+ if (!(this instanceof HTMLElement)) {
5647
+ throw new TypeError(`Invalid Invocation`);
5648
+ }
5649
+ const { constructor } = this;
5650
+ const name = reverseRegistry.get(constructor);
5651
+ if (!name) {
5652
+ throw new TypeError(`Invalid Construction`);
5653
+ }
5654
+ const elm = document.createElement(name);
5655
+ Object.setPrototypeOf(elm, constructor.prototype);
5656
+ return elm;
5657
+ };
5658
+ HTMLElementConstructor.prototype = HTMLElement.prototype;
5659
+ }
5660
+ function cloneNode(node, deep) {
5661
+ return node.cloneNode(deep);
5662
+ }
5663
+ function createElement(tagName, namespace) {
5664
+ return isUndefined(namespace)
5665
+ ? document.createElement(tagName)
5666
+ : document.createElementNS(namespace, tagName);
5667
+ }
5668
+ function createText(content) {
5669
+ return document.createTextNode(content);
5670
+ }
5671
+ function createComment(content) {
5672
+ return document.createComment(content);
5673
+ }
5674
+ let createFragment;
5675
+ // IE11 lacks support for this feature
5676
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
5677
+ if (SUPPORTS_TEMPLATE) {
5678
+ // Parse the fragment HTML string into DOM
5679
+ createFragment = function (html) {
5680
+ const template = document.createElement('template');
5681
+ template.innerHTML = html;
5682
+ return template.content.firstChild;
5683
+ };
5684
+ }
5685
+ else {
5686
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
5687
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
5688
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
5689
+ // With other elements added from:
5690
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
5691
+ // Using the test:
5692
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
5693
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
5694
+ const topLevelWrappingMap = {
5695
+ caption: ['table'],
5696
+ col: ['colgroup', 'table'],
5697
+ colgroup: ['table'],
5698
+ option: ['select'],
5699
+ tbody: ['table'],
5700
+ td: ['tr', 'tbody', 'table'],
5701
+ th: ['tr', 'tbody', 'table'],
5702
+ thead: ['table'],
5703
+ tfoot: ['table'],
5704
+ tr: ['tbody', 'table'],
5705
+ };
5706
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
5707
+ const getTagName = function (text) {
5708
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
5709
+ };
5710
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
5711
+ createFragment = function (html) {
5712
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
5713
+ if (!isUndefined(wrapperTags)) {
5714
+ for (const wrapperTag of wrapperTags) {
5715
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
5716
+ }
5717
+ }
5718
+ // For IE11, the document title must not be undefined, but it can be an empty string
5719
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
5720
+ const doc = document.implementation.createHTMLDocument('');
5721
+ doc.body.innerHTML = html;
5722
+ let content = doc.body;
5723
+ if (!isUndefined(wrapperTags)) {
5724
+ for (let i = 0; i < wrapperTags.length; i++) {
5725
+ content = content.firstChild;
5726
+ }
5393
5727
  }
5728
+ return content.firstChild;
5729
+ };
5730
+ }
5731
+ function insert(node, parent, anchor) {
5732
+ parent.insertBefore(node, anchor);
5733
+ }
5734
+ function remove(node, parent) {
5735
+ parent.removeChild(node);
5736
+ }
5737
+ function nextSibling(node) {
5738
+ return node.nextSibling;
5739
+ }
5740
+ function attachShadow(element, options) {
5741
+ // `shadowRoot` will be non-null in two cases:
5742
+ // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
5743
+ // 2. when a webapp author places <c-app> in their static HTML and mounts their
5744
+ // root component with customElement.define('c-app', Ctor)
5745
+ if (!isNull(element.shadowRoot)) {
5746
+ return element.shadowRoot;
5394
5747
  }
5395
- return content.firstChild;
5748
+ return element.attachShadow(options);
5749
+ }
5750
+ function setText(node, content) {
5751
+ node.nodeValue = content;
5752
+ }
5753
+ function getProperty(node, key) {
5754
+ return node[key];
5755
+ }
5756
+ function setProperty(node, key, value) {
5757
+ node[key] = value;
5758
+ }
5759
+ function getAttribute(element, name, namespace) {
5760
+ return isUndefined(namespace)
5761
+ ? element.getAttribute(name)
5762
+ : element.getAttributeNS(namespace, name);
5763
+ }
5764
+ function setAttribute(element, name, value, namespace) {
5765
+ return isUndefined(namespace)
5766
+ ? element.setAttribute(name, value)
5767
+ : element.setAttributeNS(namespace, name, value);
5768
+ }
5769
+ function removeAttribute(element, name, namespace) {
5770
+ if (isUndefined(namespace)) {
5771
+ element.removeAttribute(name);
5772
+ }
5773
+ else {
5774
+ element.removeAttributeNS(namespace, name);
5775
+ }
5776
+ }
5777
+ function addEventListener(target, type, callback, options) {
5778
+ target.addEventListener(type, callback, options);
5779
+ }
5780
+ function removeEventListener(target, type, callback, options) {
5781
+ target.removeEventListener(type, callback, options);
5782
+ }
5783
+ function dispatchEvent(target, event) {
5784
+ return target.dispatchEvent(event);
5785
+ }
5786
+ function getClassList(element) {
5787
+ return element.classList;
5788
+ }
5789
+ function setCSSStyleProperty(element, name, value, important) {
5790
+ // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
5791
+ // represent elements in the engine?
5792
+ element.style.setProperty(name, value, important ? 'important' : '');
5793
+ }
5794
+ function getBoundingClientRect(element) {
5795
+ return element.getBoundingClientRect();
5796
+ }
5797
+ function querySelector(element, selectors) {
5798
+ return element.querySelector(selectors);
5799
+ }
5800
+ function querySelectorAll(element, selectors) {
5801
+ return element.querySelectorAll(selectors);
5802
+ }
5803
+ function getElementsByTagName(element, tagNameOrWildCard) {
5804
+ return element.getElementsByTagName(tagNameOrWildCard);
5805
+ }
5806
+ function getElementsByClassName(element, names) {
5807
+ return element.getElementsByClassName(names);
5808
+ }
5809
+ function getChildren(element) {
5810
+ return element.children;
5811
+ }
5812
+ function getChildNodes(element) {
5813
+ return element.childNodes;
5814
+ }
5815
+ function getFirstChild(element) {
5816
+ return element.firstChild;
5817
+ }
5818
+ function getFirstElementChild(element) {
5819
+ return element.firstElementChild;
5820
+ }
5821
+ function getLastChild(element) {
5822
+ return element.lastChild;
5823
+ }
5824
+ function getLastElementChild(element) {
5825
+ return element.lastElementChild;
5826
+ }
5827
+ function isConnected(node) {
5828
+ return node.isConnected;
5829
+ }
5830
+ function assertInstanceOfHTMLElement(elm, msg) {
5831
+ assertInvariant(elm instanceof HTMLElement, msg);
5832
+ }
5833
+ const HTMLElementExported = HTMLElementConstructor;
5834
+ const renderer = {
5835
+ HTMLElementExported,
5836
+ insert,
5837
+ remove,
5838
+ cloneNode,
5839
+ createFragment,
5840
+ createElement,
5841
+ createText,
5842
+ createComment,
5843
+ nextSibling,
5844
+ attachShadow,
5845
+ getProperty,
5846
+ setProperty,
5847
+ setText,
5848
+ getAttribute,
5849
+ setAttribute,
5850
+ removeAttribute,
5851
+ addEventListener,
5852
+ removeEventListener,
5853
+ dispatchEvent,
5854
+ getClassList,
5855
+ setCSSStyleProperty,
5856
+ getBoundingClientRect,
5857
+ querySelector,
5858
+ querySelectorAll,
5859
+ getElementsByTagName,
5860
+ getElementsByClassName,
5861
+ getChildren,
5862
+ getChildNodes,
5863
+ getFirstChild,
5864
+ getFirstElementChild,
5865
+ getLastChild,
5866
+ getLastElementChild,
5867
+ isConnected,
5868
+ assertInstanceOfHTMLElement,
5869
+ defineCustomElement,
5870
+ getCustomElement,
5396
5871
  };
5872
+ // Meant to inherit any properties passed via the base renderer as the argument to the factory.
5873
+ Object.setPrototypeOf(renderer, baseRenderer);
5874
+ return renderer;
5397
5875
  }
5398
5876
 
5399
5877
  /*
@@ -5402,225 +5880,21 @@
5402
5880
  * SPDX-License-Identifier: MIT
5403
5881
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5404
5882
  */
5405
- let getCustomElement;
5406
- let defineCustomElement;
5407
- let HTMLElementConstructor;
5408
- function isCustomElementRegistryAvailable() {
5409
- if (typeof customElements === 'undefined') {
5410
- return false;
5411
- }
5412
- try {
5413
- // dereference HTMLElement global because babel wraps globals in compat mode with a
5414
- // _wrapNativeSuper()
5415
- // This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
5416
- // get wrapped by babel.
5417
- const HTMLElementAlias = HTMLElement;
5418
- // In case we use compat mode with a modern browser, the compat mode transformation
5419
- // invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
5420
- // which are not equipped to be initialized that way.
5421
- class clazz extends HTMLElementAlias {
5422
- }
5423
- customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
5424
- new clazz();
5425
- return true;
5426
- }
5427
- catch (_a) {
5428
- return false;
5429
- }
5430
- }
5431
- if (isCustomElementRegistryAvailable()) {
5432
- getCustomElement = customElements.get.bind(customElements);
5433
- defineCustomElement = customElements.define.bind(customElements);
5434
- HTMLElementConstructor = HTMLElement;
5435
- }
5436
- else {
5437
- const registry = create(null);
5438
- const reverseRegistry = new WeakMap();
5439
- defineCustomElement = function define(name, ctor) {
5440
- if (name !== StringToLowerCase.call(name) || registry[name]) {
5441
- throw new TypeError(`Invalid Registration`);
5442
- }
5443
- registry[name] = ctor;
5444
- reverseRegistry.set(ctor, name);
5445
- };
5446
- getCustomElement = function get(name) {
5447
- return registry[name];
5448
- };
5449
- HTMLElementConstructor = function HTMLElement() {
5450
- if (!(this instanceof HTMLElement)) {
5451
- throw new TypeError(`Invalid Invocation`);
5452
- }
5453
- const { constructor } = this;
5454
- const name = reverseRegistry.get(constructor);
5455
- if (!name) {
5456
- throw new TypeError(`Invalid Construction`);
5457
- }
5458
- const elm = document.createElement(name);
5459
- setPrototypeOf(elm, constructor.prototype);
5460
- return elm;
5461
- };
5462
- HTMLElementConstructor.prototype = HTMLElement.prototype;
5463
- }
5464
- const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5465
- const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5466
- function cloneNode(node, deep) {
5467
- return node.cloneNode(deep);
5468
- }
5469
- function createElement$1(tagName, namespace) {
5470
- return isUndefined$1(namespace)
5471
- ? document.createElement(tagName)
5472
- : document.createElementNS(namespace, tagName);
5473
- }
5474
- function createText(content) {
5475
- return document.createTextNode(content);
5476
- }
5477
- function createComment(content) {
5478
- return document.createComment(content);
5479
- }
5480
- function insert(node, parent, anchor) {
5481
- parent.insertBefore(node, anchor);
5482
- }
5483
- function remove(node, parent) {
5484
- parent.removeChild(node);
5485
- }
5486
- function nextSibling(node) {
5487
- return node.nextSibling;
5488
- }
5489
- function attachShadow(element, options) {
5490
- // `shadowRoot` will be non-null in two cases:
5491
- // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
5492
- // 2. when a webapp author places <c-app> in their static HTML and mounts their
5493
- // root component with customElement.define('c-app', Ctor)
5494
- if (!isNull(element.shadowRoot)) {
5495
- return element.shadowRoot;
5496
- }
5497
- return element.attachShadow(options);
5498
- }
5499
- function setText(node, content) {
5500
- node.nodeValue = content;
5501
- }
5502
- function getProperty(node, key) {
5503
- return node[key];
5504
- }
5505
- function setProperty(node, key, value) {
5506
- node[key] = value;
5507
- }
5508
- function getAttribute(element, name, namespace) {
5509
- return isUndefined$1(namespace)
5510
- ? element.getAttribute(name)
5511
- : element.getAttributeNS(namespace, name);
5512
- }
5513
- function setAttribute(element, name, value, namespace) {
5514
- return isUndefined$1(namespace)
5515
- ? element.setAttribute(name, value)
5516
- : element.setAttributeNS(namespace, name, value);
5517
- }
5518
- function removeAttribute(element, name, namespace) {
5519
- if (isUndefined$1(namespace)) {
5520
- element.removeAttribute(name);
5521
- }
5522
- else {
5523
- element.removeAttributeNS(namespace, name);
5524
- }
5525
- }
5526
- function addEventListener(target, type, callback, options) {
5527
- target.addEventListener(type, callback, options);
5528
- }
5529
- function removeEventListener(target, type, callback, options) {
5530
- target.removeEventListener(type, callback, options);
5531
- }
5532
- function dispatchEvent(target, event) {
5533
- return target.dispatchEvent(event);
5534
- }
5535
- function getClassList(element) {
5536
- return element.classList;
5537
- }
5538
- function setCSSStyleProperty(element, name, value, important) {
5539
- // TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
5540
- // represent elements in the engine?
5541
- element.style.setProperty(name, value, important ? 'important' : '');
5542
- }
5543
- function getBoundingClientRect(element) {
5544
- return element.getBoundingClientRect();
5545
- }
5546
- function querySelector(element, selectors) {
5547
- return element.querySelector(selectors);
5548
- }
5549
- function querySelectorAll(element, selectors) {
5550
- return element.querySelectorAll(selectors);
5551
- }
5552
- function getElementsByTagName(element, tagNameOrWildCard) {
5553
- return element.getElementsByTagName(tagNameOrWildCard);
5554
- }
5555
- function getElementsByClassName(element, names) {
5556
- return element.getElementsByClassName(names);
5557
- }
5558
- function getChildren(element) {
5559
- return element.children;
5560
- }
5561
- function getChildNodes(element) {
5562
- return element.childNodes;
5563
- }
5564
- function getFirstChild(element) {
5565
- return element.firstChild;
5566
- }
5567
- function getFirstElementChild(element) {
5568
- return element.firstElementChild;
5569
- }
5570
- function getLastChild(element) {
5571
- return element.lastChild;
5572
- }
5573
- function getLastElementChild(element) {
5574
- return element.lastElementChild;
5575
- }
5576
- function isConnected(node) {
5577
- return node.isConnected;
5578
- }
5579
- function assertInstanceOfHTMLElement(elm, msg) {
5580
- assert.invariant(elm instanceof HTMLElement, msg);
5581
- }
5582
- const HTMLElementExported = HTMLElementConstructor;
5583
- const renderer = {
5584
- isNativeShadowDefined,
5585
- isSyntheticShadowDefined,
5586
- HTMLElementExported,
5587
- insert,
5588
- remove,
5589
- cloneNode,
5590
- createFragment,
5591
- createElement: createElement$1,
5592
- createText,
5593
- createComment,
5594
- nextSibling,
5595
- attachShadow,
5596
- getProperty,
5597
- setProperty,
5598
- setText,
5599
- getAttribute,
5600
- setAttribute,
5601
- removeAttribute,
5602
- addEventListener,
5603
- removeEventListener,
5604
- dispatchEvent,
5605
- getClassList,
5606
- setCSSStyleProperty,
5607
- getBoundingClientRect,
5608
- querySelector,
5609
- querySelectorAll,
5610
- getElementsByTagName,
5611
- getElementsByClassName,
5612
- getChildren,
5613
- getChildNodes,
5614
- getFirstChild,
5615
- getFirstElementChild,
5616
- getLastChild,
5617
- getLastElementChild,
5618
- isConnected,
5883
+ /**
5884
+ * The base renderer that will be used by engine-core.
5885
+ * This will be used for DOM operations when lwc is running in a browser environment.
5886
+ */
5887
+ const renderer = assign(
5888
+ // The base renderer will invoke the factory with null and assign additional properties that are
5889
+ // shared across renderers
5890
+ rendererFactory(null),
5891
+ // Properties that are either not required to be sandboxed or rely on a globally shared information
5892
+ {
5893
+ // insertStyleSheet implementation shares a global cache of stylesheet data
5619
5894
  insertStylesheet,
5620
- assertInstanceOfHTMLElement,
5621
- defineCustomElement,
5622
- getCustomElement,
5623
- };
5895
+ isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5896
+ isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5897
+ });
5624
5898
 
5625
5899
  /*
5626
5900
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5751,41 +6025,57 @@
5751
6025
  * SPDX-License-Identifier: MIT
5752
6026
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5753
6027
  */
5754
- // TODO [#2472]: Remove this workaround when appropriate.
5755
6028
  // eslint-disable-next-line @lwc/lwc-internal/no-global-node
6029
+
5756
6030
  const _Node$1 = Node;
5757
6031
  const ConnectingSlot = new WeakMap();
5758
6032
  const DisconnectingSlot = new WeakMap();
6033
+
5759
6034
  function callNodeSlot(node, slot) {
5760
- const fn = slot.get(node);
5761
- if (!isUndefined$1(fn)) {
5762
- fn(node);
5763
- }
5764
- return node; // for convenience
6035
+
6036
+ const fn = slot.get(node);
6037
+
6038
+ if (!isUndefined$1(fn)) {
6039
+ fn(node);
6040
+ }
6041
+
6042
+ return node; // for convenience
5765
6043
  }
5766
- // Monkey patching Node methods to be able to detect the insertions and removal of root elements
5767
- // created via createElement.
5768
- const { appendChild, insertBefore, removeChild, replaceChild } = _Node$1.prototype;
5769
- assign(_Node$1.prototype, {
6044
+
6045
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6046
+ // Monkey patching Node methods to be able to detect the insertions and removal of root elements
6047
+ // created via createElement.
6048
+ const {
6049
+ appendChild,
6050
+ insertBefore,
6051
+ removeChild,
6052
+ replaceChild
6053
+ } = _Node$1.prototype;
6054
+ assign(_Node$1.prototype, {
5770
6055
  appendChild(newChild) {
5771
- const appendedNode = appendChild.call(this, newChild);
5772
- return callNodeSlot(appendedNode, ConnectingSlot);
6056
+ const appendedNode = appendChild.call(this, newChild);
6057
+ return callNodeSlot(appendedNode, ConnectingSlot);
5773
6058
  },
6059
+
5774
6060
  insertBefore(newChild, referenceNode) {
5775
- const insertedNode = insertBefore.call(this, newChild, referenceNode);
5776
- return callNodeSlot(insertedNode, ConnectingSlot);
6061
+ const insertedNode = insertBefore.call(this, newChild, referenceNode);
6062
+ return callNodeSlot(insertedNode, ConnectingSlot);
5777
6063
  },
6064
+
5778
6065
  removeChild(oldChild) {
5779
- const removedNode = removeChild.call(this, oldChild);
5780
- return callNodeSlot(removedNode, DisconnectingSlot);
6066
+ const removedNode = removeChild.call(this, oldChild);
6067
+ return callNodeSlot(removedNode, DisconnectingSlot);
5781
6068
  },
6069
+
5782
6070
  replaceChild(newChild, oldChild) {
5783
- const replacedNode = replaceChild.call(this, newChild, oldChild);
5784
- callNodeSlot(replacedNode, DisconnectingSlot);
5785
- callNodeSlot(newChild, ConnectingSlot);
5786
- return replacedNode;
5787
- },
5788
- });
6071
+ const replacedNode = replaceChild.call(this, newChild, oldChild);
6072
+ callNodeSlot(replacedNode, DisconnectingSlot);
6073
+ callNodeSlot(newChild, ConnectingSlot);
6074
+ return replacedNode;
6075
+ }
6076
+
6077
+ });
6078
+ }
5789
6079
  /**
5790
6080
  * EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
5791
6081
  * difference that in the options, you can pass the `is` property set to a Constructor instead of
@@ -5797,38 +6087,50 @@
5797
6087
  * const el = createElement('x-foo', { is: FooCtor });
5798
6088
  * ```
5799
6089
  */
6090
+
6091
+
5800
6092
  function createElement(sel, options) {
5801
- if (!isObject(options) || isNull(options)) {
5802
- throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
5803
- }
5804
- const Ctor = options.is;
5805
- if (!isFunction$1(Ctor)) {
5806
- throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
5807
- }
5808
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
5809
- let wasComponentUpgraded = false;
5810
- // the custom element from the registry is expecting an upgrade callback
5811
- /**
5812
- * Note: if the upgradable constructor does not expect, or throw when we new it
5813
- * with a callback as the first argument, we could implement a more advanced
5814
- * mechanism that only passes that argument if the constructor is known to be
5815
- * an upgradable custom element.
5816
- */
5817
- const element = new UpgradableConstructor((elm) => {
5818
- createVM(elm, Ctor, renderer, {
5819
- tagName: sel,
5820
- mode: options.mode !== 'closed' ? 'open' : 'closed',
5821
- owner: null,
5822
- });
5823
- ConnectingSlot.set(elm, connectRootElement);
5824
- DisconnectingSlot.set(elm, disconnectRootElement);
5825
- wasComponentUpgraded = true;
6093
+ if (!isObject(options) || isNull(options)) {
6094
+ throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
6095
+ }
6096
+
6097
+ const Ctor = options.is;
6098
+
6099
+ if (!isFunction$1(Ctor)) {
6100
+ throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
6101
+ }
6102
+
6103
+ const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
6104
+ let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
6105
+
6106
+ /**
6107
+ * Note: if the upgradable constructor does not expect, or throw when we new it
6108
+ * with a callback as the first argument, we could implement a more advanced
6109
+ * mechanism that only passes that argument if the constructor is known to be
6110
+ * an upgradable custom element.
6111
+ */
6112
+
6113
+ const element = new UpgradableConstructor(elm => {
6114
+ createVM(elm, Ctor, renderer, {
6115
+ tagName: sel,
6116
+ mode: options.mode !== 'closed' ? 'open' : 'closed',
6117
+ owner: null
5826
6118
  });
5827
- if (!wasComponentUpgraded) {
5828
- /* eslint-disable-next-line no-console */
5829
- console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
6119
+
6120
+ if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6121
+ ConnectingSlot.set(elm, connectRootElement);
6122
+ DisconnectingSlot.set(elm, disconnectRootElement);
5830
6123
  }
5831
- return element;
6124
+
6125
+ wasComponentUpgraded = true;
6126
+ });
6127
+
6128
+ if (!wasComponentUpgraded) {
6129
+ /* eslint-disable-next-line no-console */
6130
+ console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
6131
+ }
6132
+
6133
+ return element;
5832
6134
  }
5833
6135
 
5834
6136
  /*
@@ -5862,7 +6164,7 @@
5862
6164
  }
5863
6165
  // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
5864
6166
  // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
5865
- return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6167
+ return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
5866
6168
  }
5867
6169
 
5868
6170
  /*
@@ -5899,7 +6201,7 @@
5899
6201
  });
5900
6202
  freeze(LightningElement);
5901
6203
  seal(LightningElement.prototype);
5902
- /* version: 2.23.0 */
6204
+ /* version: 2.23.3 */
5903
6205
 
5904
6206
  exports.LightningElement = LightningElement;
5905
6207
  exports.__unstable__ProfilerControl = profilerControl;
@@ -5921,6 +6223,7 @@
5921
6223
  exports.registerDecorators = registerDecorators;
5922
6224
  exports.registerTemplate = registerTemplate;
5923
6225
  exports.renderer = renderer;
6226
+ exports.rendererFactory = rendererFactory;
5924
6227
  exports.sanitizeAttribute = sanitizeAttribute;
5925
6228
  exports.setFeatureFlag = setFeatureFlag;
5926
6229
  exports.setFeatureFlagForTest = setFeatureFlagForTest;