@lwc/engine-core 2.45.0 → 2.45.1
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
CHANGED
|
@@ -530,8 +530,9 @@ function patchElementWithRestrictions(elm, options) {
|
|
|
530
530
|
get() {
|
|
531
531
|
return originalOuterHTMLDescriptor.get.call(this);
|
|
532
532
|
},
|
|
533
|
-
set(
|
|
534
|
-
|
|
533
|
+
set(value) {
|
|
534
|
+
logError(`Invalid attempt to set outerHTML on Element.`);
|
|
535
|
+
return originalOuterHTMLDescriptor.set.call(this, value);
|
|
535
536
|
},
|
|
536
537
|
}),
|
|
537
538
|
};
|
|
@@ -616,16 +617,18 @@ function getShadowRootRestrictionsDescriptors(sr) {
|
|
|
616
617
|
get() {
|
|
617
618
|
return originalInnerHTMLDescriptor.get.call(this);
|
|
618
619
|
},
|
|
619
|
-
set(
|
|
620
|
-
|
|
620
|
+
set(value) {
|
|
621
|
+
logError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
|
622
|
+
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
621
623
|
},
|
|
622
624
|
}),
|
|
623
625
|
textContent: generateAccessorDescriptor({
|
|
624
626
|
get() {
|
|
625
627
|
return originalTextContentDescriptor.get.call(this);
|
|
626
628
|
},
|
|
627
|
-
set(
|
|
628
|
-
|
|
629
|
+
set(value) {
|
|
630
|
+
logError(`Invalid attempt to set textContent on ShadowRoot.`);
|
|
631
|
+
return originalTextContentDescriptor.set.call(this, value);
|
|
629
632
|
},
|
|
630
633
|
}),
|
|
631
634
|
addEventListener: generateDataDescriptor({
|
|
@@ -654,24 +657,27 @@ function getCustomElementRestrictionsDescriptors(elm) {
|
|
|
654
657
|
get() {
|
|
655
658
|
return originalInnerHTMLDescriptor.get.call(this);
|
|
656
659
|
},
|
|
657
|
-
set(
|
|
658
|
-
|
|
660
|
+
set(value) {
|
|
661
|
+
logError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
|
662
|
+
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
659
663
|
},
|
|
660
664
|
}),
|
|
661
665
|
outerHTML: generateAccessorDescriptor({
|
|
662
666
|
get() {
|
|
663
667
|
return originalOuterHTMLDescriptor.get.call(this);
|
|
664
668
|
},
|
|
665
|
-
set(
|
|
666
|
-
|
|
669
|
+
set(value) {
|
|
670
|
+
logError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
|
671
|
+
return originalOuterHTMLDescriptor.set.call(this, value);
|
|
667
672
|
},
|
|
668
673
|
}),
|
|
669
674
|
textContent: generateAccessorDescriptor({
|
|
670
675
|
get() {
|
|
671
676
|
return originalTextContentDescriptor.get.call(this);
|
|
672
677
|
},
|
|
673
|
-
set(
|
|
674
|
-
|
|
678
|
+
set(value) {
|
|
679
|
+
logError(`Invalid attempt to set textContent on HTMLElement.`);
|
|
680
|
+
return originalTextContentDescriptor.set.call(this, value);
|
|
675
681
|
},
|
|
676
682
|
}),
|
|
677
683
|
addEventListener: generateDataDescriptor({
|
|
@@ -687,20 +693,6 @@ function getCustomElementRestrictionsDescriptors(elm) {
|
|
|
687
693
|
}),
|
|
688
694
|
};
|
|
689
695
|
}
|
|
690
|
-
function getComponentRestrictionsDescriptors() {
|
|
691
|
-
assertNotProd(); // this method should never leak to prod
|
|
692
|
-
return {
|
|
693
|
-
tagName: generateAccessorDescriptor({
|
|
694
|
-
get() {
|
|
695
|
-
throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` +
|
|
696
|
-
` not know which tagName will be used to create the element, therefore writing` +
|
|
697
|
-
` code that check for that value is error prone.`);
|
|
698
|
-
},
|
|
699
|
-
configurable: true,
|
|
700
|
-
enumerable: false, // no enumerable properties on component
|
|
701
|
-
}),
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
696
|
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
705
697
|
assertNotProd(); // this method should never leak to prod
|
|
706
698
|
const originalDispatchEvent = proto.dispatchEvent;
|
|
@@ -733,9 +725,6 @@ function patchCustomElementWithRestrictions(elm) {
|
|
|
733
725
|
const elmProto = shared.getPrototypeOf(elm);
|
|
734
726
|
shared.setPrototypeOf(elm, shared.create(elmProto, restrictionsDescriptors));
|
|
735
727
|
}
|
|
736
|
-
function patchComponentWithRestrictions(cmp) {
|
|
737
|
-
shared.defineProperties(cmp, getComponentRestrictionsDescriptors());
|
|
738
|
-
}
|
|
739
728
|
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
740
729
|
shared.defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
741
730
|
}
|
|
@@ -1346,16 +1335,10 @@ function markLockerLiveObject(obj) {
|
|
|
1346
1335
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1347
1336
|
const { get, set, enumerable, configurable } = descriptor;
|
|
1348
1337
|
if (!shared.isFunction(get)) {
|
|
1349
|
-
|
|
1350
|
-
shared.assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1351
|
-
}
|
|
1352
|
-
throw new TypeError();
|
|
1338
|
+
throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1353
1339
|
}
|
|
1354
1340
|
if (!shared.isFunction(set)) {
|
|
1355
|
-
|
|
1356
|
-
shared.assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1357
|
-
}
|
|
1358
|
-
throw new TypeError();
|
|
1341
|
+
throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1359
1342
|
}
|
|
1360
1343
|
return {
|
|
1361
1344
|
enumerable,
|
|
@@ -1375,10 +1358,18 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1375
1358
|
const vm = getAssociatedVM(this);
|
|
1376
1359
|
if (process.env.NODE_ENV !== 'production') {
|
|
1377
1360
|
const vmBeingRendered = getVMBeingRendered();
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1361
|
+
if (isInvokingRender) {
|
|
1362
|
+
logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1363
|
+
}
|
|
1364
|
+
if (isUpdatingTemplate) {
|
|
1365
|
+
logError(`When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
|
1366
|
+
}
|
|
1367
|
+
if (isBeingConstructed(vm)) {
|
|
1368
|
+
logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1369
|
+
}
|
|
1370
|
+
if (shared.isObject(newValue) && !shared.isNull(newValue)) {
|
|
1371
|
+
logError(`Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1372
|
+
}
|
|
1382
1373
|
}
|
|
1383
1374
|
updateComponentValue(vm, propName, newValue);
|
|
1384
1375
|
return set.call(vm.elm, newValue);
|
|
@@ -1431,7 +1422,6 @@ const LightningElement = function () {
|
|
|
1431
1422
|
// Adding extra guard rails in DEV mode.
|
|
1432
1423
|
if (process.env.NODE_ENV !== 'production') {
|
|
1433
1424
|
patchCustomElementWithRestrictions(elm);
|
|
1434
|
-
patchComponentWithRestrictions(component);
|
|
1435
1425
|
}
|
|
1436
1426
|
return this;
|
|
1437
1427
|
};
|
|
@@ -1467,9 +1457,15 @@ LightningElement.prototype = {
|
|
|
1467
1457
|
const { elm, renderer: { addEventListener }, } = vm;
|
|
1468
1458
|
if (process.env.NODE_ENV !== 'production') {
|
|
1469
1459
|
const vmBeingRendered = getVMBeingRendered();
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1460
|
+
if (isInvokingRender) {
|
|
1461
|
+
logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
1462
|
+
}
|
|
1463
|
+
if (isUpdatingTemplate) {
|
|
1464
|
+
logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
1465
|
+
}
|
|
1466
|
+
if (!shared.isFunction(listener)) {
|
|
1467
|
+
logError(`Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
1468
|
+
}
|
|
1473
1469
|
}
|
|
1474
1470
|
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
1475
1471
|
addEventListener(elm, type, wrappedListener, options);
|
|
@@ -1519,7 +1515,9 @@ LightningElement.prototype = {
|
|
|
1519
1515
|
const vm = getAssociatedVM(this);
|
|
1520
1516
|
const { elm, renderer: { setAttribute }, } = vm;
|
|
1521
1517
|
if (process.env.NODE_ENV !== 'production') {
|
|
1522
|
-
|
|
1518
|
+
if (isBeingConstructed(vm)) {
|
|
1519
|
+
logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1520
|
+
}
|
|
1523
1521
|
}
|
|
1524
1522
|
unlockAttribute(elm, name);
|
|
1525
1523
|
setAttribute(elm, name, value);
|
|
@@ -1529,7 +1527,9 @@ LightningElement.prototype = {
|
|
|
1529
1527
|
const vm = getAssociatedVM(this);
|
|
1530
1528
|
const { elm, renderer: { setAttribute }, } = vm;
|
|
1531
1529
|
if (process.env.NODE_ENV !== 'production') {
|
|
1532
|
-
|
|
1530
|
+
if (isBeingConstructed(vm)) {
|
|
1531
|
+
logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1532
|
+
}
|
|
1533
1533
|
}
|
|
1534
1534
|
unlockAttribute(elm, name);
|
|
1535
1535
|
setAttribute(elm, name, value, namespace);
|
|
@@ -1552,9 +1552,9 @@ LightningElement.prototype = {
|
|
|
1552
1552
|
const vm = getAssociatedVM(this);
|
|
1553
1553
|
const { elm, renderer: { getClassList }, } = vm;
|
|
1554
1554
|
if (process.env.NODE_ENV !== 'production') {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1555
|
+
if (isBeingConstructed(vm)) {
|
|
1556
|
+
logError(`Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
|
|
1557
|
+
}
|
|
1558
1558
|
}
|
|
1559
1559
|
return getClassList(elm);
|
|
1560
1560
|
},
|
|
@@ -2060,8 +2060,12 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2060
2060
|
const vm = getAssociatedVM(this);
|
|
2061
2061
|
if (process.env.NODE_ENV !== 'production') {
|
|
2062
2062
|
const vmBeingRendered = getVMBeingRendered();
|
|
2063
|
-
|
|
2064
|
-
|
|
2063
|
+
if (isInvokingRender) {
|
|
2064
|
+
logError(`render() method has side effects on the state of property "${shared.toString(key)}"`, shared.isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2065
|
+
}
|
|
2066
|
+
if (isUpdatingTemplate) {
|
|
2067
|
+
logError(`Updating the template has side effects on the state of property "${shared.toString(key)}"`, shared.isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2068
|
+
}
|
|
2065
2069
|
}
|
|
2066
2070
|
vm.cmpProps[key] = newValue;
|
|
2067
2071
|
componentValueMutated(vm, key);
|
|
@@ -2085,14 +2089,18 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2085
2089
|
const vm = getAssociatedVM(this);
|
|
2086
2090
|
if (process.env.NODE_ENV !== 'production') {
|
|
2087
2091
|
const vmBeingRendered = getVMBeingRendered();
|
|
2088
|
-
|
|
2089
|
-
|
|
2092
|
+
if (isInvokingRender) {
|
|
2093
|
+
logError(`render() method has side effects on the state of property "${shared.toString(key)}"`, shared.isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2094
|
+
}
|
|
2095
|
+
if (isUpdatingTemplate) {
|
|
2096
|
+
logError(`Updating the template has side effects on the state of property "${shared.toString(key)}"`, shared.isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2097
|
+
}
|
|
2090
2098
|
}
|
|
2091
2099
|
if (set) {
|
|
2092
2100
|
set.call(this, newValue);
|
|
2093
2101
|
}
|
|
2094
2102
|
else if (process.env.NODE_ENV !== 'production') {
|
|
2095
|
-
|
|
2103
|
+
logError(`Invalid attempt to set a new value for property "${shared.toString(key)}" that does not has a setter decorated with @api.`, vm);
|
|
2096
2104
|
}
|
|
2097
2105
|
},
|
|
2098
2106
|
enumerable,
|
|
@@ -2126,8 +2134,12 @@ function internalTrackDecorator(key) {
|
|
|
2126
2134
|
const vm = getAssociatedVM(this);
|
|
2127
2135
|
if (process.env.NODE_ENV !== 'production') {
|
|
2128
2136
|
const vmBeingRendered = getVMBeingRendered();
|
|
2129
|
-
|
|
2130
|
-
|
|
2137
|
+
if (isInvokingRender) {
|
|
2138
|
+
logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
2139
|
+
}
|
|
2140
|
+
if (isUpdatingTemplate) {
|
|
2141
|
+
logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
2142
|
+
}
|
|
2131
2143
|
}
|
|
2132
2144
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2133
2145
|
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
@@ -2904,13 +2916,20 @@ function createComponentDef(Ctor) {
|
|
|
2904
2916
|
const ctorName = Ctor.name;
|
|
2905
2917
|
// Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
|
|
2906
2918
|
// assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2919
|
+
if (!Ctor.constructor) {
|
|
2920
|
+
// This error seems impossible to hit, due to an earlier check in `isComponentConstructor()`.
|
|
2921
|
+
// But we keep it here just in case.
|
|
2922
|
+
logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
2923
|
+
}
|
|
2924
|
+
if (!shared.isUndefined(ctorShadowSupportMode) &&
|
|
2925
|
+
ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
|
|
2926
|
+
ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */) {
|
|
2927
|
+
logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
2911
2928
|
}
|
|
2912
|
-
if (!shared.isUndefined(ctorRenderMode)
|
|
2913
|
-
|
|
2929
|
+
if (!shared.isUndefined(ctorRenderMode) &&
|
|
2930
|
+
ctorRenderMode !== 'light' &&
|
|
2931
|
+
ctorRenderMode !== 'shadow') {
|
|
2932
|
+
logError(`Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
2914
2933
|
}
|
|
2915
2934
|
}
|
|
2916
2935
|
const decoratorsMeta = getDecoratorsMeta(Ctor);
|
|
@@ -4692,7 +4711,7 @@ function k(compilerKey, obj) {
|
|
|
4692
4711
|
return compilerKey + ':' + obj;
|
|
4693
4712
|
case 'object':
|
|
4694
4713
|
if (process.env.NODE_ENV !== 'production') {
|
|
4695
|
-
|
|
4714
|
+
logError(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
|
|
4696
4715
|
}
|
|
4697
4716
|
}
|
|
4698
4717
|
}
|
|
@@ -4982,13 +5001,19 @@ function validateSlots(vm) {
|
|
|
4982
5001
|
}
|
|
4983
5002
|
}
|
|
4984
5003
|
function validateLightDomTemplate(template, vm) {
|
|
4985
|
-
|
|
5004
|
+
assertNotProd(); // should never leak to prod mode
|
|
5005
|
+
if (template === defaultEmptyTemplate) {
|
|
4986
5006
|
return;
|
|
5007
|
+
}
|
|
4987
5008
|
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
4988
|
-
|
|
5009
|
+
if (template.renderMode !== 'light') {
|
|
5010
|
+
logError(`Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
|
|
5011
|
+
}
|
|
4989
5012
|
}
|
|
4990
5013
|
else {
|
|
4991
|
-
|
|
5014
|
+
if (!shared.isUndefined(template.renderMode)) {
|
|
5015
|
+
logError(`Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
|
|
5016
|
+
}
|
|
4992
5017
|
}
|
|
4993
5018
|
}
|
|
4994
5019
|
function buildParseFragmentFn(createFragmentFn) {
|
|
@@ -5121,7 +5146,9 @@ function evaluateTemplate(vm, html) {
|
|
|
5121
5146
|
logOperationEnd(1 /* OperationId.Render */, vm);
|
|
5122
5147
|
});
|
|
5123
5148
|
if (process.env.NODE_ENV !== 'production') {
|
|
5124
|
-
|
|
5149
|
+
if (!shared.isArray(vnodes)) {
|
|
5150
|
+
logError(`Compiler should produce html functions that always return an array.`);
|
|
5151
|
+
}
|
|
5125
5152
|
}
|
|
5126
5153
|
return vnodes;
|
|
5127
5154
|
}
|
|
@@ -6880,5 +6907,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
6880
6907
|
exports.track = track;
|
|
6881
6908
|
exports.unwrap = unwrap;
|
|
6882
6909
|
exports.wire = wire;
|
|
6883
|
-
/* version: 2.45.
|
|
6910
|
+
/* version: 2.45.1 */
|
|
6884
6911
|
//# sourceMappingURL=engine-core.cjs.js.map
|