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