@lwc/engine-core 2.5.6 → 2.5.10-alpha1
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-core.cjs.js +392 -64
- package/dist/engine-core.js +387 -63
- package/package.json +5 -5
- package/types/3rdparty/snabbdom/types.d.ts +1 -0
- package/types/framework/api.d.ts +6 -1
- package/types/framework/hooks.d.ts +5 -0
- package/types/framework/main.d.ts +2 -2
- package/types/framework/overridable-hooks.d.ts +1 -2
- package/types/framework/performance-timing.d.ts +10 -0
- package/types/framework/renderer.d.ts +1 -0
- package/types/framework/utils.d.ts +3 -0
- package/types/framework/vm.d.ts +3 -1
- package/types/shared/logger.d.ts +1 -0
- package/types/framework/api-helpers.d.ts +0 -15
package/dist/engine-core.cjs.js
CHANGED
|
@@ -51,6 +51,26 @@ function guid() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
54
|
+
} // Borrowed from Vue template compiler.
|
|
55
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
56
|
+
|
|
57
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
58
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
59
|
+
function parseStyleText(cssText) {
|
|
60
|
+
const styleMap = {};
|
|
61
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
62
|
+
|
|
63
|
+
for (const declaration of declarations) {
|
|
64
|
+
if (declaration) {
|
|
65
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
66
|
+
|
|
67
|
+
if (prop !== undefined && value !== undefined) {
|
|
68
|
+
styleMap[prop.trim()] = value.trim();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return styleMap;
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
/*
|
|
@@ -222,8 +242,9 @@ function getErrorComponentStack(vm) {
|
|
|
222
242
|
* SPDX-License-Identifier: MIT
|
|
223
243
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
224
244
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
245
|
+
|
|
246
|
+
function log(method, message, vm) {
|
|
247
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
227
248
|
|
|
228
249
|
if (!shared.isUndefined(vm)) {
|
|
229
250
|
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
@@ -231,7 +252,7 @@ function logError(message, vm) {
|
|
|
231
252
|
|
|
232
253
|
if (process.env.NODE_ENV === 'test') {
|
|
233
254
|
/* eslint-disable-next-line no-console */
|
|
234
|
-
console
|
|
255
|
+
console[method](msg);
|
|
235
256
|
return;
|
|
236
257
|
}
|
|
237
258
|
|
|
@@ -239,10 +260,17 @@ function logError(message, vm) {
|
|
|
239
260
|
throw new Error(msg);
|
|
240
261
|
} catch (e) {
|
|
241
262
|
/* eslint-disable-next-line no-console */
|
|
242
|
-
console
|
|
263
|
+
console[method](e);
|
|
243
264
|
}
|
|
244
265
|
}
|
|
245
266
|
|
|
267
|
+
function logError(message, vm) {
|
|
268
|
+
log('error', message, vm);
|
|
269
|
+
}
|
|
270
|
+
function logWarn(message, vm) {
|
|
271
|
+
log('warn', message, vm);
|
|
272
|
+
}
|
|
273
|
+
|
|
246
274
|
/*
|
|
247
275
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
248
276
|
* All rights reserved.
|
|
@@ -2596,8 +2624,10 @@ for (const [elementProp, rendererMethod] of childGetters) {
|
|
|
2596
2624
|
}
|
|
2597
2625
|
|
|
2598
2626
|
return renderer[rendererMethod](elm);
|
|
2599
|
-
}
|
|
2627
|
+
},
|
|
2600
2628
|
|
|
2629
|
+
configurable: true,
|
|
2630
|
+
enumerable: true
|
|
2601
2631
|
};
|
|
2602
2632
|
}
|
|
2603
2633
|
|
|
@@ -2617,8 +2647,11 @@ for (const queryMethod of queryMethods) {
|
|
|
2617
2647
|
}
|
|
2618
2648
|
|
|
2619
2649
|
return renderer[queryMethod](elm, arg);
|
|
2620
|
-
}
|
|
2650
|
+
},
|
|
2621
2651
|
|
|
2652
|
+
configurable: true,
|
|
2653
|
+
enumerable: true,
|
|
2654
|
+
writable: true
|
|
2622
2655
|
};
|
|
2623
2656
|
}
|
|
2624
2657
|
|
|
@@ -3750,7 +3783,7 @@ function createComponentDef(Ctor) {
|
|
|
3750
3783
|
if (!shared.isUndefined(ctorShadowSupportMode)) {
|
|
3751
3784
|
shared.assert.invariant(ctorShadowSupportMode === "any"
|
|
3752
3785
|
/* Any */
|
|
3753
|
-
|| ctorShadowSupportMode === "
|
|
3786
|
+
|| ctorShadowSupportMode === "reset"
|
|
3754
3787
|
/* Default */
|
|
3755
3788
|
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
3756
3789
|
}
|
|
@@ -3910,7 +3943,7 @@ const lightingElementDef = {
|
|
|
3910
3943
|
renderMode: 1
|
|
3911
3944
|
/* Shadow */
|
|
3912
3945
|
,
|
|
3913
|
-
shadowSupportMode: "
|
|
3946
|
+
shadowSupportMode: "reset"
|
|
3914
3947
|
/* Default */
|
|
3915
3948
|
,
|
|
3916
3949
|
wire: EmptyObject,
|
|
@@ -4055,6 +4088,16 @@ function createElmHook(vnode) {
|
|
|
4055
4088
|
modComputedClassName.create(vnode);
|
|
4056
4089
|
modComputedStyle.create(vnode);
|
|
4057
4090
|
}
|
|
4091
|
+
function hydrateElmHook(vnode) {
|
|
4092
|
+
modEvents.create(vnode); // Attrs are already on the element.
|
|
4093
|
+
// modAttrs.create(vnode);
|
|
4094
|
+
|
|
4095
|
+
modProps.create(vnode); // Already set.
|
|
4096
|
+
// modStaticClassName.create(vnode);
|
|
4097
|
+
// modStaticStyle.create(vnode);
|
|
4098
|
+
// modComputedClassName.create(vnode);
|
|
4099
|
+
// modComputedStyle.create(vnode);
|
|
4100
|
+
}
|
|
4058
4101
|
function fallbackElmHook(elm, vnode) {
|
|
4059
4102
|
const {
|
|
4060
4103
|
owner
|
|
@@ -4219,6 +4262,179 @@ function createChildrenHook(vnode) {
|
|
|
4219
4262
|
}
|
|
4220
4263
|
}
|
|
4221
4264
|
}
|
|
4265
|
+
|
|
4266
|
+
function isElementNode(node) {
|
|
4267
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4268
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4272
|
+
const {
|
|
4273
|
+
data: {
|
|
4274
|
+
attrs = {}
|
|
4275
|
+
},
|
|
4276
|
+
owner: {
|
|
4277
|
+
renderer
|
|
4278
|
+
}
|
|
4279
|
+
} = vnode;
|
|
4280
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4281
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4282
|
+
|
|
4283
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4284
|
+
const elmAttrValue = renderer.getAttribute(elm, attrName);
|
|
4285
|
+
|
|
4286
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
4287
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4288
|
+
nodesAreCompatible = false;
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4291
|
+
|
|
4292
|
+
return nodesAreCompatible;
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4296
|
+
const {
|
|
4297
|
+
data: {
|
|
4298
|
+
className,
|
|
4299
|
+
classMap
|
|
4300
|
+
},
|
|
4301
|
+
owner: {
|
|
4302
|
+
renderer
|
|
4303
|
+
}
|
|
4304
|
+
} = vnode;
|
|
4305
|
+
let nodesAreCompatible = true;
|
|
4306
|
+
let vnodeClassName;
|
|
4307
|
+
|
|
4308
|
+
if (!shared.isUndefined(className) && String(className) !== elm.className) {
|
|
4309
|
+
// className is used when class is bound to an expr.
|
|
4310
|
+
nodesAreCompatible = false;
|
|
4311
|
+
vnodeClassName = className;
|
|
4312
|
+
} else if (!shared.isUndefined(classMap)) {
|
|
4313
|
+
// classMap is used when class is set to static value.
|
|
4314
|
+
const classList = renderer.getClassList(elm);
|
|
4315
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4316
|
+
|
|
4317
|
+
for (const name in classMap) {
|
|
4318
|
+
computedClassName += ' ' + name;
|
|
4319
|
+
|
|
4320
|
+
if (!classList.contains(name)) {
|
|
4321
|
+
nodesAreCompatible = false;
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4325
|
+
vnodeClassName = computedClassName.trim();
|
|
4326
|
+
|
|
4327
|
+
if (classList.length > shared.keys(classMap).length) {
|
|
4328
|
+
nodesAreCompatible = false;
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
if (!nodesAreCompatible) {
|
|
4333
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
return nodesAreCompatible;
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4340
|
+
const {
|
|
4341
|
+
data: {
|
|
4342
|
+
style,
|
|
4343
|
+
styleDecls
|
|
4344
|
+
},
|
|
4345
|
+
owner: {
|
|
4346
|
+
renderer
|
|
4347
|
+
}
|
|
4348
|
+
} = vnode;
|
|
4349
|
+
const elmStyle = renderer.getAttribute(elm, 'style') || '';
|
|
4350
|
+
let vnodeStyle;
|
|
4351
|
+
let nodesAreCompatible = true;
|
|
4352
|
+
|
|
4353
|
+
if (!shared.isUndefined(style) && style !== elmStyle) {
|
|
4354
|
+
nodesAreCompatible = false;
|
|
4355
|
+
vnodeStyle = style;
|
|
4356
|
+
} else if (!shared.isUndefined(styleDecls)) {
|
|
4357
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4358
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4359
|
+
|
|
4360
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4361
|
+
const [prop, value, important] = styleDecls[i];
|
|
4362
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4363
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4364
|
+
|
|
4365
|
+
if (shared.isUndefined(parsedPropValue)) {
|
|
4366
|
+
nodesAreCompatible = false;
|
|
4367
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
4368
|
+
nodesAreCompatible = false;
|
|
4369
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4370
|
+
nodesAreCompatible = false;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4375
|
+
nodesAreCompatible = false;
|
|
4376
|
+
}
|
|
4377
|
+
|
|
4378
|
+
vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
if (!nodesAreCompatible) {
|
|
4382
|
+
// style is used when class is bound to an expr.
|
|
4383
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4384
|
+
}
|
|
4385
|
+
|
|
4386
|
+
return nodesAreCompatible;
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
function throwHydrationError() {
|
|
4390
|
+
shared.assert.fail('Server rendered elements do not match client side generated elements');
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4394
|
+
var _a, _b;
|
|
4395
|
+
|
|
4396
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4397
|
+
const filteredVNodes = shared.ArrayFilter.call(children, vnode => !!vnode);
|
|
4398
|
+
|
|
4399
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
4400
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4401
|
+
throwHydrationError();
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
let elmCurrentChildIdx = 0;
|
|
4406
|
+
|
|
4407
|
+
for (let j = 0, n = children.length; j < n; j++) {
|
|
4408
|
+
const ch = children[j];
|
|
4409
|
+
|
|
4410
|
+
if (ch != null) {
|
|
4411
|
+
const childNode = elmChildren[elmCurrentChildIdx];
|
|
4412
|
+
|
|
4413
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4414
|
+
// VComments and VTexts validation is handled in their hooks
|
|
4415
|
+
if (isElementNode(childNode)) {
|
|
4416
|
+
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
4417
|
+
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
4418
|
+
throwHydrationError();
|
|
4419
|
+
} // Note: props are not yet set
|
|
4420
|
+
|
|
4421
|
+
|
|
4422
|
+
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
4423
|
+
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
4424
|
+
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
4425
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4426
|
+
|
|
4427
|
+
if (!isVNodeAndElementCompatible) {
|
|
4428
|
+
throwHydrationError();
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
ch.hook.hydrate(ch, childNode);
|
|
4434
|
+
elmCurrentChildIdx++;
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4222
4438
|
function updateCustomElmHook(oldVnode, vnode) {
|
|
4223
4439
|
// Attrs need to be applied to element before props
|
|
4224
4440
|
// IE11 will wipe out value on radio inputs if value
|
|
@@ -4292,36 +4508,6 @@ function getUpgradableConstructor(tagName, renderer) {
|
|
|
4292
4508
|
return CE;
|
|
4293
4509
|
}
|
|
4294
4510
|
|
|
4295
|
-
/*
|
|
4296
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4297
|
-
* All rights reserved.
|
|
4298
|
-
* SPDX-License-Identifier: MIT
|
|
4299
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4300
|
-
*/
|
|
4301
|
-
|
|
4302
|
-
/**
|
|
4303
|
-
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
4304
|
-
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
4305
|
-
* lwc:inner-html directive.
|
|
4306
|
-
* It is meant to be overridden with setSanitizeHtmlContentHook
|
|
4307
|
-
*/
|
|
4308
|
-
let sanitizeHtmlContentHook = () => {
|
|
4309
|
-
// locker-service patches this function during runtime to sanitize HTML content.
|
|
4310
|
-
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
4311
|
-
};
|
|
4312
|
-
/**
|
|
4313
|
-
* Sets the sanitizeHtmlContentHook.
|
|
4314
|
-
*
|
|
4315
|
-
* @param newHookImpl
|
|
4316
|
-
* @returns oldHookImplementation.
|
|
4317
|
-
*/
|
|
4318
|
-
|
|
4319
|
-
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
4320
|
-
const currentHook = sanitizeHtmlContentHook;
|
|
4321
|
-
sanitizeHtmlContentHook = newHookImpl;
|
|
4322
|
-
return currentHook;
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
4511
|
/*
|
|
4326
4512
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4327
4513
|
* All rights reserved.
|
|
@@ -4345,7 +4531,26 @@ const TextHook = {
|
|
|
4345
4531
|
update: updateNodeHook,
|
|
4346
4532
|
insert: insertNodeHook,
|
|
4347
4533
|
move: insertNodeHook,
|
|
4348
|
-
remove: removeNodeHook
|
|
4534
|
+
remove: removeNodeHook,
|
|
4535
|
+
hydrate: (vNode, node) => {
|
|
4536
|
+
var _a;
|
|
4537
|
+
|
|
4538
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4539
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4540
|
+
if (node.nodeType !== Node.TEXT_NODE) {
|
|
4541
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
4542
|
+
shared.assert.fail('Hydration mismatch: incorrect node type received.');
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4545
|
+
if (node.nodeValue !== vNode.text) {
|
|
4546
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
4547
|
+
}
|
|
4548
|
+
} // always set the text value to the one from the vnode.
|
|
4549
|
+
|
|
4550
|
+
|
|
4551
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
4552
|
+
vNode.elm = node;
|
|
4553
|
+
}
|
|
4349
4554
|
};
|
|
4350
4555
|
const CommentHook = {
|
|
4351
4556
|
create: vnode => {
|
|
@@ -4363,7 +4568,26 @@ const CommentHook = {
|
|
|
4363
4568
|
update: updateNodeHook,
|
|
4364
4569
|
insert: insertNodeHook,
|
|
4365
4570
|
move: insertNodeHook,
|
|
4366
|
-
remove: removeNodeHook
|
|
4571
|
+
remove: removeNodeHook,
|
|
4572
|
+
hydrate: (vNode, node) => {
|
|
4573
|
+
var _a;
|
|
4574
|
+
|
|
4575
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4576
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4577
|
+
if (node.nodeType !== Node.COMMENT_NODE) {
|
|
4578
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
4579
|
+
shared.assert.fail('Hydration mismatch: incorrect node type received.');
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
if (node.nodeValue !== vNode.text) {
|
|
4583
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
|
|
4584
|
+
}
|
|
4585
|
+
} // always set the text value to the one from the vnode.
|
|
4586
|
+
|
|
4587
|
+
|
|
4588
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
4589
|
+
vNode.elm = node;
|
|
4590
|
+
}
|
|
4367
4591
|
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4368
4592
|
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4369
4593
|
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
@@ -4403,6 +4627,38 @@ const ElementHook = {
|
|
|
4403
4627
|
remove: (vnode, parentNode) => {
|
|
4404
4628
|
removeNodeHook(vnode, parentNode);
|
|
4405
4629
|
removeElmHook(vnode);
|
|
4630
|
+
},
|
|
4631
|
+
hydrate: (vnode, node) => {
|
|
4632
|
+
const elm = node;
|
|
4633
|
+
vnode.elm = elm;
|
|
4634
|
+
const {
|
|
4635
|
+
context
|
|
4636
|
+
} = vnode.data;
|
|
4637
|
+
const isDomManual = Boolean(!shared.isUndefined(context) && !shared.isUndefined(context.lwc) && context.lwc.dom === "manual"
|
|
4638
|
+
/* manual */
|
|
4639
|
+
);
|
|
4640
|
+
|
|
4641
|
+
if (isDomManual) {
|
|
4642
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
4643
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
4644
|
+
const {
|
|
4645
|
+
props
|
|
4646
|
+
} = vnode.data;
|
|
4647
|
+
|
|
4648
|
+
if (!shared.isUndefined(props) && !shared.isUndefined(props.innerHTML)) {
|
|
4649
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
4650
|
+
delete props.innerHTML;
|
|
4651
|
+
} else {
|
|
4652
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4656
|
+
|
|
4657
|
+
hydrateElmHook(vnode);
|
|
4658
|
+
|
|
4659
|
+
if (!isDomManual) {
|
|
4660
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
4661
|
+
}
|
|
4406
4662
|
}
|
|
4407
4663
|
};
|
|
4408
4664
|
const CustomElementHook = {
|
|
@@ -4494,6 +4750,44 @@ const CustomElementHook = {
|
|
|
4494
4750
|
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
4495
4751
|
removeVM(vm);
|
|
4496
4752
|
}
|
|
4753
|
+
},
|
|
4754
|
+
hydrate: (vnode, elm) => {
|
|
4755
|
+
// the element is created, but the vm is not
|
|
4756
|
+
const {
|
|
4757
|
+
sel,
|
|
4758
|
+
mode,
|
|
4759
|
+
ctor,
|
|
4760
|
+
owner
|
|
4761
|
+
} = vnode;
|
|
4762
|
+
const def = getComponentInternalDef(ctor);
|
|
4763
|
+
createVM(elm, def, {
|
|
4764
|
+
mode,
|
|
4765
|
+
owner,
|
|
4766
|
+
tagName: sel,
|
|
4767
|
+
renderer: owner.renderer
|
|
4768
|
+
});
|
|
4769
|
+
vnode.elm = elm;
|
|
4770
|
+
const vm = getAssociatedVM(elm);
|
|
4771
|
+
allocateChildrenHook(vnode, vm);
|
|
4772
|
+
hydrateElmHook(vnode); // Insert hook section:
|
|
4773
|
+
|
|
4774
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4775
|
+
shared.assert.isTrue(vm.state === 0
|
|
4776
|
+
/* created */
|
|
4777
|
+
, `${vm} cannot be recycled.`);
|
|
4778
|
+
}
|
|
4779
|
+
|
|
4780
|
+
runConnectedCallback(vm);
|
|
4781
|
+
|
|
4782
|
+
if (vm.renderMode !== 0
|
|
4783
|
+
/* Light */
|
|
4784
|
+
) {
|
|
4785
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
4786
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
4787
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4790
|
+
hydrateVM(vm);
|
|
4497
4791
|
}
|
|
4498
4792
|
};
|
|
4499
4793
|
|
|
@@ -4806,7 +5100,7 @@ function co(text) {
|
|
|
4806
5100
|
|
|
4807
5101
|
|
|
4808
5102
|
function d(value) {
|
|
4809
|
-
return value == null ? '' : value;
|
|
5103
|
+
return value == null ? '' : String(value);
|
|
4810
5104
|
} // [b]ind function
|
|
4811
5105
|
|
|
4812
5106
|
|
|
@@ -4968,9 +5262,28 @@ function sc(vnodes) {
|
|
|
4968
5262
|
|
|
4969
5263
|
markAsDynamicChildren(vnodes);
|
|
4970
5264
|
return vnodes;
|
|
4971
|
-
}
|
|
5265
|
+
}
|
|
5266
|
+
/**
|
|
5267
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
5268
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
5269
|
+
* lwc:inner-html directive.
|
|
5270
|
+
* It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
|
|
5271
|
+
*/
|
|
5272
|
+
|
|
5273
|
+
|
|
5274
|
+
let sanitizeHtmlContentHook = () => {
|
|
5275
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
|
5276
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
5277
|
+
};
|
|
5278
|
+
/**
|
|
5279
|
+
* Sets the sanitizeHtmlContentHook.
|
|
5280
|
+
*/
|
|
4972
5281
|
|
|
4973
5282
|
|
|
5283
|
+
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
5284
|
+
sanitizeHtmlContentHook = newHookImpl;
|
|
5285
|
+
} // [s]anitize [h]tml [c]ontent
|
|
5286
|
+
|
|
4974
5287
|
function shc(content) {
|
|
4975
5288
|
return sanitizeHtmlContentHook(content);
|
|
4976
5289
|
}
|
|
@@ -5162,7 +5475,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
5162
5475
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5163
5476
|
renderer.insertGlobalStylesheet(stylesheets[i]);
|
|
5164
5477
|
}
|
|
5165
|
-
} else if (renderer.ssr) {
|
|
5478
|
+
} else if (renderer.ssr || renderer.isHydrating()) {
|
|
5479
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
5480
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
5481
|
+
// the first time the VM renders.
|
|
5166
5482
|
// native shadow or light DOM, SSR
|
|
5167
5483
|
const combinedStylesheetContent = shared.ArrayJoin.call(stylesheets, '\n');
|
|
5168
5484
|
return createInlineStyleVNode(combinedStylesheetContent);
|
|
@@ -5759,12 +6075,20 @@ function connectRootElement(elm) {
|
|
|
5759
6075
|
/* GlobalHydrate */
|
|
5760
6076
|
, vm);
|
|
5761
6077
|
}
|
|
6078
|
+
function hydrateRootElement(elm) {
|
|
6079
|
+
const vm = getAssociatedVM(elm);
|
|
6080
|
+
runConnectedCallback(vm);
|
|
6081
|
+
hydrateVM(vm);
|
|
6082
|
+
}
|
|
5762
6083
|
function disconnectRootElement(elm) {
|
|
5763
6084
|
const vm = getAssociatedVM(elm);
|
|
5764
6085
|
resetComponentStateWhenRemoved(vm);
|
|
5765
6086
|
}
|
|
5766
6087
|
function appendVM(vm) {
|
|
5767
6088
|
rehydrate(vm);
|
|
6089
|
+
}
|
|
6090
|
+
function hydrateVM(vm) {
|
|
6091
|
+
hydrate(vm);
|
|
5768
6092
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
5769
6093
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5770
6094
|
|
|
@@ -5995,6 +6319,22 @@ function rehydrate(vm) {
|
|
|
5995
6319
|
}
|
|
5996
6320
|
}
|
|
5997
6321
|
|
|
6322
|
+
function hydrate(vm) {
|
|
6323
|
+
if (shared.isTrue(vm.isDirty)) {
|
|
6324
|
+
// manually diffing/patching here.
|
|
6325
|
+
// This routine is:
|
|
6326
|
+
// patchShadowRoot(vm, children);
|
|
6327
|
+
// -> addVnodes.
|
|
6328
|
+
const children = renderComponent(vm);
|
|
6329
|
+
vm.children = children;
|
|
6330
|
+
const vmChildren = vm.renderMode === 0
|
|
6331
|
+
/* Light */
|
|
6332
|
+
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6333
|
+
hydrateChildrenHook(vmChildren, children, vm);
|
|
6334
|
+
runRenderedCallback(vm);
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
|
|
5998
6338
|
function patchShadowRoot(vm, newCh) {
|
|
5999
6339
|
const {
|
|
6000
6340
|
children: oldCh
|
|
@@ -6805,35 +7145,23 @@ function readonly(obj) {
|
|
|
6805
7145
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6806
7146
|
*/
|
|
6807
7147
|
let hooksAreSet = false;
|
|
6808
|
-
|
|
6809
|
-
function overrideHooks(hooks) {
|
|
6810
|
-
const oldHooks = {};
|
|
6811
|
-
|
|
6812
|
-
if (!shared.isUndefined(hooks.sanitizeHtmlContent)) {
|
|
6813
|
-
oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
6814
|
-
}
|
|
6815
|
-
|
|
6816
|
-
return oldHooks;
|
|
6817
|
-
}
|
|
6818
|
-
|
|
6819
7148
|
function setHooks(hooks) {
|
|
6820
7149
|
shared.assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
|
6821
|
-
overrideHooks(hooks);
|
|
6822
7150
|
hooksAreSet = true;
|
|
6823
|
-
|
|
6824
|
-
function setHooksForTest(hooks) {
|
|
6825
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6826
|
-
return overrideHooks(hooks);
|
|
6827
|
-
}
|
|
7151
|
+
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
6828
7152
|
}
|
|
6829
7153
|
|
|
6830
7154
|
Object.defineProperty(exports, 'setFeatureFlag', {
|
|
6831
7155
|
enumerable: true,
|
|
6832
|
-
get: function () {
|
|
7156
|
+
get: function () {
|
|
7157
|
+
return features.setFeatureFlag;
|
|
7158
|
+
}
|
|
6833
7159
|
});
|
|
6834
7160
|
Object.defineProperty(exports, 'setFeatureFlagForTest', {
|
|
6835
7161
|
enumerable: true,
|
|
6836
|
-
get: function () {
|
|
7162
|
+
get: function () {
|
|
7163
|
+
return features.setFeatureFlagForTest;
|
|
7164
|
+
}
|
|
6837
7165
|
});
|
|
6838
7166
|
exports.LightningElement = LightningElement;
|
|
6839
7167
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -6846,6 +7174,7 @@ exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
|
|
|
6846
7174
|
exports.getComponentDef = getComponentDef;
|
|
6847
7175
|
exports.getComponentInternalDef = getComponentInternalDef;
|
|
6848
7176
|
exports.getUpgradableConstructor = getUpgradableConstructor;
|
|
7177
|
+
exports.hydrateRootElement = hydrateRootElement;
|
|
6849
7178
|
exports.isComponentConstructor = isComponentConstructor;
|
|
6850
7179
|
exports.readonly = readonly;
|
|
6851
7180
|
exports.register = register;
|
|
@@ -6854,11 +7183,10 @@ exports.registerDecorators = registerDecorators;
|
|
|
6854
7183
|
exports.registerTemplate = registerTemplate;
|
|
6855
7184
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
6856
7185
|
exports.setHooks = setHooks;
|
|
6857
|
-
exports.setHooksForTest = setHooksForTest;
|
|
6858
7186
|
exports.swapComponent = swapComponent;
|
|
6859
7187
|
exports.swapStyle = swapStyle;
|
|
6860
7188
|
exports.swapTemplate = swapTemplate;
|
|
6861
7189
|
exports.track = track;
|
|
6862
7190
|
exports.unwrap = unwrap;
|
|
6863
7191
|
exports.wire = wire;
|
|
6864
|
-
/* version: 2.5.
|
|
7192
|
+
/* version: 2.5.10-alpha1 */
|