lwc 2.5.7 → 2.5.8
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 +490 -68
- package/dist/engine-dom/iife/es2017/engine-dom.js +490 -67
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +306 -60
- package/dist/engine-dom/iife/es5/engine-dom.js +566 -129
- package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +363 -113
- package/dist/engine-dom/umd/es2017/engine-dom.js +490 -67
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +306 -60
- package/dist/engine-dom/umd/es5/engine-dom.js +566 -129
- package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +363 -113
- package/dist/engine-server/commonjs/es2017/engine-server.js +361 -11
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
- package/dist/engine-server/esm/es2017/engine-server.js +361 -11
- 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 +8 -8
|
@@ -298,7 +298,7 @@ var LWC = (function (exports) {
|
|
|
298
298
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
299
299
|
return attributeName;
|
|
300
300
|
}
|
|
301
|
-
/** version: 2.5.
|
|
301
|
+
/** version: 2.5.8 */
|
|
302
302
|
|
|
303
303
|
/*
|
|
304
304
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -470,7 +470,7 @@ var LWC = (function (exports) {
|
|
|
470
470
|
|
|
471
471
|
function setFeatureFlagForTest(name, value) {
|
|
472
472
|
}
|
|
473
|
-
/** version: 2.5.
|
|
473
|
+
/** version: 2.5.8 */
|
|
474
474
|
|
|
475
475
|
/* proxy-compat-disable */
|
|
476
476
|
|
|
@@ -512,7 +512,7 @@ var LWC = (function (exports) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
515
|
-
}
|
|
515
|
+
} // Borrowed from Vue template compiler.
|
|
516
516
|
/*
|
|
517
517
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
518
518
|
* All rights reserved.
|
|
@@ -660,6 +660,20 @@ var LWC = (function (exports) {
|
|
|
660
660
|
return `<${StringToLowerCase.call(vm.tagName)}>`;
|
|
661
661
|
} // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
|
|
662
662
|
|
|
663
|
+
|
|
664
|
+
function getComponentStack(vm) {
|
|
665
|
+
const stack = [];
|
|
666
|
+
let prefix = '';
|
|
667
|
+
|
|
668
|
+
while (!isNull(vm.owner)) {
|
|
669
|
+
ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
|
670
|
+
vm = vm.owner;
|
|
671
|
+
prefix += '\t';
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return ArrayJoin.call(stack, '\n');
|
|
675
|
+
}
|
|
676
|
+
|
|
663
677
|
function getErrorComponentStack(vm) {
|
|
664
678
|
const wcStack = [];
|
|
665
679
|
let currentVm = vm;
|
|
@@ -679,6 +693,32 @@ var LWC = (function (exports) {
|
|
|
679
693
|
*/
|
|
680
694
|
|
|
681
695
|
|
|
696
|
+
function log(method, message, vm) {
|
|
697
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
698
|
+
|
|
699
|
+
if (!isUndefined$1(vm)) {
|
|
700
|
+
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
try {
|
|
704
|
+
throw new Error(msg);
|
|
705
|
+
} catch (e) {
|
|
706
|
+
/* eslint-disable-next-line no-console */
|
|
707
|
+
console[method](e);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function logWarn(message, vm) {
|
|
712
|
+
log('warn', message, vm);
|
|
713
|
+
}
|
|
714
|
+
/*
|
|
715
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
716
|
+
* All rights reserved.
|
|
717
|
+
* SPDX-License-Identifier: MIT
|
|
718
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
|
|
682
722
|
function handleEvent(event, vnode) {
|
|
683
723
|
const {
|
|
684
724
|
type
|
|
@@ -3431,6 +3471,17 @@ var LWC = (function (exports) {
|
|
|
3431
3471
|
modComputedStyle.create(vnode);
|
|
3432
3472
|
}
|
|
3433
3473
|
|
|
3474
|
+
function hydrateElmHook(vnode) {
|
|
3475
|
+
modEvents.create(vnode); // Attrs are already on the element.
|
|
3476
|
+
// modAttrs.create(vnode);
|
|
3477
|
+
|
|
3478
|
+
modProps.create(vnode); // Already set.
|
|
3479
|
+
// modStaticClassName.create(vnode);
|
|
3480
|
+
// modStaticStyle.create(vnode);
|
|
3481
|
+
// modComputedClassName.create(vnode);
|
|
3482
|
+
// modComputedStyle.create(vnode);
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3434
3485
|
function fallbackElmHook(elm, vnode) {
|
|
3435
3486
|
const {
|
|
3436
3487
|
owner
|
|
@@ -3580,6 +3631,22 @@ var LWC = (function (exports) {
|
|
|
3580
3631
|
}
|
|
3581
3632
|
}
|
|
3582
3633
|
|
|
3634
|
+
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
3635
|
+
|
|
3636
|
+
let elmCurrentChildIdx = 0;
|
|
3637
|
+
|
|
3638
|
+
for (let j = 0, n = children.length; j < n; j++) {
|
|
3639
|
+
const ch = children[j];
|
|
3640
|
+
|
|
3641
|
+
if (ch != null) {
|
|
3642
|
+
const childNode = elmChildren[elmCurrentChildIdx];
|
|
3643
|
+
|
|
3644
|
+
ch.hook.hydrate(ch, childNode);
|
|
3645
|
+
elmCurrentChildIdx++;
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3583
3650
|
function updateCustomElmHook(oldVnode, vnode) {
|
|
3584
3651
|
// Attrs need to be applied to element before props
|
|
3585
3652
|
// IE11 will wipe out value on radio inputs if value
|
|
@@ -3681,7 +3748,14 @@ var LWC = (function (exports) {
|
|
|
3681
3748
|
update: updateNodeHook,
|
|
3682
3749
|
insert: insertNodeHook,
|
|
3683
3750
|
move: insertNodeHook,
|
|
3684
|
-
remove: removeNodeHook
|
|
3751
|
+
remove: removeNodeHook,
|
|
3752
|
+
hydrate: (vNode, node) => {
|
|
3753
|
+
var _a;
|
|
3754
|
+
|
|
3755
|
+
|
|
3756
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
3757
|
+
vNode.elm = node;
|
|
3758
|
+
}
|
|
3685
3759
|
};
|
|
3686
3760
|
const CommentHook = {
|
|
3687
3761
|
create: vnode => {
|
|
@@ -3699,7 +3773,14 @@ var LWC = (function (exports) {
|
|
|
3699
3773
|
update: updateNodeHook,
|
|
3700
3774
|
insert: insertNodeHook,
|
|
3701
3775
|
move: insertNodeHook,
|
|
3702
|
-
remove: removeNodeHook
|
|
3776
|
+
remove: removeNodeHook,
|
|
3777
|
+
hydrate: (vNode, node) => {
|
|
3778
|
+
var _a;
|
|
3779
|
+
|
|
3780
|
+
|
|
3781
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
3782
|
+
vNode.elm = node;
|
|
3783
|
+
}
|
|
3703
3784
|
}; // insert is called after update, which is used somewhere else (via a module)
|
|
3704
3785
|
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
3705
3786
|
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
@@ -3739,6 +3820,38 @@ var LWC = (function (exports) {
|
|
|
3739
3820
|
remove: (vnode, parentNode) => {
|
|
3740
3821
|
removeNodeHook(vnode, parentNode);
|
|
3741
3822
|
removeElmHook(vnode);
|
|
3823
|
+
},
|
|
3824
|
+
hydrate: (vnode, node) => {
|
|
3825
|
+
const elm = node;
|
|
3826
|
+
vnode.elm = elm;
|
|
3827
|
+
const {
|
|
3828
|
+
context
|
|
3829
|
+
} = vnode.data;
|
|
3830
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
3831
|
+
/* manual */
|
|
3832
|
+
);
|
|
3833
|
+
|
|
3834
|
+
if (isDomManual) {
|
|
3835
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
3836
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
3837
|
+
const {
|
|
3838
|
+
props
|
|
3839
|
+
} = vnode.data;
|
|
3840
|
+
|
|
3841
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
3842
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
3843
|
+
delete props.innerHTML;
|
|
3844
|
+
} else {
|
|
3845
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3850
|
+
hydrateElmHook(vnode);
|
|
3851
|
+
|
|
3852
|
+
if (!isDomManual) {
|
|
3853
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
3854
|
+
}
|
|
3742
3855
|
}
|
|
3743
3856
|
};
|
|
3744
3857
|
const CustomElementHook = {
|
|
@@ -3822,6 +3935,38 @@ var LWC = (function (exports) {
|
|
|
3822
3935
|
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
3823
3936
|
removeVM(vm);
|
|
3824
3937
|
}
|
|
3938
|
+
},
|
|
3939
|
+
hydrate: (vnode, elm) => {
|
|
3940
|
+
// the element is created, but the vm is not
|
|
3941
|
+
const {
|
|
3942
|
+
sel,
|
|
3943
|
+
mode,
|
|
3944
|
+
ctor,
|
|
3945
|
+
owner
|
|
3946
|
+
} = vnode;
|
|
3947
|
+
const def = getComponentInternalDef(ctor);
|
|
3948
|
+
createVM(elm, def, {
|
|
3949
|
+
mode,
|
|
3950
|
+
owner,
|
|
3951
|
+
tagName: sel,
|
|
3952
|
+
renderer: owner.renderer
|
|
3953
|
+
});
|
|
3954
|
+
vnode.elm = elm;
|
|
3955
|
+
const vm = getAssociatedVM(elm);
|
|
3956
|
+
allocateChildrenHook(vnode, vm);
|
|
3957
|
+
hydrateElmHook(vnode); // Insert hook section:
|
|
3958
|
+
|
|
3959
|
+
runConnectedCallback(vm);
|
|
3960
|
+
|
|
3961
|
+
if (vm.renderMode !== 0
|
|
3962
|
+
/* Light */
|
|
3963
|
+
) {
|
|
3964
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
3965
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
3966
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
hydrateVM(vm);
|
|
3825
3970
|
}
|
|
3826
3971
|
};
|
|
3827
3972
|
|
|
@@ -4380,7 +4525,10 @@ var LWC = (function (exports) {
|
|
|
4380
4525
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4381
4526
|
renderer.insertGlobalStylesheet(stylesheets[i]);
|
|
4382
4527
|
}
|
|
4383
|
-
} else if (renderer.ssr) {
|
|
4528
|
+
} else if (renderer.ssr || renderer.isHydrating) {
|
|
4529
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4530
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4531
|
+
// the first time the VM renders.
|
|
4384
4532
|
// native shadow or light DOM, SSR
|
|
4385
4533
|
const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
|
|
4386
4534
|
return createInlineStyleVNode(combinedStylesheetContent);
|
|
@@ -4879,6 +5027,12 @@ var LWC = (function (exports) {
|
|
|
4879
5027
|
, vm);
|
|
4880
5028
|
}
|
|
4881
5029
|
|
|
5030
|
+
function hydrateRootElement(elm) {
|
|
5031
|
+
const vm = getAssociatedVM(elm);
|
|
5032
|
+
runConnectedCallback(vm);
|
|
5033
|
+
hydrateVM(vm);
|
|
5034
|
+
}
|
|
5035
|
+
|
|
4882
5036
|
function disconnectRootElement(elm) {
|
|
4883
5037
|
const vm = getAssociatedVM(elm);
|
|
4884
5038
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -4886,6 +5040,10 @@ var LWC = (function (exports) {
|
|
|
4886
5040
|
|
|
4887
5041
|
function appendVM(vm) {
|
|
4888
5042
|
rehydrate(vm);
|
|
5043
|
+
}
|
|
5044
|
+
|
|
5045
|
+
function hydrateVM(vm) {
|
|
5046
|
+
hydrate(vm);
|
|
4889
5047
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
4890
5048
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
4891
5049
|
|
|
@@ -5080,6 +5238,22 @@ var LWC = (function (exports) {
|
|
|
5080
5238
|
}
|
|
5081
5239
|
}
|
|
5082
5240
|
|
|
5241
|
+
function hydrate(vm) {
|
|
5242
|
+
if (isTrue(vm.isDirty)) {
|
|
5243
|
+
// manually diffing/patching here.
|
|
5244
|
+
// This routine is:
|
|
5245
|
+
// patchShadowRoot(vm, children);
|
|
5246
|
+
// -> addVnodes.
|
|
5247
|
+
const children = renderComponent(vm);
|
|
5248
|
+
vm.children = children;
|
|
5249
|
+
const vmChildren = vm.renderMode === 0
|
|
5250
|
+
/* Light */
|
|
5251
|
+
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
5252
|
+
hydrateChildrenHook(vmChildren, children);
|
|
5253
|
+
runRenderedCallback(vm);
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5083
5257
|
function patchShadowRoot(vm, newCh) {
|
|
5084
5258
|
const {
|
|
5085
5259
|
children: oldCh
|
|
@@ -5874,7 +6048,7 @@ var LWC = (function (exports) {
|
|
|
5874
6048
|
hooksAreSet = true;
|
|
5875
6049
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
5876
6050
|
}
|
|
5877
|
-
/* version: 2.5.
|
|
6051
|
+
/* version: 2.5.8 */
|
|
5878
6052
|
|
|
5879
6053
|
/*
|
|
5880
6054
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6009,8 +6183,19 @@ var LWC = (function (exports) {
|
|
|
6009
6183
|
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
6010
6184
|
}
|
|
6011
6185
|
|
|
6186
|
+
let isHydrating = false;
|
|
6187
|
+
|
|
6188
|
+
function setIsHydrating(v) {
|
|
6189
|
+
isHydrating = v;
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6012
6192
|
const renderer = {
|
|
6013
6193
|
ssr: false,
|
|
6194
|
+
|
|
6195
|
+
get isHydrating() {
|
|
6196
|
+
return isHydrating;
|
|
6197
|
+
},
|
|
6198
|
+
|
|
6014
6199
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
6015
6200
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
6016
6201
|
|
|
@@ -6039,6 +6224,10 @@ var LWC = (function (exports) {
|
|
|
6039
6224
|
},
|
|
6040
6225
|
|
|
6041
6226
|
attachShadow(element, options) {
|
|
6227
|
+
if (isHydrating) {
|
|
6228
|
+
return element.shadowRoot;
|
|
6229
|
+
}
|
|
6230
|
+
|
|
6042
6231
|
return element.attachShadow(options);
|
|
6043
6232
|
},
|
|
6044
6233
|
|
|
@@ -6170,57 +6359,6 @@ var LWC = (function (exports) {
|
|
|
6170
6359
|
getCustomElement,
|
|
6171
6360
|
HTMLElement: HTMLElementConstructor
|
|
6172
6361
|
};
|
|
6173
|
-
/*
|
|
6174
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6175
|
-
* All rights reserved.
|
|
6176
|
-
* SPDX-License-Identifier: MIT
|
|
6177
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6178
|
-
*/
|
|
6179
|
-
|
|
6180
|
-
/**
|
|
6181
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
6182
|
-
* registered as a new element via customElements.define() at any given time.
|
|
6183
|
-
*
|
|
6184
|
-
* @deprecated since version 1.3.11
|
|
6185
|
-
*
|
|
6186
|
-
* @example
|
|
6187
|
-
* ```
|
|
6188
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
6189
|
-
* import Foo from 'ns/foo';
|
|
6190
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
6191
|
-
* customElements.define('x-foo', WC);
|
|
6192
|
-
* const elm = document.createElement('x-foo');
|
|
6193
|
-
* ```
|
|
6194
|
-
*/
|
|
6195
|
-
|
|
6196
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
6197
|
-
|
|
6198
|
-
return Ctor.CustomElementConstructor;
|
|
6199
|
-
}
|
|
6200
|
-
|
|
6201
|
-
function buildCustomElementConstructor(Ctor) {
|
|
6202
|
-
const def = getComponentInternalDef(Ctor);
|
|
6203
|
-
return class extends def.bridge {
|
|
6204
|
-
constructor() {
|
|
6205
|
-
super();
|
|
6206
|
-
createVM(this, def, {
|
|
6207
|
-
mode: 'open',
|
|
6208
|
-
owner: null,
|
|
6209
|
-
tagName: this.tagName,
|
|
6210
|
-
renderer
|
|
6211
|
-
});
|
|
6212
|
-
}
|
|
6213
|
-
|
|
6214
|
-
connectedCallback() {
|
|
6215
|
-
connectRootElement(this);
|
|
6216
|
-
}
|
|
6217
|
-
|
|
6218
|
-
disconnectedCallback() {
|
|
6219
|
-
disconnectRootElement(this);
|
|
6220
|
-
}
|
|
6221
|
-
|
|
6222
|
-
};
|
|
6223
|
-
}
|
|
6224
6362
|
/*
|
|
6225
6363
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6226
6364
|
* All rights reserved.
|
|
@@ -6230,7 +6368,6 @@ var LWC = (function (exports) {
|
|
|
6230
6368
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
6231
6369
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6232
6370
|
|
|
6233
|
-
|
|
6234
6371
|
const _Node$1 = Node;
|
|
6235
6372
|
const ConnectingSlot = new WeakMap();
|
|
6236
6373
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -6338,6 +6475,114 @@ var LWC = (function (exports) {
|
|
|
6338
6475
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6339
6476
|
*/
|
|
6340
6477
|
|
|
6478
|
+
|
|
6479
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
6480
|
+
if (!isFunction$1(Ctor)) {
|
|
6481
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
6482
|
+
}
|
|
6483
|
+
|
|
6484
|
+
if (!isObject(props) || isNull(props)) {
|
|
6485
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
6486
|
+
}
|
|
6487
|
+
|
|
6488
|
+
const def = getComponentInternalDef(Ctor);
|
|
6489
|
+
|
|
6490
|
+
try {
|
|
6491
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
6492
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
6493
|
+
setIsHydrating(true);
|
|
6494
|
+
createVM(element, def, {
|
|
6495
|
+
mode: 'open',
|
|
6496
|
+
owner: null,
|
|
6497
|
+
renderer,
|
|
6498
|
+
tagName: element.tagName.toLowerCase()
|
|
6499
|
+
});
|
|
6500
|
+
|
|
6501
|
+
for (const [key, value] of Object.entries(props)) {
|
|
6502
|
+
element[key] = value;
|
|
6503
|
+
}
|
|
6504
|
+
|
|
6505
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
6506
|
+
|
|
6507
|
+
setIsHydrating(false);
|
|
6508
|
+
} catch (e) {
|
|
6509
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
6510
|
+
// the client generated DOM.
|
|
6511
|
+
|
|
6512
|
+
/* eslint-disable-next-line no-console */
|
|
6513
|
+
console.error('Recovering from error while hydrating: ', e);
|
|
6514
|
+
setIsHydrating(false);
|
|
6515
|
+
const newElem = createElement(element.tagName, {
|
|
6516
|
+
is: Ctor,
|
|
6517
|
+
mode: 'open'
|
|
6518
|
+
});
|
|
6519
|
+
|
|
6520
|
+
for (const [key, value] of Object.entries(props)) {
|
|
6521
|
+
newElem[key] = value;
|
|
6522
|
+
}
|
|
6523
|
+
|
|
6524
|
+
element.parentNode.replaceChild(newElem, element);
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
/*
|
|
6528
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6529
|
+
* All rights reserved.
|
|
6530
|
+
* SPDX-License-Identifier: MIT
|
|
6531
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6532
|
+
*/
|
|
6533
|
+
|
|
6534
|
+
/**
|
|
6535
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
6536
|
+
* registered as a new element via customElements.define() at any given time.
|
|
6537
|
+
*
|
|
6538
|
+
* @deprecated since version 1.3.11
|
|
6539
|
+
*
|
|
6540
|
+
* @example
|
|
6541
|
+
* ```
|
|
6542
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
6543
|
+
* import Foo from 'ns/foo';
|
|
6544
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
6545
|
+
* customElements.define('x-foo', WC);
|
|
6546
|
+
* const elm = document.createElement('x-foo');
|
|
6547
|
+
* ```
|
|
6548
|
+
*/
|
|
6549
|
+
|
|
6550
|
+
|
|
6551
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
6552
|
+
|
|
6553
|
+
return Ctor.CustomElementConstructor;
|
|
6554
|
+
}
|
|
6555
|
+
|
|
6556
|
+
function buildCustomElementConstructor(Ctor) {
|
|
6557
|
+
const def = getComponentInternalDef(Ctor);
|
|
6558
|
+
return class extends def.bridge {
|
|
6559
|
+
constructor() {
|
|
6560
|
+
super();
|
|
6561
|
+
createVM(this, def, {
|
|
6562
|
+
mode: 'open',
|
|
6563
|
+
owner: null,
|
|
6564
|
+
tagName: this.tagName,
|
|
6565
|
+
renderer
|
|
6566
|
+
});
|
|
6567
|
+
}
|
|
6568
|
+
|
|
6569
|
+
connectedCallback() {
|
|
6570
|
+
connectRootElement(this);
|
|
6571
|
+
}
|
|
6572
|
+
|
|
6573
|
+
disconnectedCallback() {
|
|
6574
|
+
disconnectRootElement(this);
|
|
6575
|
+
}
|
|
6576
|
+
|
|
6577
|
+
};
|
|
6578
|
+
}
|
|
6579
|
+
/*
|
|
6580
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6581
|
+
* All rights reserved.
|
|
6582
|
+
* SPDX-License-Identifier: MIT
|
|
6583
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6584
|
+
*/
|
|
6585
|
+
|
|
6341
6586
|
/**
|
|
6342
6587
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
6343
6588
|
* This API is subject to change or being removed.
|
|
@@ -6437,7 +6682,7 @@ var LWC = (function (exports) {
|
|
|
6437
6682
|
});
|
|
6438
6683
|
freeze(LightningElement);
|
|
6439
6684
|
seal(LightningElement.prototype);
|
|
6440
|
-
/* version: 2.5.
|
|
6685
|
+
/* version: 2.5.8 */
|
|
6441
6686
|
|
|
6442
6687
|
exports.LightningElement = LightningElement;
|
|
6443
6688
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -6447,6 +6692,7 @@ var LWC = (function (exports) {
|
|
|
6447
6692
|
exports.createElement = createElement;
|
|
6448
6693
|
exports.getComponentConstructor = getComponentConstructor;
|
|
6449
6694
|
exports.getComponentDef = getComponentDef;
|
|
6695
|
+
exports.hydrateComponent = hydrateComponent;
|
|
6450
6696
|
exports.isComponentConstructor = isComponentConstructor;
|
|
6451
6697
|
exports.isNodeFromTemplate = isNodeFromTemplate;
|
|
6452
6698
|
exports.readonly = readonly;
|