@lwc/engine-core 8.2.0 → 8.4.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/README.md +6 -0
- package/dist/framework/main.d.ts +1 -0
- package/dist/framework/reporting.d.ts +7 -2
- package/dist/index.cjs.js +54 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +52 -25
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString as toString$1, isString, ArrayIndexOf, ArrayPop, isFalse, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, 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, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, 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';
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, seal, create, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, ArrayFilter, isObject, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertySymbols as getOwnPropertySymbols$1, toString as toString$1, isString, ArrayIndexOf, ArrayPop, isFalse, isTrustedSignal, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, 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, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, StringTrim, ArraySort, ArrayFrom, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, 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
|
+
export { setTrustedSignalSet } from '@lwc/shared';
|
|
5
6
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
6
7
|
|
|
7
8
|
/*
|
|
@@ -292,6 +293,16 @@ function toPrettyMemberNotation(parent, child) {
|
|
|
292
293
|
return `${toString$1(parent)}[${JSON.stringify(child)}]`;
|
|
293
294
|
}
|
|
294
295
|
}
|
|
296
|
+
function safelyCallGetter(target, key) {
|
|
297
|
+
// Arbitrary getters can throw. We don't want to throw an error just due to dev-mode-only mutation tracking
|
|
298
|
+
// (which is only used for performance debugging) so ignore errors here.
|
|
299
|
+
try {
|
|
300
|
+
return target[key];
|
|
301
|
+
}
|
|
302
|
+
catch (_err) {
|
|
303
|
+
/* ignore */
|
|
304
|
+
}
|
|
305
|
+
}
|
|
295
306
|
/**
|
|
296
307
|
* Flush all the logs we've written so far and return the current logs.
|
|
297
308
|
*/
|
|
@@ -360,7 +371,7 @@ function trackTargetForMutationLogging(key, target) {
|
|
|
360
371
|
// Deeply traverse arrays and objects to track every object within
|
|
361
372
|
if (isArray$1(target)) {
|
|
362
373
|
for (let i = 0; i < target.length; i++) {
|
|
363
|
-
trackTargetForMutationLogging(toPrettyMemberNotation(key, i), target
|
|
374
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, i), safelyCallGetter(target, i));
|
|
364
375
|
}
|
|
365
376
|
}
|
|
366
377
|
else {
|
|
@@ -369,10 +380,10 @@ function trackTargetForMutationLogging(key, target) {
|
|
|
369
380
|
// https://github.com/salesforce/observable-membrane/blob/b85417f/src/base-handler.ts#L142-L143
|
|
370
381
|
// Note this code path is very hot, hence doing two separate for-loops rather than creating a new array.
|
|
371
382
|
for (const prop of getOwnPropertyNames$1(target)) {
|
|
372
|
-
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target
|
|
383
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
|
|
373
384
|
}
|
|
374
385
|
for (const prop of getOwnPropertySymbols$1(target)) {
|
|
375
|
-
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), target
|
|
386
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
|
|
376
387
|
}
|
|
377
388
|
}
|
|
378
389
|
}
|
|
@@ -598,6 +609,7 @@ function componentValueObserved(vm, key, target = {}) {
|
|
|
598
609
|
'value' in target &&
|
|
599
610
|
'subscribe' in target &&
|
|
600
611
|
isFunction$1(target.subscribe) &&
|
|
612
|
+
isTrustedSignal(target) &&
|
|
601
613
|
// Only subscribe if a template is being rendered by the engine
|
|
602
614
|
tro.isObserving()) {
|
|
603
615
|
// Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
|
|
@@ -664,8 +676,9 @@ for (const [propName, attrName] of entries(AriaPropNameToAttrNameMap)) {
|
|
|
664
676
|
return this.getAttribute(attrName);
|
|
665
677
|
},
|
|
666
678
|
set(newValue) {
|
|
667
|
-
// TODO [#3284]:
|
|
668
|
-
//
|
|
679
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
|
680
|
+
// (null and undefined) should remove the attribute; however, we
|
|
681
|
+
// only do so in the case of null for historical reasons.
|
|
669
682
|
// See also https://github.com/w3c/aria/issues/1858
|
|
670
683
|
if (isNull(newValue)) {
|
|
671
684
|
this.removeAttribute(attrName);
|
|
@@ -6178,19 +6191,30 @@ function validateSlots(vm) {
|
|
|
6178
6191
|
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
|
6179
6192
|
}
|
|
6180
6193
|
}
|
|
6181
|
-
function
|
|
6182
|
-
|
|
6183
|
-
if (
|
|
6194
|
+
function checkHasMatchingRenderMode(template, vm) {
|
|
6195
|
+
// don't validate in prod environments where reporting is disabled
|
|
6196
|
+
if (process.env.NODE_ENV === 'production' && !isReportingEnabled()) {
|
|
6184
6197
|
return;
|
|
6185
6198
|
}
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
}
|
|
6199
|
+
// don't validate the default empty template - it is not inherently light or shadow
|
|
6200
|
+
if (template === defaultEmptyTemplate) {
|
|
6201
|
+
return;
|
|
6190
6202
|
}
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6203
|
+
// TODO [#4663]: `renderMode` mismatch between template and component causes `console.error` but no error
|
|
6204
|
+
// Note that `undefined` means shadow in this case, because shadow is the default.
|
|
6205
|
+
const vmIsLight = vm.renderMode === 0 /* RenderMode.Light */;
|
|
6206
|
+
const templateIsLight = template.renderMode === 'light';
|
|
6207
|
+
if (vmIsLight !== templateIsLight) {
|
|
6208
|
+
report("RenderModeMismatch" /* ReportingEventId.RenderModeMismatch */, {
|
|
6209
|
+
tagName: vm.tagName,
|
|
6210
|
+
mode: vm.renderMode,
|
|
6211
|
+
});
|
|
6212
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6213
|
+
const tagName = getComponentTag(vm);
|
|
6214
|
+
const message = vmIsLight
|
|
6215
|
+
? `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${tagName}.`
|
|
6216
|
+
: `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${tagName} or set it to 'lwc:render-mode="shadow"`;
|
|
6217
|
+
logError(message);
|
|
6194
6218
|
}
|
|
6195
6219
|
}
|
|
6196
6220
|
}
|
|
@@ -6405,9 +6429,7 @@ function evaluateTemplate(vm, html) {
|
|
|
6405
6429
|
if (!isTemplateRegistered(html)) {
|
|
6406
6430
|
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$1(html)}.`);
|
|
6407
6431
|
}
|
|
6408
|
-
|
|
6409
|
-
validateLightDomTemplate(html, vm);
|
|
6410
|
-
}
|
|
6432
|
+
checkHasMatchingRenderMode(html, vm);
|
|
6411
6433
|
// Perf opt: do not reset the shadow root during the first rendering (there is
|
|
6412
6434
|
// nothing to reset).
|
|
6413
6435
|
if (!isNull(cmpTemplate)) {
|
|
@@ -7994,7 +8016,10 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
7994
8016
|
let nodesAreCompatible = true;
|
|
7995
8017
|
let readableVnodeClassname;
|
|
7996
8018
|
const elmClassName = getAttribute(elm, 'class');
|
|
7997
|
-
if (!isUndefined$1(className) &&
|
|
8019
|
+
if (!isUndefined$1(className) &&
|
|
8020
|
+
String(className) !== elmClassName &&
|
|
8021
|
+
// No mismatch if SSR `class` attribute is missing and CSR `class` is the empty string
|
|
8022
|
+
!(className === '' && isNull(elmClassName))) {
|
|
7998
8023
|
// className is used when class is bound to an expr.
|
|
7999
8024
|
nodesAreCompatible = false;
|
|
8000
8025
|
// stringify for pretty-printing
|
|
@@ -8133,13 +8158,15 @@ function haveCompatibleStaticParts(vnode, renderer) {
|
|
|
8133
8158
|
// Explicitly skip hydration validation when static parts don't contain `style` or `className`.
|
|
8134
8159
|
// This means the style/class attributes are either static or don't exist on the element and
|
|
8135
8160
|
// cannot be affected by hydration.
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
: true;
|
|
8161
|
+
// We need to do class first, style second to match the ordering of non-static-optimized nodes,
|
|
8162
|
+
// otherwise the ordering of console errors is different between the two.
|
|
8139
8163
|
const hasMatchingClass = shouldValidateAttr(data, 'className')
|
|
8140
8164
|
? validateClassAttr(vnode, elm, data, renderer)
|
|
8141
8165
|
: true;
|
|
8142
|
-
|
|
8166
|
+
const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
|
|
8167
|
+
? validateStyleAttr(vnode, elm, data, renderer)
|
|
8168
|
+
: true;
|
|
8169
|
+
if (isFalse(hasMatchingAttrs && hasMatchingClass && hasMatchingStyleAttr)) {
|
|
8143
8170
|
return false;
|
|
8144
8171
|
}
|
|
8145
8172
|
}
|
|
@@ -8430,5 +8457,5 @@ function readonly(obj) {
|
|
|
8430
8457
|
}
|
|
8431
8458
|
|
|
8432
8459
|
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, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
8433
|
-
/** version: 8.
|
|
8460
|
+
/** version: 8.4.0 */
|
|
8434
8461
|
//# sourceMappingURL=index.js.map
|