@lwc/engine-core 8.11.0 → 8.12.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/framework/api.d.ts +2 -11
- package/dist/index.cjs.js +35 -195
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +60 -220
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2024 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
|
-
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isFunction as isFunction$1, keys, ArrayFilter, isObject, isArray as isArray$1, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isFunction as isFunction$1, keys, ArrayFilter, isObject, isArray as isArray$1, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString, isString, ArrayIndexOf, ArrayPop, isFalse, isTrustedSignal, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, AriaAttrNameToPropNameMap, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, assert, freeze, KEY__SYNTHETIC_MODE, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, isTrue, KEY__SCOPED_CSS, KEY__NATIVE_ONLY_CSS, ArraySplice, flattenStylesheets, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, sanitizeHtmlContent, normalizeClass, ArraySort, ArrayFrom, htmlEscape, StringCharAt, LOWEST_API_VERSION, ArrayUnshift, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, StringSplit, parseStyleText, arrayEvery, ArrayCopyWithin, ArrayFill, ArrayReverse, ArrayShift } from '@lwc/shared';
|
|
5
5
|
export { setHooks, setTrustedSignalSet } from '@lwc/shared';
|
|
6
6
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
7
7
|
|
|
@@ -266,19 +266,19 @@ let mutationLogs = [];
|
|
|
266
266
|
function toPrettyMemberNotation(parent, child) {
|
|
267
267
|
if (isUndefined$1(parent)) {
|
|
268
268
|
// Bare prop, just stringify the child
|
|
269
|
-
return toString
|
|
269
|
+
return toString(child);
|
|
270
270
|
}
|
|
271
271
|
else if (!isString(child)) {
|
|
272
272
|
// Symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
|
|
273
|
-
return `${toString
|
|
273
|
+
return `${toString(parent)}[${toString(child)}]`;
|
|
274
274
|
}
|
|
275
275
|
else if (/^\w+$/.test(child)) {
|
|
276
276
|
// Dot-notation-safe string, e.g. `obj.foo`
|
|
277
|
-
return `${toString
|
|
277
|
+
return `${toString(parent)}.${child}`;
|
|
278
278
|
}
|
|
279
279
|
else {
|
|
280
280
|
// Bracket-notation-requiring string, e.g. `obj["prop with spaces"]`
|
|
281
|
-
return `${toString
|
|
281
|
+
return `${toString(parent)}[${JSON.stringify(child)}]`;
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
function safelyCallGetter(target, key) {
|
|
@@ -767,7 +767,7 @@ const ariaDescriptor = (attrName) => ({
|
|
|
767
767
|
this.removeAttribute(attrName);
|
|
768
768
|
}
|
|
769
769
|
else {
|
|
770
|
-
this.setAttribute(attrName, toString
|
|
770
|
+
this.setAttribute(attrName, toString(newValue));
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
773
|
},
|
|
@@ -785,7 +785,7 @@ const tabIndexDescriptor = () => ({
|
|
|
785
785
|
const num = Number(newValue);
|
|
786
786
|
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
|
787
787
|
if (normalizedValue !== currentValue) {
|
|
788
|
-
this.setAttribute('tabindex', toString
|
|
788
|
+
this.setAttribute('tabindex', toString(newValue));
|
|
789
789
|
}
|
|
790
790
|
},
|
|
791
791
|
});
|
|
@@ -1088,18 +1088,6 @@ function updateComponentValue(vm, key, newValue) {
|
|
|
1088
1088
|
const { isArray } = Array;
|
|
1089
1089
|
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
|
1090
1090
|
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
|
1091
|
-
const OtS = {}.toString;
|
|
1092
|
-
function toString(obj) {
|
|
1093
|
-
if (obj && obj.toString) {
|
|
1094
|
-
return obj.toString();
|
|
1095
|
-
}
|
|
1096
|
-
else if (typeof obj === 'object') {
|
|
1097
|
-
return OtS.call(obj);
|
|
1098
|
-
}
|
|
1099
|
-
else {
|
|
1100
|
-
return obj + '';
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
1091
|
function isUndefined(obj) {
|
|
1104
1092
|
return obj === undefined;
|
|
1105
1093
|
}
|
|
@@ -1337,10 +1325,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
1337
1325
|
return true;
|
|
1338
1326
|
}
|
|
1339
1327
|
setPrototypeOf(shadowTarget, prototype) {
|
|
1340
|
-
/* istanbul ignore else */
|
|
1341
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1342
|
-
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
|
1343
|
-
}
|
|
1344
1328
|
}
|
|
1345
1329
|
preventExtensions(shadowTarget) {
|
|
1346
1330
|
if (isExtensible(shadowTarget)) {
|
|
@@ -1404,147 +1388,31 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
1404
1388
|
if (!isUndefined(wrappedSetter)) {
|
|
1405
1389
|
return wrappedSetter;
|
|
1406
1390
|
}
|
|
1407
|
-
const handler = this;
|
|
1408
1391
|
const set = function (v) {
|
|
1409
|
-
/* istanbul ignore else */
|
|
1410
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1411
|
-
const { originalTarget } = handler;
|
|
1412
|
-
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1413
|
-
}
|
|
1414
1392
|
};
|
|
1415
1393
|
setterMap.set(originalSet, set);
|
|
1416
1394
|
return set;
|
|
1417
1395
|
}
|
|
1418
1396
|
set(shadowTarget, key, value) {
|
|
1419
|
-
/* istanbul ignore else */
|
|
1420
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1421
|
-
const { originalTarget } = this;
|
|
1422
|
-
const msg = isArray(originalTarget)
|
|
1423
|
-
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
|
1424
|
-
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
|
1425
|
-
throw new Error(msg);
|
|
1426
|
-
}
|
|
1427
1397
|
/* istanbul ignore next */
|
|
1428
1398
|
return false;
|
|
1429
1399
|
}
|
|
1430
1400
|
deleteProperty(shadowTarget, key) {
|
|
1431
|
-
/* istanbul ignore else */
|
|
1432
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1433
|
-
const { originalTarget } = this;
|
|
1434
|
-
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1435
|
-
}
|
|
1436
1401
|
/* istanbul ignore next */
|
|
1437
1402
|
return false;
|
|
1438
1403
|
}
|
|
1439
1404
|
setPrototypeOf(shadowTarget, prototype) {
|
|
1440
|
-
/* istanbul ignore else */
|
|
1441
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1442
|
-
const { originalTarget } = this;
|
|
1443
|
-
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
|
1444
|
-
}
|
|
1445
1405
|
}
|
|
1446
1406
|
preventExtensions(shadowTarget) {
|
|
1447
|
-
/* istanbul ignore else */
|
|
1448
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1449
|
-
const { originalTarget } = this;
|
|
1450
|
-
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
|
1451
|
-
}
|
|
1452
1407
|
/* istanbul ignore next */
|
|
1453
1408
|
return false;
|
|
1454
1409
|
}
|
|
1455
1410
|
defineProperty(shadowTarget, key, descriptor) {
|
|
1456
|
-
/* istanbul ignore else */
|
|
1457
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1458
|
-
const { originalTarget } = this;
|
|
1459
|
-
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1460
|
-
}
|
|
1461
1411
|
/* istanbul ignore next */
|
|
1462
1412
|
return false;
|
|
1463
1413
|
}
|
|
1464
1414
|
}
|
|
1465
1415
|
|
|
1466
|
-
function extract(objectOrArray) {
|
|
1467
|
-
if (isArray(objectOrArray)) {
|
|
1468
|
-
return objectOrArray.map((item) => {
|
|
1469
|
-
const original = unwrap$1(item);
|
|
1470
|
-
if (original !== item) {
|
|
1471
|
-
return extract(original);
|
|
1472
|
-
}
|
|
1473
|
-
return item;
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
const obj = ObjectCreate(getPrototypeOf(objectOrArray));
|
|
1477
|
-
const names = getOwnPropertyNames(objectOrArray);
|
|
1478
|
-
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
|
1479
|
-
const item = objectOrArray[key];
|
|
1480
|
-
const original = unwrap$1(item);
|
|
1481
|
-
if (original !== item) {
|
|
1482
|
-
seed[key] = extract(original);
|
|
1483
|
-
}
|
|
1484
|
-
else {
|
|
1485
|
-
seed[key] = item;
|
|
1486
|
-
}
|
|
1487
|
-
return seed;
|
|
1488
|
-
}, obj);
|
|
1489
|
-
}
|
|
1490
|
-
const formatter = {
|
|
1491
|
-
header: (plainOrProxy) => {
|
|
1492
|
-
const originalTarget = unwrap$1(plainOrProxy);
|
|
1493
|
-
// if originalTarget is falsy or not unwrappable, exit
|
|
1494
|
-
if (!originalTarget || originalTarget === plainOrProxy) {
|
|
1495
|
-
return null;
|
|
1496
|
-
}
|
|
1497
|
-
const obj = extract(plainOrProxy);
|
|
1498
|
-
return ['object', { object: obj }];
|
|
1499
|
-
},
|
|
1500
|
-
hasBody: () => {
|
|
1501
|
-
return false;
|
|
1502
|
-
},
|
|
1503
|
-
body: () => {
|
|
1504
|
-
return null;
|
|
1505
|
-
},
|
|
1506
|
-
};
|
|
1507
|
-
// Inspired from paulmillr/es6-shim
|
|
1508
|
-
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
|
1509
|
-
/* istanbul ignore next */
|
|
1510
|
-
function getGlobal() {
|
|
1511
|
-
// the only reliable means to get the global object is `Function('return this')()`
|
|
1512
|
-
// However, this causes CSP violations in Chrome apps.
|
|
1513
|
-
if (typeof globalThis !== 'undefined') {
|
|
1514
|
-
return globalThis;
|
|
1515
|
-
}
|
|
1516
|
-
if (typeof self !== 'undefined') {
|
|
1517
|
-
return self;
|
|
1518
|
-
}
|
|
1519
|
-
if (typeof window !== 'undefined') {
|
|
1520
|
-
return window;
|
|
1521
|
-
}
|
|
1522
|
-
if (typeof global !== 'undefined') {
|
|
1523
|
-
return global;
|
|
1524
|
-
}
|
|
1525
|
-
// Gracefully degrade if not able to locate the global object
|
|
1526
|
-
return {};
|
|
1527
|
-
}
|
|
1528
|
-
function init() {
|
|
1529
|
-
/* istanbul ignore if */
|
|
1530
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1531
|
-
// this method should never leak to prod
|
|
1532
|
-
throw new ReferenceError();
|
|
1533
|
-
}
|
|
1534
|
-
const global = getGlobal();
|
|
1535
|
-
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
|
1536
|
-
// - Go to Settings,
|
|
1537
|
-
// - Under console, select "Enable custom formatters"
|
|
1538
|
-
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
|
1539
|
-
const devtoolsFormatters = global.devtoolsFormatters || [];
|
|
1540
|
-
ArrayPush.call(devtoolsFormatters, formatter);
|
|
1541
|
-
global.devtoolsFormatters = devtoolsFormatters;
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
/* istanbul ignore else */
|
|
1545
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1546
|
-
init();
|
|
1547
|
-
}
|
|
1548
1416
|
function defaultValueIsObservable(value) {
|
|
1549
1417
|
// intentionally checking for null
|
|
1550
1418
|
if (value === null) {
|
|
@@ -2551,7 +2419,7 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2551
2419
|
const vm = getAssociatedVM(this);
|
|
2552
2420
|
if (isBeingConstructed(vm)) {
|
|
2553
2421
|
if (process.env.NODE_ENV !== 'production') {
|
|
2554
|
-
logError(`Can’t read the value of property \`${toString
|
|
2422
|
+
logError(`Can’t read the value of property \`${toString(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2555
2423
|
}
|
|
2556
2424
|
return;
|
|
2557
2425
|
}
|
|
@@ -2564,10 +2432,10 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2564
2432
|
if (process.env.NODE_ENV !== 'production') {
|
|
2565
2433
|
const vmBeingRendered = getVMBeingRendered();
|
|
2566
2434
|
if (isInvokingRender) {
|
|
2567
|
-
logError(`render() method has side effects on the state of property "${toString
|
|
2435
|
+
logError(`render() method has side effects on the state of property "${toString(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2568
2436
|
}
|
|
2569
2437
|
if (isUpdatingTemplate) {
|
|
2570
|
-
logError(`Updating the template has side effects on the state of property "${toString
|
|
2438
|
+
logError(`Updating the template has side effects on the state of property "${toString(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2571
2439
|
}
|
|
2572
2440
|
}
|
|
2573
2441
|
vm.cmpProps[key] = newValue;
|
|
@@ -2579,7 +2447,7 @@ function createPublicPropertyDescriptor(key) {
|
|
|
2579
2447
|
}
|
|
2580
2448
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2581
2449
|
const { get, set, enumerable, configurable } = descriptor;
|
|
2582
|
-
assert.invariant(isFunction$1(get), `Invalid public accessor ${toString
|
|
2450
|
+
assert.invariant(isFunction$1(get), `Invalid public accessor ${toString(key)} decorated with @api. The property is missing a getter.`);
|
|
2583
2451
|
return {
|
|
2584
2452
|
get() {
|
|
2585
2453
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2593,17 +2461,17 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2593
2461
|
if (process.env.NODE_ENV !== 'production') {
|
|
2594
2462
|
const vmBeingRendered = getVMBeingRendered();
|
|
2595
2463
|
if (isInvokingRender) {
|
|
2596
|
-
logError(`render() method has side effects on the state of property "${toString
|
|
2464
|
+
logError(`render() method has side effects on the state of property "${toString(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2597
2465
|
}
|
|
2598
2466
|
if (isUpdatingTemplate) {
|
|
2599
|
-
logError(`Updating the template has side effects on the state of property "${toString
|
|
2467
|
+
logError(`Updating the template has side effects on the state of property "${toString(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
|
|
2600
2468
|
}
|
|
2601
2469
|
}
|
|
2602
2470
|
if (set) {
|
|
2603
2471
|
set.call(this, newValue);
|
|
2604
2472
|
}
|
|
2605
2473
|
else if (process.env.NODE_ENV !== 'production') {
|
|
2606
|
-
logError(`Invalid attempt to set a new value for property "${toString
|
|
2474
|
+
logError(`Invalid attempt to set a new value for property "${toString(key)}" that does not has a setter decorated with @api.`, vm);
|
|
2607
2475
|
}
|
|
2608
2476
|
},
|
|
2609
2477
|
enumerable,
|
|
@@ -2641,10 +2509,10 @@ function internalTrackDecorator(key) {
|
|
|
2641
2509
|
if (process.env.NODE_ENV !== 'production') {
|
|
2642
2510
|
const vmBeingRendered = getVMBeingRendered();
|
|
2643
2511
|
if (isInvokingRender) {
|
|
2644
|
-
logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString
|
|
2512
|
+
logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString(key)}`);
|
|
2645
2513
|
}
|
|
2646
2514
|
if (isUpdatingTemplate) {
|
|
2647
|
-
logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString
|
|
2515
|
+
logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString(key)}`);
|
|
2648
2516
|
}
|
|
2649
2517
|
}
|
|
2650
2518
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
@@ -5518,7 +5386,7 @@ function ti(value) {
|
|
|
5518
5386
|
if (process.env.NODE_ENV !== 'production') {
|
|
5519
5387
|
const vmBeingRendered = getVMBeingRendered();
|
|
5520
5388
|
if (shouldNormalize) {
|
|
5521
|
-
logError(`Invalid tabindex value \`${toString
|
|
5389
|
+
logError(`Invalid tabindex value \`${toString(value)}\` in template for ${vmBeingRendered}. This attribute must be set to 0 or -1.`, vmBeingRendered);
|
|
5522
5390
|
}
|
|
5523
5391
|
}
|
|
5524
5392
|
return shouldNormalize ? 0 : value;
|
|
@@ -5679,16 +5547,16 @@ function i(iterable, factory) {
|
|
|
5679
5547
|
const vmBeingRendered = getVMBeingRendered();
|
|
5680
5548
|
if (isUndefined$1(iterable) || isNull(iterable)) {
|
|
5681
5549
|
if (process.env.NODE_ENV !== 'production') {
|
|
5682
|
-
logError(`Invalid template iteration for value \`${toString
|
|
5550
|
+
logError(`Invalid template iteration for value \`${toString(iterable)}\` in ${vmBeingRendered}. It must be an array-like object.`, vmBeingRendered);
|
|
5683
5551
|
}
|
|
5684
5552
|
return list;
|
|
5685
5553
|
}
|
|
5686
5554
|
if (process.env.NODE_ENV !== 'production') {
|
|
5687
|
-
assert.isFalse(isUndefined$1(iterable[SymbolIterator]), `Invalid template iteration for value \`${toString
|
|
5555
|
+
assert.isFalse(isUndefined$1(iterable[SymbolIterator]), `Invalid template iteration for value \`${toString(iterable)}\` in ${vmBeingRendered}. It must be an array-like object.`);
|
|
5688
5556
|
}
|
|
5689
5557
|
const iterator = iterable[SymbolIterator]();
|
|
5690
5558
|
if (process.env.NODE_ENV !== 'production') {
|
|
5691
|
-
assert.isTrue(iterator && isFunction$1(iterator.next), `Invalid iterator function for "${toString
|
|
5559
|
+
assert.isTrue(iterator && isFunction$1(iterator.next), `Invalid iterator function for "${toString(iterable)}" in ${vmBeingRendered}.`);
|
|
5692
5560
|
}
|
|
5693
5561
|
let next = iterator.next();
|
|
5694
5562
|
let j = 0;
|
|
@@ -5870,7 +5738,7 @@ function ddc(sel, Ctor, data, children = EmptyArray) {
|
|
|
5870
5738
|
return null;
|
|
5871
5739
|
}
|
|
5872
5740
|
if (!isComponentConstructor(Ctor)) {
|
|
5873
|
-
throw new Error(`Invalid LWC Constructor ${toString
|
|
5741
|
+
throw new Error(`Invalid LWC Constructor ${toString(Ctor)} for custom element <${sel}>.`);
|
|
5874
5742
|
}
|
|
5875
5743
|
return c(sel, Ctor, data, children);
|
|
5876
5744
|
}
|
|
@@ -5891,13 +5759,13 @@ function dc(Ctor, data, children = EmptyArray) {
|
|
|
5891
5759
|
return null;
|
|
5892
5760
|
}
|
|
5893
5761
|
if (!isComponentConstructor(Ctor)) {
|
|
5894
|
-
throw new Error(`Invalid constructor: "${toString
|
|
5762
|
+
throw new Error(`Invalid constructor: "${toString(Ctor)}" is not a LightningElement constructor.`);
|
|
5895
5763
|
}
|
|
5896
5764
|
// Look up the dynamic component's name at runtime once the constructor is available.
|
|
5897
5765
|
// This information is only known at runtime and is stored as part of registerComponent.
|
|
5898
5766
|
const sel = getComponentRegisteredName(Ctor);
|
|
5899
5767
|
if (isUndefined$1(sel) || sel === '') {
|
|
5900
|
-
throw new Error(`Invalid LWC constructor ${toString
|
|
5768
|
+
throw new Error(`Invalid LWC constructor ${toString(Ctor)} does not have a registered name`);
|
|
5901
5769
|
}
|
|
5902
5770
|
return c(sel, Ctor, data, children);
|
|
5903
5771
|
}
|
|
@@ -5929,45 +5797,7 @@ function shc(content) {
|
|
|
5929
5797
|
const sanitizedString = sanitizeHtmlContent(content);
|
|
5930
5798
|
return createSanitizedHtmlContent(sanitizedString);
|
|
5931
5799
|
}
|
|
5932
|
-
|
|
5933
|
-
* [ncls] - Normalize class name attribute.
|
|
5934
|
-
*
|
|
5935
|
-
* Transforms the provided class property value from an object/string into a string the diffing algo
|
|
5936
|
-
* can operate on.
|
|
5937
|
-
*
|
|
5938
|
-
* This implementation is borrowed from Vue:
|
|
5939
|
-
* https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
|
|
5940
|
-
*/
|
|
5941
|
-
function ncls(value) {
|
|
5942
|
-
if (isUndefined$1(value) || isNull(value)) {
|
|
5943
|
-
// Returning undefined here improves initial render cost, because the old vnode's class will be considered
|
|
5944
|
-
// undefined in the `patchClassAttribute` routine, so `oldClass === newClass` will be true so we return early
|
|
5945
|
-
return undefined;
|
|
5946
|
-
}
|
|
5947
|
-
let res = '';
|
|
5948
|
-
if (isString(value)) {
|
|
5949
|
-
res = value;
|
|
5950
|
-
}
|
|
5951
|
-
else if (isArray$1(value)) {
|
|
5952
|
-
for (let i = 0; i < value.length; i++) {
|
|
5953
|
-
const normalized = ncls(value[i]);
|
|
5954
|
-
if (normalized) {
|
|
5955
|
-
res += normalized + ' ';
|
|
5956
|
-
}
|
|
5957
|
-
}
|
|
5958
|
-
}
|
|
5959
|
-
else if (isObject(value) && !isNull(value)) {
|
|
5960
|
-
// Iterate own enumerable keys of the object
|
|
5961
|
-
const keys$1 = keys(value);
|
|
5962
|
-
for (let i = 0; i < keys$1.length; i += 1) {
|
|
5963
|
-
const key = keys$1[i];
|
|
5964
|
-
if (value[key]) {
|
|
5965
|
-
res += key + ' ';
|
|
5966
|
-
}
|
|
5967
|
-
}
|
|
5968
|
-
}
|
|
5969
|
-
return StringTrim.call(res);
|
|
5970
|
-
}
|
|
5800
|
+
const ncls = normalizeClass;
|
|
5971
5801
|
const api = freeze({
|
|
5972
5802
|
s,
|
|
5973
5803
|
h,
|
|
@@ -6302,7 +6132,7 @@ function validateSlots(vm) {
|
|
|
6302
6132
|
assertNotProd(); // this method should never leak to prod
|
|
6303
6133
|
const { cmpSlots } = vm;
|
|
6304
6134
|
for (const slotName in cmpSlots.slotAssignments) {
|
|
6305
|
-
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString
|
|
6135
|
+
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
6306
6136
|
}
|
|
6307
6137
|
}
|
|
6308
6138
|
function checkHasMatchingRenderMode(template, vm) {
|
|
@@ -6541,7 +6371,7 @@ function evaluateTemplate(vm, html) {
|
|
|
6541
6371
|
if (html !== cmpTemplate) {
|
|
6542
6372
|
// Check that the template was built by the compiler.
|
|
6543
6373
|
if (!isTemplateRegistered(html)) {
|
|
6544
|
-
throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString
|
|
6374
|
+
throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString(html)}.`);
|
|
6545
6375
|
}
|
|
6546
6376
|
checkHasMatchingRenderMode(html, vm);
|
|
6547
6377
|
// Perf opt: do not reset the shadow root during the first rendering (there is
|
|
@@ -7720,6 +7550,8 @@ if (process.env.IS_BROWSER && isGlobalAriaPolyfillLoaded()) {
|
|
|
7720
7550
|
* SPDX-License-Identifier: MIT
|
|
7721
7551
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7722
7552
|
*/
|
|
7553
|
+
// Used as a perf optimization to avoid creating and discarding sets unnecessarily.
|
|
7554
|
+
const EMPTY_SET = new Set();
|
|
7723
7555
|
// flag indicating if the hydration recovered from the DOM mismatch
|
|
7724
7556
|
let hasMismatch = false;
|
|
7725
7557
|
function hydrateRoot(vm) {
|
|
@@ -8095,6 +7927,22 @@ function validateAttrs(vnode, elm, data, renderer, shouldValidateAttr) {
|
|
|
8095
7927
|
}
|
|
8096
7928
|
return nodesAreCompatible;
|
|
8097
7929
|
}
|
|
7930
|
+
function checkClassesCompatibility(first, second) {
|
|
7931
|
+
if (first.size !== second.size) {
|
|
7932
|
+
return false;
|
|
7933
|
+
}
|
|
7934
|
+
for (const f of first) {
|
|
7935
|
+
if (!second.has(f)) {
|
|
7936
|
+
return false;
|
|
7937
|
+
}
|
|
7938
|
+
}
|
|
7939
|
+
for (const s of second) {
|
|
7940
|
+
if (!first.has(s)) {
|
|
7941
|
+
return false;
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
return true;
|
|
7945
|
+
}
|
|
8098
7946
|
function validateClassAttr(vnode, elm, data, renderer) {
|
|
8099
7947
|
const { owner } = vnode;
|
|
8100
7948
|
// classMap is never available on VStaticPartData so it can default to undefined
|
|
@@ -8104,17 +7952,19 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8104
7952
|
// ---------- Step 1: get the classes from the element and the vnode
|
|
8105
7953
|
// Use a Set because we don't care to validate mismatches for 1) different ordering in SSR vs CSR, or 2)
|
|
8106
7954
|
// duplicated class names. These don't have an effect on rendered styles.
|
|
8107
|
-
const elmClasses = new Set(ArrayFrom(elm.classList));
|
|
7955
|
+
const elmClasses = elm.classList.length ? new Set(ArrayFrom(elm.classList)) : EMPTY_SET;
|
|
8108
7956
|
let vnodeClasses;
|
|
8109
7957
|
if (!isUndefined$1(className)) {
|
|
8110
7958
|
// ignore empty spaces entirely, filter them out using `filter(..., Boolean)`
|
|
8111
|
-
|
|
7959
|
+
const classes = ArrayFilter.call(StringSplit.call(className, /\s+/), Boolean);
|
|
7960
|
+
vnodeClasses = classes.length ? new Set(classes) : EMPTY_SET;
|
|
8112
7961
|
}
|
|
8113
7962
|
else if (!isUndefined$1(classMap)) {
|
|
8114
|
-
|
|
7963
|
+
const classes = keys(classMap);
|
|
7964
|
+
vnodeClasses = classes.length ? new Set(classes) : EMPTY_SET;
|
|
8115
7965
|
}
|
|
8116
7966
|
else {
|
|
8117
|
-
vnodeClasses =
|
|
7967
|
+
vnodeClasses = EMPTY_SET;
|
|
8118
7968
|
}
|
|
8119
7969
|
// ---------- Step 2: handle the scope tokens
|
|
8120
7970
|
// we don't care about legacy for hydration. it's a new use case
|
|
@@ -8126,7 +7976,12 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8126
7976
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
8127
7977
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
8128
7978
|
if (!isNull(scopeToken)) {
|
|
8129
|
-
vnodeClasses
|
|
7979
|
+
if (vnodeClasses === EMPTY_SET) {
|
|
7980
|
+
vnodeClasses = new Set([scopeToken]);
|
|
7981
|
+
}
|
|
7982
|
+
else {
|
|
7983
|
+
vnodeClasses.add(scopeToken);
|
|
7984
|
+
}
|
|
8130
7985
|
}
|
|
8131
7986
|
// This tells us which `*-host` scope token was rendered to the element's class.
|
|
8132
7987
|
// For now we just ignore any mismatches involving this class.
|
|
@@ -8137,27 +7992,12 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8137
7992
|
vnodeClasses.delete(elmHostScopeToken);
|
|
8138
7993
|
}
|
|
8139
7994
|
// ---------- Step 3: check for compatibility
|
|
8140
|
-
|
|
8141
|
-
if (
|
|
8142
|
-
nodesAreCompatible = false;
|
|
8143
|
-
}
|
|
8144
|
-
else {
|
|
8145
|
-
for (const vnodeClass of vnodeClasses) {
|
|
8146
|
-
if (!elmClasses.has(vnodeClass)) {
|
|
8147
|
-
nodesAreCompatible = false;
|
|
8148
|
-
}
|
|
8149
|
-
}
|
|
8150
|
-
for (const elmClass of elmClasses) {
|
|
8151
|
-
if (!vnodeClasses.has(elmClass)) {
|
|
8152
|
-
nodesAreCompatible = false;
|
|
8153
|
-
}
|
|
8154
|
-
}
|
|
8155
|
-
}
|
|
8156
|
-
if (process.env.NODE_ENV !== 'production' && !nodesAreCompatible) {
|
|
7995
|
+
const classesAreCompatible = checkClassesCompatibility(vnodeClasses, elmClasses);
|
|
7996
|
+
if (process.env.NODE_ENV !== 'production' && !classesAreCompatible) {
|
|
8157
7997
|
const prettyPrint = (set) => JSON.stringify(ArrayJoin.call(ArraySort.call(ArrayFrom(set)), ' '));
|
|
8158
7998
|
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${prettyPrint(vnodeClasses)} but found ${prettyPrint(elmClasses)}`, vnode.owner);
|
|
8159
7999
|
}
|
|
8160
|
-
return
|
|
8000
|
+
return classesAreCompatible;
|
|
8161
8001
|
}
|
|
8162
8002
|
function validateStyleAttr(vnode, elm, data, renderer) {
|
|
8163
8003
|
// Note styleDecls is always undefined for VStaticPartData, casting here to default it to undefined
|
|
@@ -8546,5 +8386,5 @@ function readonly(obj) {
|
|
|
8546
8386
|
}
|
|
8547
8387
|
|
|
8548
8388
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
8549
|
-
/** version: 8.
|
|
8389
|
+
/** version: 8.12.1 */
|
|
8550
8390
|
//# sourceMappingURL=index.js.map
|