@lwc/engine-core 2.42.0 → 2.44.0
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 +78 -199
- package/dist/engine-core.cjs.js.map +1 -1
- package/dist/engine-core.js +79 -201
- package/dist/engine-core.js.map +1 -1
- package/package.json +4 -4
- package/types/framework/attributes.d.ts +0 -7
- package/types/framework/main.d.ts +1 -0
- package/types/framework/reporting.d.ts +3 -1
- package/types/framework/stylesheet.d.ts +5 -0
package/dist/engine-core.cjs.js
CHANGED
|
@@ -446,101 +446,6 @@ const defaultDefHTMLPropertyNames = [
|
|
|
446
446
|
'tabIndex',
|
|
447
447
|
'title',
|
|
448
448
|
];
|
|
449
|
-
function offsetPropertyErrorMessage(name) {
|
|
450
|
-
return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
|
|
451
|
-
}
|
|
452
|
-
// Global HTML Attributes & Properties
|
|
453
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
|
454
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
|
|
455
|
-
//
|
|
456
|
-
// If you update this list, check for test files that recapitulate the same list. Searching the codebase
|
|
457
|
-
// for e.g. "dropzone" should suffice.
|
|
458
|
-
const globalHTMLProperties = {
|
|
459
|
-
accessKey: {
|
|
460
|
-
attribute: 'accesskey',
|
|
461
|
-
},
|
|
462
|
-
accessKeyLabel: {
|
|
463
|
-
readOnly: true,
|
|
464
|
-
},
|
|
465
|
-
className: {
|
|
466
|
-
attribute: 'class',
|
|
467
|
-
error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.',
|
|
468
|
-
},
|
|
469
|
-
contentEditable: {
|
|
470
|
-
attribute: 'contenteditable',
|
|
471
|
-
},
|
|
472
|
-
dataset: {
|
|
473
|
-
readOnly: true,
|
|
474
|
-
error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead.",
|
|
475
|
-
},
|
|
476
|
-
dir: {
|
|
477
|
-
attribute: 'dir',
|
|
478
|
-
},
|
|
479
|
-
draggable: {
|
|
480
|
-
attribute: 'draggable',
|
|
481
|
-
},
|
|
482
|
-
dropzone: {
|
|
483
|
-
attribute: 'dropzone',
|
|
484
|
-
readOnly: true,
|
|
485
|
-
},
|
|
486
|
-
hidden: {
|
|
487
|
-
attribute: 'hidden',
|
|
488
|
-
},
|
|
489
|
-
id: {
|
|
490
|
-
attribute: 'id',
|
|
491
|
-
},
|
|
492
|
-
inputMode: {
|
|
493
|
-
attribute: 'inputmode',
|
|
494
|
-
},
|
|
495
|
-
lang: {
|
|
496
|
-
attribute: 'lang',
|
|
497
|
-
},
|
|
498
|
-
slot: {
|
|
499
|
-
attribute: 'slot',
|
|
500
|
-
error: 'Using the `slot` property is an anti-pattern.',
|
|
501
|
-
},
|
|
502
|
-
spellcheck: {
|
|
503
|
-
attribute: 'spellcheck',
|
|
504
|
-
},
|
|
505
|
-
style: {
|
|
506
|
-
attribute: 'style',
|
|
507
|
-
},
|
|
508
|
-
tabIndex: {
|
|
509
|
-
attribute: 'tabindex',
|
|
510
|
-
},
|
|
511
|
-
title: {
|
|
512
|
-
attribute: 'title',
|
|
513
|
-
},
|
|
514
|
-
translate: {
|
|
515
|
-
attribute: 'translate',
|
|
516
|
-
},
|
|
517
|
-
// additional "global attributes" that are not present in the link above.
|
|
518
|
-
isContentEditable: {
|
|
519
|
-
readOnly: true,
|
|
520
|
-
},
|
|
521
|
-
offsetHeight: {
|
|
522
|
-
readOnly: true,
|
|
523
|
-
error: offsetPropertyErrorMessage('offsetHeight'),
|
|
524
|
-
},
|
|
525
|
-
offsetLeft: {
|
|
526
|
-
readOnly: true,
|
|
527
|
-
error: offsetPropertyErrorMessage('offsetLeft'),
|
|
528
|
-
},
|
|
529
|
-
offsetParent: {
|
|
530
|
-
readOnly: true,
|
|
531
|
-
},
|
|
532
|
-
offsetTop: {
|
|
533
|
-
readOnly: true,
|
|
534
|
-
error: offsetPropertyErrorMessage('offsetTop'),
|
|
535
|
-
},
|
|
536
|
-
offsetWidth: {
|
|
537
|
-
readOnly: true,
|
|
538
|
-
error: offsetPropertyErrorMessage('offsetWidth'),
|
|
539
|
-
},
|
|
540
|
-
role: {
|
|
541
|
-
attribute: 'role',
|
|
542
|
-
},
|
|
543
|
-
};
|
|
544
449
|
let controlledElement = null;
|
|
545
450
|
let controlledAttributeName;
|
|
546
451
|
function isAttributeLocked(elm, attrName) {
|
|
@@ -725,8 +630,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
|
|
|
725
630
|
}),
|
|
726
631
|
addEventListener: generateDataDescriptor({
|
|
727
632
|
value(type, listener, options) {
|
|
728
|
-
// TODO [#
|
|
729
|
-
// programmatically into its Component's shadow root
|
|
633
|
+
// TODO [#1824]: Potentially relax this restriction
|
|
730
634
|
if (!shared.isUndefined(options)) {
|
|
731
635
|
logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
|
|
732
636
|
}
|
|
@@ -772,8 +676,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
|
|
|
772
676
|
}),
|
|
773
677
|
addEventListener: generateDataDescriptor({
|
|
774
678
|
value(type, listener, options) {
|
|
775
|
-
// TODO [#
|
|
776
|
-
// programmatically into a lighting element node
|
|
679
|
+
// TODO [#1824]: Potentially relax this restriction
|
|
777
680
|
if (!shared.isUndefined(options)) {
|
|
778
681
|
logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
|
779
682
|
}
|
|
@@ -801,7 +704,7 @@ function getComponentRestrictionsDescriptors() {
|
|
|
801
704
|
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
802
705
|
assertNotProd(); // this method should never leak to prod
|
|
803
706
|
const originalDispatchEvent = proto.dispatchEvent;
|
|
804
|
-
|
|
707
|
+
return {
|
|
805
708
|
dispatchEvent: generateDataDescriptor({
|
|
806
709
|
value(event) {
|
|
807
710
|
const vm = getAssociatedVM(this);
|
|
@@ -819,32 +722,6 @@ function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
|
819
722
|
},
|
|
820
723
|
}),
|
|
821
724
|
};
|
|
822
|
-
shared.forEach.call(shared.getOwnPropertyNames(globalHTMLProperties), (propName) => {
|
|
823
|
-
if (propName in proto) {
|
|
824
|
-
return; // no need to redefine something that we are already exposing
|
|
825
|
-
}
|
|
826
|
-
descriptors[propName] = generateAccessorDescriptor({
|
|
827
|
-
get() {
|
|
828
|
-
const { error, attribute } = globalHTMLProperties[propName];
|
|
829
|
-
const msg = [];
|
|
830
|
-
msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
|
831
|
-
if (error) {
|
|
832
|
-
msg.push(error);
|
|
833
|
-
}
|
|
834
|
-
else if (attribute) {
|
|
835
|
-
msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
|
836
|
-
}
|
|
837
|
-
logError(msg.join('\n'), getAssociatedVM(this));
|
|
838
|
-
},
|
|
839
|
-
set() {
|
|
840
|
-
const { readOnly } = globalHTMLProperties[propName];
|
|
841
|
-
if (readOnly) {
|
|
842
|
-
logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
});
|
|
846
|
-
});
|
|
847
|
-
return descriptors;
|
|
848
725
|
}
|
|
849
726
|
// This routine will prevent access to certain properties on a shadow root instance to guarantee
|
|
850
727
|
// that all components will work fine in IE11 and other browsers without shadow dom support.
|
|
@@ -2195,12 +2072,7 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2195
2072
|
}
|
|
2196
2073
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2197
2074
|
const { get, set, enumerable, configurable } = descriptor;
|
|
2198
|
-
|
|
2199
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2200
|
-
shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
|
|
2201
|
-
}
|
|
2202
|
-
throw new Error();
|
|
2203
|
-
}
|
|
2075
|
+
shared.assert.invariant(shared.isFunction(get), `Invalid public accessor ${shared.toString(key)} decorated with @api. The property is missing a getter.`);
|
|
2204
2076
|
return {
|
|
2205
2077
|
get() {
|
|
2206
2078
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2322,64 +2194,64 @@ function getClassDescriptorType(descriptor) {
|
|
|
2322
2194
|
}
|
|
2323
2195
|
}
|
|
2324
2196
|
function validateObservedField(Ctor, fieldName, descriptor) {
|
|
2197
|
+
assertNotProd(); // this method should never leak to prod
|
|
2325
2198
|
if (!shared.isUndefined(descriptor)) {
|
|
2326
2199
|
const type = getClassDescriptorType(descriptor);
|
|
2327
2200
|
const message = `Invalid observed ${fieldName} field. Found a duplicate ${type} with the same name.`;
|
|
2328
|
-
// [
|
|
2329
|
-
|
|
2330
|
-
if (type === "accessor" /* DescriptorType.Accessor */) {
|
|
2331
|
-
logError(message);
|
|
2332
|
-
}
|
|
2333
|
-
else {
|
|
2334
|
-
shared.assert.fail(message);
|
|
2335
|
-
}
|
|
2201
|
+
// TODO [#3408]: this should throw, not log
|
|
2202
|
+
logError(message);
|
|
2336
2203
|
}
|
|
2337
2204
|
}
|
|
2338
2205
|
function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
|
|
2206
|
+
assertNotProd(); // this method should never leak to prod
|
|
2339
2207
|
if (!shared.isUndefined(descriptor)) {
|
|
2340
2208
|
const type = getClassDescriptorType(descriptor);
|
|
2341
|
-
|
|
2209
|
+
// TODO [#3408]: this should throw, not log
|
|
2210
|
+
logError(`Invalid @track ${fieldName} field. Found a duplicate ${type} with the same name.`);
|
|
2342
2211
|
}
|
|
2343
2212
|
}
|
|
2344
2213
|
function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
|
|
2214
|
+
assertNotProd(); // this method should never leak to prod
|
|
2345
2215
|
if (!shared.isUndefined(descriptor)) {
|
|
2346
2216
|
const type = getClassDescriptorType(descriptor);
|
|
2347
|
-
|
|
2217
|
+
// TODO [#3408]: this should throw, not log
|
|
2218
|
+
logError(`Invalid @wire ${fieldName} field. Found a duplicate ${type} with the same name.`);
|
|
2348
2219
|
}
|
|
2349
2220
|
}
|
|
2350
2221
|
function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
|
|
2222
|
+
assertNotProd(); // this method should never leak to prod
|
|
2351
2223
|
if (shared.isUndefined(descriptor) || !shared.isFunction(descriptor.value) || shared.isFalse(descriptor.writable)) {
|
|
2352
|
-
|
|
2224
|
+
// TODO [#3441]: This line of code does not seem possible to reach.
|
|
2225
|
+
logError(`Invalid @wire ${methodName} field. The field should have a valid writable descriptor.`);
|
|
2353
2226
|
}
|
|
2354
2227
|
}
|
|
2355
2228
|
function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
|
|
2229
|
+
assertNotProd(); // this method should never leak to prod
|
|
2356
2230
|
if (!shared.isUndefined(descriptor)) {
|
|
2357
2231
|
const type = getClassDescriptorType(descriptor);
|
|
2358
2232
|
const message = `Invalid @api ${fieldName} field. Found a duplicate ${type} with the same name.`;
|
|
2359
|
-
// [
|
|
2360
|
-
|
|
2361
|
-
if (type === "accessor" /* DescriptorType.Accessor */) {
|
|
2362
|
-
logError(message);
|
|
2363
|
-
}
|
|
2364
|
-
else {
|
|
2365
|
-
shared.assert.fail(message);
|
|
2366
|
-
}
|
|
2233
|
+
// TODO [#3408]: this should throw, not log
|
|
2234
|
+
logError(message);
|
|
2367
2235
|
}
|
|
2368
2236
|
}
|
|
2369
2237
|
function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2238
|
+
assertNotProd(); // this method should never leak to prod
|
|
2239
|
+
if (shared.isFunction(descriptor.set)) {
|
|
2240
|
+
if (!shared.isFunction(descriptor.get)) {
|
|
2241
|
+
// TODO [#3441]: This line of code does not seem possible to reach.
|
|
2242
|
+
logError(`Missing getter for property ${fieldName} decorated with @api in ${Ctor}. You cannot have a setter without the corresponding getter.`);
|
|
2243
|
+
}
|
|
2375
2244
|
}
|
|
2376
2245
|
else if (!shared.isFunction(descriptor.get)) {
|
|
2377
|
-
|
|
2246
|
+
// TODO [#3441]: This line of code does not seem possible to reach.
|
|
2247
|
+
logError(`Missing @api get ${fieldName} accessor.`);
|
|
2378
2248
|
}
|
|
2379
2249
|
}
|
|
2380
2250
|
function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
|
|
2251
|
+
assertNotProd(); // this method should never leak to prod
|
|
2381
2252
|
if (shared.isUndefined(descriptor) || !shared.isFunction(descriptor.value) || shared.isFalse(descriptor.writable)) {
|
|
2382
|
-
|
|
2253
|
+
// TODO [#3441]: This line of code does not seem possible to reach.
|
|
2254
|
+
logError(`Invalid @api ${methodName} method.`);
|
|
2383
2255
|
}
|
|
2384
2256
|
}
|
|
2385
2257
|
/**
|
|
@@ -2402,13 +2274,14 @@ function registerDecorators(Ctor, meta) {
|
|
|
2402
2274
|
apiFieldsConfig[fieldName] = propConfig.config;
|
|
2403
2275
|
descriptor = shared.getOwnPropertyDescriptor(proto, fieldName);
|
|
2404
2276
|
if (propConfig.config > 0) {
|
|
2277
|
+
if (shared.isUndefined(descriptor)) {
|
|
2278
|
+
// TODO [#3441]: This line of code does not seem possible to reach.
|
|
2279
|
+
throw new Error();
|
|
2280
|
+
}
|
|
2405
2281
|
// accessor declaration
|
|
2406
2282
|
if (process.env.NODE_ENV !== 'production') {
|
|
2407
2283
|
validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
|
|
2408
2284
|
}
|
|
2409
|
-
if (shared.isUndefined(descriptor)) {
|
|
2410
|
-
throw new Error();
|
|
2411
|
-
}
|
|
2412
2285
|
descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
|
|
2413
2286
|
}
|
|
2414
2287
|
else {
|
|
@@ -2448,7 +2321,10 @@ function registerDecorators(Ctor, meta) {
|
|
|
2448
2321
|
descriptor = shared.getOwnPropertyDescriptor(proto, fieldOrMethodName);
|
|
2449
2322
|
if (method === 1) {
|
|
2450
2323
|
if (process.env.NODE_ENV !== 'production') {
|
|
2451
|
-
|
|
2324
|
+
if (!adapter) {
|
|
2325
|
+
// TODO [#3408]: this should throw, not log
|
|
2326
|
+
logError(`@wire on method "${fieldOrMethodName}": adapter id must be truthy.`);
|
|
2327
|
+
}
|
|
2452
2328
|
validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
|
2453
2329
|
}
|
|
2454
2330
|
if (shared.isUndefined(descriptor)) {
|
|
@@ -2459,7 +2335,10 @@ function registerDecorators(Ctor, meta) {
|
|
|
2459
2335
|
}
|
|
2460
2336
|
else {
|
|
2461
2337
|
if (process.env.NODE_ENV !== 'production') {
|
|
2462
|
-
|
|
2338
|
+
if (!adapter) {
|
|
2339
|
+
// TODO [#3408]: this should throw, not log
|
|
2340
|
+
logError(`@wire on field "${fieldOrMethodName}": adapter id must be truthy.`);
|
|
2341
|
+
}
|
|
2463
2342
|
validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
|
2464
2343
|
}
|
|
2465
2344
|
descriptor = internalWireFieldDecorator(fieldOrMethodName);
|
|
@@ -3265,6 +3144,15 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
|
3265
3144
|
// the stylesheet, while internally, we have a replacement for it.
|
|
3266
3145
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3267
3146
|
}
|
|
3147
|
+
// Check that this stylesheet was generated by our compiler
|
|
3148
|
+
if (!isStylesheetRegistered(stylesheet)) {
|
|
3149
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3150
|
+
logWarnOnce(`TypeError: Unexpected LWC stylesheet content found for component <${vm.tagName.toLowerCase()}>.`);
|
|
3151
|
+
}
|
|
3152
|
+
report("UnexpectedStylesheetContent" /* ReportingEventId.UnexpectedStylesheetContent */, {
|
|
3153
|
+
tagName: vm.tagName.toLowerCase(),
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3268
3156
|
const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
|
|
3269
3157
|
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS &&
|
|
3270
3158
|
!isScopedCss &&
|
|
@@ -3385,6 +3273,18 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3385
3273
|
}
|
|
3386
3274
|
return null;
|
|
3387
3275
|
}
|
|
3276
|
+
const signedStylesheetSet = new Set();
|
|
3277
|
+
/**
|
|
3278
|
+
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3279
|
+
* will prevent this function from being imported by userland code.
|
|
3280
|
+
*/
|
|
3281
|
+
function registerStylesheet(stylesheet) {
|
|
3282
|
+
signedStylesheetSet.add(stylesheet);
|
|
3283
|
+
return stylesheet;
|
|
3284
|
+
}
|
|
3285
|
+
function isStylesheetRegistered(stylesheet) {
|
|
3286
|
+
return signedStylesheetSet.has(stylesheet);
|
|
3287
|
+
}
|
|
3388
3288
|
|
|
3389
3289
|
/*
|
|
3390
3290
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5094,18 +4994,12 @@ function getVMBeingRendered() {
|
|
|
5094
4994
|
function setVMBeingRendered(vm) {
|
|
5095
4995
|
vmBeingRendered = vm;
|
|
5096
4996
|
}
|
|
5097
|
-
function validateSlots(vm
|
|
4997
|
+
function validateSlots(vm) {
|
|
5098
4998
|
assertNotProd(); // this method should never leak to prod
|
|
5099
4999
|
const { cmpSlots } = vm;
|
|
5100
|
-
const { slots = EmptyArray } = html;
|
|
5101
5000
|
for (const slotName in cmpSlots.slotAssignments) {
|
|
5102
5001
|
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5103
5002
|
shared.assert.isTrue(shared.isArray(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${shared.toString(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
5104
|
-
if (slotName !== '' && shared.ArrayIndexOf.call(slots, slotName) === -1) {
|
|
5105
|
-
// TODO [#1297]: this should never really happen because the compiler should always validate
|
|
5106
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-production-assert
|
|
5107
|
-
logError(`Ignoring unknown provided slot name "${slotName}" in ${vm}. Check for a typo on the slot attribute.`, vm);
|
|
5108
|
-
}
|
|
5109
5003
|
}
|
|
5110
5004
|
}
|
|
5111
5005
|
function validateLightDomTemplate(template, vm) {
|
|
@@ -5224,7 +5118,7 @@ function evaluateTemplate(vm, html) {
|
|
|
5224
5118
|
}
|
|
5225
5119
|
if (process.env.NODE_ENV !== 'production') {
|
|
5226
5120
|
// validating slots in every rendering since the allocated content might change over time
|
|
5227
|
-
validateSlots(vm
|
|
5121
|
+
validateSlots(vm);
|
|
5228
5122
|
// add the VM to the list of host VMs that can be re-rendered if html is swapped
|
|
5229
5123
|
setActiveVM(vm);
|
|
5230
5124
|
}
|
|
@@ -6210,7 +6104,7 @@ function checkAndReportViolation(elm, prop, isSetter, setValue) {
|
|
|
6210
6104
|
const vm = findVM(elm);
|
|
6211
6105
|
if (process.env.NODE_ENV !== 'production') {
|
|
6212
6106
|
logWarnOnce(`Element <${elm.tagName.toLowerCase()}> ` +
|
|
6213
|
-
(shared.isUndefined(vm) ? '' : `owned by <${vm.
|
|
6107
|
+
(shared.isUndefined(vm) ? '' : `owned by <${vm.tagName.toLowerCase()}> `) +
|
|
6214
6108
|
`uses non-standard property "${prop}". This will be removed in a future version of LWC. ` +
|
|
6215
6109
|
`See https://sfdc.co/deprecated-aria`);
|
|
6216
6110
|
}
|
|
@@ -6327,8 +6221,6 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
6327
6221
|
return renderer.nextSibling(hydratedNode);
|
|
6328
6222
|
}
|
|
6329
6223
|
const NODE_VALUE_PROP = 'nodeValue';
|
|
6330
|
-
const PARENT_NODE_PROP = 'parentNode';
|
|
6331
|
-
const TAG_NAME_PROP = 'tagName';
|
|
6332
6224
|
function textNodeContentsAreEqual(node, vnode, renderer) {
|
|
6333
6225
|
const { getProperty } = renderer;
|
|
6334
6226
|
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
@@ -6340,22 +6232,6 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
|
|
|
6340
6232
|
if (nodeValue === '\u200D' && vnode.text === '') {
|
|
6341
6233
|
return true;
|
|
6342
6234
|
}
|
|
6343
|
-
// Special case for text nodes inside `<style>` tags – these are escaped when rendered server-size,
|
|
6344
|
-
// but not when generated by the engine client-side.
|
|
6345
|
-
const parentNode = getProperty(node, PARENT_NODE_PROP);
|
|
6346
|
-
// Should never be null, but just to be safe, we check.
|
|
6347
|
-
/* istanbul ignore else */
|
|
6348
|
-
if (!shared.isNull(parentNode)) {
|
|
6349
|
-
const tagName = getProperty(parentNode, TAG_NAME_PROP);
|
|
6350
|
-
// If the tagName is STYLE, then the following condition should always be true.
|
|
6351
|
-
// The LWC compiler blocks using `<style>`s inside of templates, so it should be impossible
|
|
6352
|
-
// for component authors to render different `<style>` text content on the client and server.
|
|
6353
|
-
// But just to be safe, we check.
|
|
6354
|
-
/* istanbul ignore next */
|
|
6355
|
-
if (tagName === 'STYLE' && shared.htmlEscape(vnode.text) === nodeValue) {
|
|
6356
|
-
return true;
|
|
6357
|
-
}
|
|
6358
|
-
}
|
|
6359
6235
|
return false;
|
|
6360
6236
|
}
|
|
6361
6237
|
function hydrateText(node, vnode, renderer) {
|
|
@@ -6579,7 +6455,7 @@ function validateAttrs(vnode, elm, renderer) {
|
|
|
6579
6455
|
function validateClassAttr(vnode, elm, renderer) {
|
|
6580
6456
|
const { data, owner } = vnode;
|
|
6581
6457
|
let { className, classMap } = data;
|
|
6582
|
-
const { getProperty, getClassList } = renderer;
|
|
6458
|
+
const { getProperty, getClassList, getAttribute } = renderer;
|
|
6583
6459
|
const scopedToken = getScopeTokenClass(owner);
|
|
6584
6460
|
const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
|
|
6585
6461
|
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
@@ -6609,11 +6485,12 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6609
6485
|
}
|
|
6610
6486
|
let nodesAreCompatible = true;
|
|
6611
6487
|
let readableVnodeClassname;
|
|
6612
|
-
const elmClassName =
|
|
6488
|
+
const elmClassName = getAttribute(elm, 'class');
|
|
6613
6489
|
if (!shared.isUndefined(className) && String(className) !== elmClassName) {
|
|
6614
6490
|
// className is used when class is bound to an expr.
|
|
6615
6491
|
nodesAreCompatible = false;
|
|
6616
|
-
|
|
6492
|
+
// stringify for pretty-printing
|
|
6493
|
+
readableVnodeClassname = JSON.stringify(className);
|
|
6617
6494
|
}
|
|
6618
6495
|
else if (!shared.isUndefined(classMap)) {
|
|
6619
6496
|
// classMap is used when class is set to static value.
|
|
@@ -6626,19 +6503,20 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6626
6503
|
nodesAreCompatible = false;
|
|
6627
6504
|
}
|
|
6628
6505
|
}
|
|
6629
|
-
|
|
6506
|
+
// stringify for pretty-printing
|
|
6507
|
+
readableVnodeClassname = JSON.stringify(computedClassName.trim());
|
|
6630
6508
|
if (classList.length > shared.keys(classMap).length) {
|
|
6631
6509
|
nodesAreCompatible = false;
|
|
6632
6510
|
}
|
|
6633
6511
|
}
|
|
6634
|
-
else if (shared.isUndefined(className) && elmClassName
|
|
6512
|
+
else if (shared.isUndefined(className) && !shared.isNull(elmClassName)) {
|
|
6635
6513
|
// SSR contains a className but client-side VDOM does not
|
|
6636
6514
|
nodesAreCompatible = false;
|
|
6637
|
-
readableVnodeClassname = '';
|
|
6515
|
+
readableVnodeClassname = '""';
|
|
6638
6516
|
}
|
|
6639
6517
|
if (!nodesAreCompatible) {
|
|
6640
6518
|
if (process.env.NODE_ENV !== 'production') {
|
|
6641
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected
|
|
6519
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${readableVnodeClassname} but found ${JSON.stringify(elmClassName)}`, vnode.owner);
|
|
6642
6520
|
}
|
|
6643
6521
|
}
|
|
6644
6522
|
return nodesAreCompatible;
|
|
@@ -6979,7 +6857,7 @@ function readonly(obj) {
|
|
|
6979
6857
|
if (process.env.NODE_ENV !== 'production') {
|
|
6980
6858
|
// TODO [#1292]: Remove the readonly decorator
|
|
6981
6859
|
if (arguments.length !== 1) {
|
|
6982
|
-
|
|
6860
|
+
logError('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
6983
6861
|
}
|
|
6984
6862
|
}
|
|
6985
6863
|
return getReadOnlyProxy(obj);
|
|
@@ -7014,6 +6892,7 @@ exports.readonly = readonly;
|
|
|
7014
6892
|
exports.register = register;
|
|
7015
6893
|
exports.registerComponent = registerComponent;
|
|
7016
6894
|
exports.registerDecorators = registerDecorators;
|
|
6895
|
+
exports.registerStylesheet = registerStylesheet;
|
|
7017
6896
|
exports.registerTemplate = registerTemplate;
|
|
7018
6897
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
7019
6898
|
exports.setHooks = setHooks;
|
|
@@ -7023,5 +6902,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
7023
6902
|
exports.track = track;
|
|
7024
6903
|
exports.unwrap = unwrap;
|
|
7025
6904
|
exports.wire = wire;
|
|
7026
|
-
/* version: 2.
|
|
6905
|
+
/* version: 2.44.0 */
|
|
7027
6906
|
//# sourceMappingURL=engine-core.cjs.js.map
|