@lwc/engine-core 8.10.1 → 8.12.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/framework/api.d.ts +2 -11
- package/dist/index.cjs.js +36 -63
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +37 -64
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/framework/api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeClass } from '@lwc/shared';
|
|
1
2
|
import type { SanitizedHtmlContent } from './sanitized-html-content';
|
|
2
3
|
import type { Key, VComment, VCustomElement, VElement, VElementData, VFragment, VNode, VNodes, VScopedSlotFragment, VStatic, VStaticPart, VStaticPartData, VText } from './vnodes';
|
|
3
4
|
import type { LightningElementConstructor } from './base-lightning-element';
|
|
@@ -41,16 +42,6 @@ declare function ddc(sel: string, Ctor: LightningElementConstructor | null | und
|
|
|
41
42
|
*/
|
|
42
43
|
declare function dc(Ctor: LightningElementConstructor | null | undefined, data: VElementData, children?: VNodes): VCustomElement | null;
|
|
43
44
|
declare function shc(content: unknown): SanitizedHtmlContent;
|
|
44
|
-
/**
|
|
45
|
-
* [ncls] - Normalize class name attribute.
|
|
46
|
-
*
|
|
47
|
-
* Transforms the provided class property value from an object/string into a string the diffing algo
|
|
48
|
-
* can operate on.
|
|
49
|
-
*
|
|
50
|
-
* This implementation is borrowed from Vue:
|
|
51
|
-
* https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
|
|
52
|
-
*/
|
|
53
|
-
declare function ncls(value: unknown): string | undefined;
|
|
54
45
|
declare const api: Readonly<{
|
|
55
46
|
s: typeof s;
|
|
56
47
|
h: typeof h;
|
|
@@ -72,7 +63,7 @@ declare const api: Readonly<{
|
|
|
72
63
|
ssf: typeof ssf;
|
|
73
64
|
ddc: typeof ddc;
|
|
74
65
|
sp: typeof sp;
|
|
75
|
-
ncls: typeof
|
|
66
|
+
ncls: typeof normalizeClass;
|
|
76
67
|
}>;
|
|
77
68
|
export default api;
|
|
78
69
|
export type RenderAPI = typeof api;
|
package/dist/index.cjs.js
CHANGED
|
@@ -3984,6 +3984,7 @@ function getComponentHtmlPrototype(Ctor) {
|
|
|
3984
3984
|
return def.bridge;
|
|
3985
3985
|
}
|
|
3986
3986
|
const lightingElementDef = {
|
|
3987
|
+
ctor: LightningElement,
|
|
3987
3988
|
name: LightningElement.name,
|
|
3988
3989
|
props: lightningBasedDescriptors,
|
|
3989
3990
|
propsConfig: EmptyObject,
|
|
@@ -5931,45 +5932,7 @@ function shc(content) {
|
|
|
5931
5932
|
const sanitizedString = shared.sanitizeHtmlContent(content);
|
|
5932
5933
|
return createSanitizedHtmlContent(sanitizedString);
|
|
5933
5934
|
}
|
|
5934
|
-
|
|
5935
|
-
* [ncls] - Normalize class name attribute.
|
|
5936
|
-
*
|
|
5937
|
-
* Transforms the provided class property value from an object/string into a string the diffing algo
|
|
5938
|
-
* can operate on.
|
|
5939
|
-
*
|
|
5940
|
-
* This implementation is borrowed from Vue:
|
|
5941
|
-
* https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
|
|
5942
|
-
*/
|
|
5943
|
-
function ncls(value) {
|
|
5944
|
-
if (shared.isUndefined(value) || shared.isNull(value)) {
|
|
5945
|
-
// Returning undefined here improves initial render cost, because the old vnode's class will be considered
|
|
5946
|
-
// undefined in the `patchClassAttribute` routine, so `oldClass === newClass` will be true so we return early
|
|
5947
|
-
return undefined;
|
|
5948
|
-
}
|
|
5949
|
-
let res = '';
|
|
5950
|
-
if (shared.isString(value)) {
|
|
5951
|
-
res = value;
|
|
5952
|
-
}
|
|
5953
|
-
else if (shared.isArray(value)) {
|
|
5954
|
-
for (let i = 0; i < value.length; i++) {
|
|
5955
|
-
const normalized = ncls(value[i]);
|
|
5956
|
-
if (normalized) {
|
|
5957
|
-
res += normalized + ' ';
|
|
5958
|
-
}
|
|
5959
|
-
}
|
|
5960
|
-
}
|
|
5961
|
-
else if (shared.isObject(value) && !shared.isNull(value)) {
|
|
5962
|
-
// Iterate own enumerable keys of the object
|
|
5963
|
-
const keys = shared.keys(value);
|
|
5964
|
-
for (let i = 0; i < keys.length; i += 1) {
|
|
5965
|
-
const key = keys[i];
|
|
5966
|
-
if (value[key]) {
|
|
5967
|
-
res += key + ' ';
|
|
5968
|
-
}
|
|
5969
|
-
}
|
|
5970
|
-
}
|
|
5971
|
-
return shared.StringTrim.call(res);
|
|
5972
|
-
}
|
|
5935
|
+
const ncls = shared.normalizeClass;
|
|
5973
5936
|
const api = shared.freeze({
|
|
5974
5937
|
s,
|
|
5975
5938
|
h,
|
|
@@ -7722,6 +7685,8 @@ if (process.env.IS_BROWSER && isGlobalAriaPolyfillLoaded()) {
|
|
|
7722
7685
|
* SPDX-License-Identifier: MIT
|
|
7723
7686
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7724
7687
|
*/
|
|
7688
|
+
// Used as a perf optimization to avoid creating and discarding sets unnecessarily.
|
|
7689
|
+
const EMPTY_SET = new Set();
|
|
7725
7690
|
// flag indicating if the hydration recovered from the DOM mismatch
|
|
7726
7691
|
let hasMismatch = false;
|
|
7727
7692
|
function hydrateRoot(vm) {
|
|
@@ -8097,6 +8062,22 @@ function validateAttrs(vnode, elm, data, renderer, shouldValidateAttr) {
|
|
|
8097
8062
|
}
|
|
8098
8063
|
return nodesAreCompatible;
|
|
8099
8064
|
}
|
|
8065
|
+
function checkClassesCompatibility(first, second) {
|
|
8066
|
+
if (first.size !== second.size) {
|
|
8067
|
+
return false;
|
|
8068
|
+
}
|
|
8069
|
+
for (const f of first) {
|
|
8070
|
+
if (!second.has(f)) {
|
|
8071
|
+
return false;
|
|
8072
|
+
}
|
|
8073
|
+
}
|
|
8074
|
+
for (const s of second) {
|
|
8075
|
+
if (!first.has(s)) {
|
|
8076
|
+
return false;
|
|
8077
|
+
}
|
|
8078
|
+
}
|
|
8079
|
+
return true;
|
|
8080
|
+
}
|
|
8100
8081
|
function validateClassAttr(vnode, elm, data, renderer) {
|
|
8101
8082
|
const { owner } = vnode;
|
|
8102
8083
|
// classMap is never available on VStaticPartData so it can default to undefined
|
|
@@ -8106,17 +8087,19 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8106
8087
|
// ---------- Step 1: get the classes from the element and the vnode
|
|
8107
8088
|
// Use a Set because we don't care to validate mismatches for 1) different ordering in SSR vs CSR, or 2)
|
|
8108
8089
|
// duplicated class names. These don't have an effect on rendered styles.
|
|
8109
|
-
const elmClasses = new Set(shared.ArrayFrom(elm.classList));
|
|
8090
|
+
const elmClasses = elm.classList.length ? new Set(shared.ArrayFrom(elm.classList)) : EMPTY_SET;
|
|
8110
8091
|
let vnodeClasses;
|
|
8111
8092
|
if (!shared.isUndefined(className)) {
|
|
8112
8093
|
// ignore empty spaces entirely, filter them out using `filter(..., Boolean)`
|
|
8113
|
-
|
|
8094
|
+
const classes = shared.ArrayFilter.call(shared.StringSplit.call(className, /\s+/), Boolean);
|
|
8095
|
+
vnodeClasses = classes.length ? new Set(classes) : EMPTY_SET;
|
|
8114
8096
|
}
|
|
8115
8097
|
else if (!shared.isUndefined(classMap)) {
|
|
8116
|
-
|
|
8098
|
+
const classes = shared.keys(classMap);
|
|
8099
|
+
vnodeClasses = classes.length ? new Set(classes) : EMPTY_SET;
|
|
8117
8100
|
}
|
|
8118
8101
|
else {
|
|
8119
|
-
vnodeClasses =
|
|
8102
|
+
vnodeClasses = EMPTY_SET;
|
|
8120
8103
|
}
|
|
8121
8104
|
// ---------- Step 2: handle the scope tokens
|
|
8122
8105
|
// we don't care about legacy for hydration. it's a new use case
|
|
@@ -8128,7 +8111,12 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8128
8111
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
8129
8112
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
8130
8113
|
if (!shared.isNull(scopeToken)) {
|
|
8131
|
-
vnodeClasses
|
|
8114
|
+
if (vnodeClasses === EMPTY_SET) {
|
|
8115
|
+
vnodeClasses = new Set([scopeToken]);
|
|
8116
|
+
}
|
|
8117
|
+
else {
|
|
8118
|
+
vnodeClasses.add(scopeToken);
|
|
8119
|
+
}
|
|
8132
8120
|
}
|
|
8133
8121
|
// This tells us which `*-host` scope token was rendered to the element's class.
|
|
8134
8122
|
// For now we just ignore any mismatches involving this class.
|
|
@@ -8139,27 +8127,12 @@ function validateClassAttr(vnode, elm, data, renderer) {
|
|
|
8139
8127
|
vnodeClasses.delete(elmHostScopeToken);
|
|
8140
8128
|
}
|
|
8141
8129
|
// ---------- Step 3: check for compatibility
|
|
8142
|
-
|
|
8143
|
-
if (
|
|
8144
|
-
nodesAreCompatible = false;
|
|
8145
|
-
}
|
|
8146
|
-
else {
|
|
8147
|
-
for (const vnodeClass of vnodeClasses) {
|
|
8148
|
-
if (!elmClasses.has(vnodeClass)) {
|
|
8149
|
-
nodesAreCompatible = false;
|
|
8150
|
-
}
|
|
8151
|
-
}
|
|
8152
|
-
for (const elmClass of elmClasses) {
|
|
8153
|
-
if (!vnodeClasses.has(elmClass)) {
|
|
8154
|
-
nodesAreCompatible = false;
|
|
8155
|
-
}
|
|
8156
|
-
}
|
|
8157
|
-
}
|
|
8158
|
-
if (process.env.NODE_ENV !== 'production' && !nodesAreCompatible) {
|
|
8130
|
+
const classesAreCompatible = checkClassesCompatibility(vnodeClasses, elmClasses);
|
|
8131
|
+
if (process.env.NODE_ENV !== 'production' && !classesAreCompatible) {
|
|
8159
8132
|
const prettyPrint = (set) => JSON.stringify(shared.ArrayJoin.call(shared.ArraySort.call(shared.ArrayFrom(set)), ' '));
|
|
8160
8133
|
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${prettyPrint(vnodeClasses)} but found ${prettyPrint(elmClasses)}`, vnode.owner);
|
|
8161
8134
|
}
|
|
8162
|
-
return
|
|
8135
|
+
return classesAreCompatible;
|
|
8163
8136
|
}
|
|
8164
8137
|
function validateStyleAttr(vnode, elm, data, renderer) {
|
|
8165
8138
|
// Note styleDecls is always undefined for VStaticPartData, casting here to default it to undefined
|
|
@@ -8598,5 +8571,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
8598
8571
|
exports.track = track;
|
|
8599
8572
|
exports.unwrap = unwrap;
|
|
8600
8573
|
exports.wire = wire;
|
|
8601
|
-
/** version: 8.
|
|
8574
|
+
/** version: 8.12.0 */
|
|
8602
8575
|
//# sourceMappingURL=index.cjs.js.map
|