@lwc/engine-core 3.0.2 → 3.0.4
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/stylesheet.d.ts +2 -2
- package/dist/framework/template.d.ts +2 -0
- package/dist/framework/vm.d.ts +6 -0
- package/dist/index.cjs.js +76 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +76 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -12,14 +12,14 @@ export type StylesheetFactory = (stylesheetToken: string | undefined, useActualH
|
|
|
12
12
|
* @import CSS declaration).
|
|
13
13
|
*/
|
|
14
14
|
export type TemplateStylesheetFactories = Array<StylesheetFactory | TemplateStylesheetFactories>;
|
|
15
|
-
export declare function updateStylesheetToken(vm: VM, template: Template): void;
|
|
15
|
+
export declare function updateStylesheetToken(vm: VM, template: Template, legacy: boolean): void;
|
|
16
16
|
export declare function getStylesheetsContent(vm: VM, template: Template): string[];
|
|
17
17
|
/**
|
|
18
18
|
* If the component that is currently being rendered uses scoped styles,
|
|
19
19
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
20
20
|
* it returns null.
|
|
21
21
|
*/
|
|
22
|
-
export declare function getScopeTokenClass(owner: VM): string | null;
|
|
22
|
+
export declare function getScopeTokenClass(owner: VM, legacy: boolean): string | null;
|
|
23
23
|
/**
|
|
24
24
|
* This function returns the host style token for a custom element if it
|
|
25
25
|
* exists. Otherwise it returns null.
|
|
@@ -10,6 +10,8 @@ export interface Template {
|
|
|
10
10
|
stylesheets?: TemplateStylesheetFactories;
|
|
11
11
|
/** The string used for synthetic shadow style scoping and light DOM style scoping. */
|
|
12
12
|
stylesheetToken?: string;
|
|
13
|
+
/** Same as the above, but for legacy use cases (pre-LWC v3.0.0) */
|
|
14
|
+
legacyStylesheetToken?: string;
|
|
13
15
|
/** Render mode for the template. Could be light or undefined (which means it's shadow) */
|
|
14
16
|
renderMode?: 'light';
|
|
15
17
|
/** True if this template contains template refs, undefined or false otherwise */
|
package/dist/framework/vm.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ export interface Context {
|
|
|
42
42
|
hasTokenInClass: boolean | undefined;
|
|
43
43
|
/** True if a stylesheetToken was added to the host attributes */
|
|
44
44
|
hasTokenInAttribute: boolean | undefined;
|
|
45
|
+
/** The legacy string used for synthetic shadow DOM and light DOM style scoping. */
|
|
46
|
+
legacyStylesheetToken: string | undefined;
|
|
47
|
+
/** True if a legacyStylesheetToken was added to the host class */
|
|
48
|
+
hasLegacyTokenInClass: boolean | undefined;
|
|
49
|
+
/** True if a legacyStylesheetToken was added to the host attributes */
|
|
50
|
+
hasLegacyTokenInAttribute: boolean | undefined;
|
|
45
51
|
/** Whether or not light DOM scoped styles are present in the stylesheets. */
|
|
46
52
|
hasScopedStyles: boolean | undefined;
|
|
47
53
|
/** The VNodes injected in all the shadow trees to apply the associated component stylesheets. */
|
package/dist/index.cjs.js
CHANGED
|
@@ -3090,9 +3090,11 @@ function createInlineStyleVNode(content) {
|
|
|
3090
3090
|
},
|
|
3091
3091
|
}, [api.t(content)]);
|
|
3092
3092
|
}
|
|
3093
|
-
|
|
3093
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3094
|
+
function updateStylesheetToken(vm, template, legacy) {
|
|
3094
3095
|
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3095
|
-
const { stylesheets: newStylesheets
|
|
3096
|
+
const { stylesheets: newStylesheets } = template;
|
|
3097
|
+
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
|
3096
3098
|
const { stylesheets: newVmStylesheets } = vm;
|
|
3097
3099
|
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3098
3100
|
const { hasScopedStyles } = context;
|
|
@@ -3100,7 +3102,19 @@ function updateStylesheetToken(vm, template) {
|
|
|
3100
3102
|
let newHasTokenInClass;
|
|
3101
3103
|
let newHasTokenInAttribute;
|
|
3102
3104
|
// Reset the styling token applied to the host element.
|
|
3103
|
-
|
|
3105
|
+
let oldToken;
|
|
3106
|
+
let oldHasTokenInClass;
|
|
3107
|
+
let oldHasTokenInAttribute;
|
|
3108
|
+
if (legacy) {
|
|
3109
|
+
oldToken = context.legacyStylesheetToken;
|
|
3110
|
+
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
|
3111
|
+
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
|
3112
|
+
}
|
|
3113
|
+
else {
|
|
3114
|
+
oldToken = context.stylesheetToken;
|
|
3115
|
+
oldHasTokenInClass = context.hasTokenInClass;
|
|
3116
|
+
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
|
3117
|
+
}
|
|
3104
3118
|
if (!shared.isUndefined(oldToken)) {
|
|
3105
3119
|
if (oldHasTokenInClass) {
|
|
3106
3120
|
getClassList(elm).remove(makeHostToken(oldToken));
|
|
@@ -3128,9 +3142,16 @@ function updateStylesheetToken(vm, template) {
|
|
|
3128
3142
|
}
|
|
3129
3143
|
}
|
|
3130
3144
|
// Update the styling tokens present on the context object.
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3145
|
+
if (legacy) {
|
|
3146
|
+
context.legacyStylesheetToken = newToken;
|
|
3147
|
+
context.hasLegacyTokenInClass = newHasTokenInClass;
|
|
3148
|
+
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
|
3149
|
+
}
|
|
3150
|
+
else {
|
|
3151
|
+
context.stylesheetToken = newToken;
|
|
3152
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3153
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3154
|
+
}
|
|
3134
3155
|
}
|
|
3135
3156
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3136
3157
|
const content = [];
|
|
@@ -3217,9 +3238,12 @@ function getNearestShadowComponent(vm) {
|
|
|
3217
3238
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3218
3239
|
* it returns null.
|
|
3219
3240
|
*/
|
|
3220
|
-
|
|
3241
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3242
|
+
function getScopeTokenClass(owner, legacy) {
|
|
3221
3243
|
const { cmpTemplate, context } = owner;
|
|
3222
|
-
return (context.hasScopedStyles &&
|
|
3244
|
+
return ((context.hasScopedStyles &&
|
|
3245
|
+
(legacy ? cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.legacyStylesheetToken : cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) ||
|
|
3246
|
+
null);
|
|
3223
3247
|
}
|
|
3224
3248
|
/**
|
|
3225
3249
|
* This function returns the host style token for a custom element if it
|
|
@@ -3945,18 +3969,35 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
|
3945
3969
|
patchProps(oldVnode, vnode, renderer);
|
|
3946
3970
|
}
|
|
3947
3971
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3972
|
+
const { getClassList } = renderer;
|
|
3948
3973
|
// Set the class name for `*.scoped.css` style scoping.
|
|
3949
|
-
const scopeToken = getScopeTokenClass(owner);
|
|
3974
|
+
const scopeToken = getScopeTokenClass(owner, /* legacy */ false);
|
|
3950
3975
|
if (!shared.isNull(scopeToken)) {
|
|
3951
|
-
const { getClassList } = renderer;
|
|
3952
3976
|
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3953
3977
|
// probably we should have a renderer api for just the add operation
|
|
3954
3978
|
getClassList(elm).add(scopeToken);
|
|
3955
3979
|
}
|
|
3980
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3981
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
3982
|
+
const legacyScopeToken = getScopeTokenClass(owner, /* legacy */ true);
|
|
3983
|
+
if (!shared.isNull(legacyScopeToken)) {
|
|
3984
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3985
|
+
// probably we should have a renderer api for just the add operation
|
|
3986
|
+
getClassList(elm).add(legacyScopeToken);
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3956
3989
|
// Set property element for synthetic shadow DOM style scoping.
|
|
3957
3990
|
const { stylesheetToken: syntheticToken } = owner.context;
|
|
3958
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */
|
|
3959
|
-
|
|
3991
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3992
|
+
if (!shared.isUndefined(syntheticToken)) {
|
|
3993
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3994
|
+
}
|
|
3995
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
3996
|
+
const legacyToken = owner.context.legacyStylesheetToken;
|
|
3997
|
+
if (!shared.isUndefined(legacyToken)) {
|
|
3998
|
+
elm.$legacyShadowToken$ = legacyToken;
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
3960
4001
|
}
|
|
3961
4002
|
}
|
|
3962
4003
|
function applyDomManual(elm, vnode) {
|
|
@@ -4983,9 +5024,10 @@ function buildParseFragmentFn(createFragmentFn) {
|
|
|
4983
5024
|
return (strings, ...keys) => {
|
|
4984
5025
|
const cache = shared.create(null);
|
|
4985
5026
|
return function () {
|
|
4986
|
-
const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
5027
|
+
const { context: { hasScopedStyles, stylesheetToken, legacyStylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
4987
5028
|
const hasStyleToken = !shared.isUndefined(stylesheetToken);
|
|
4988
5029
|
const isSyntheticShadow = shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
5030
|
+
const hasLegacyToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS && !shared.isUndefined(legacyStylesheetToken);
|
|
4989
5031
|
let cacheKey = 0;
|
|
4990
5032
|
if (hasStyleToken && hasScopedStyles) {
|
|
4991
5033
|
cacheKey |= 1 /* FragmentCache.HAS_SCOPED_STYLE */;
|
|
@@ -4993,12 +5035,19 @@ function buildParseFragmentFn(createFragmentFn) {
|
|
|
4993
5035
|
if (hasStyleToken && isSyntheticShadow) {
|
|
4994
5036
|
cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
|
|
4995
5037
|
}
|
|
5038
|
+
if (hasLegacyToken) {
|
|
5039
|
+
// This isn't strictly required for prod, but it's required for our karma tests
|
|
5040
|
+
// since the lwcRuntimeFlag may change over time
|
|
5041
|
+
cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
|
|
5042
|
+
}
|
|
4996
5043
|
if (!shared.isUndefined(cache[cacheKey])) {
|
|
4997
5044
|
return cache[cacheKey];
|
|
4998
5045
|
}
|
|
4999
|
-
|
|
5000
|
-
const
|
|
5001
|
-
const
|
|
5046
|
+
// If legacy stylesheet tokens are required, then add them to the rendered string
|
|
5047
|
+
const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
|
|
5048
|
+
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
|
|
5049
|
+
const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetTokenToRender}"` : '';
|
|
5050
|
+
const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetTokenToRender : '';
|
|
5002
5051
|
let htmlFragment = '';
|
|
5003
5052
|
for (let i = 0, n = keys.length; i < n; i++) {
|
|
5004
5053
|
switch (keys[i]) {
|
|
@@ -5074,7 +5123,10 @@ function evaluateTemplate(vm, html) {
|
|
|
5074
5123
|
// Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
|
|
5075
5124
|
context.hasScopedStyles = computeHasScopedStyles(html, vm);
|
|
5076
5125
|
// Update the scoping token on the host element.
|
|
5077
|
-
updateStylesheetToken(vm, html);
|
|
5126
|
+
updateStylesheetToken(vm, html, /* legacy */ false);
|
|
5127
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
5128
|
+
updateStylesheetToken(vm, html, /* legacy */ true);
|
|
5129
|
+
}
|
|
5078
5130
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
5079
5131
|
// re-rendering.
|
|
5080
5132
|
const stylesheetsContent = getStylesheetsContent(vm, html);
|
|
@@ -5444,6 +5496,9 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5444
5496
|
stylesheetToken: undefined,
|
|
5445
5497
|
hasTokenInClass: undefined,
|
|
5446
5498
|
hasTokenInAttribute: undefined,
|
|
5499
|
+
legacyStylesheetToken: undefined,
|
|
5500
|
+
hasLegacyTokenInClass: undefined,
|
|
5501
|
+
hasLegacyTokenInAttribute: undefined,
|
|
5447
5502
|
hasScopedStyles: undefined,
|
|
5448
5503
|
styleVNodes: null,
|
|
5449
5504
|
tplCache: EmptyObject,
|
|
@@ -6477,7 +6532,8 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6477
6532
|
const { data, owner } = vnode;
|
|
6478
6533
|
let { className, classMap } = data;
|
|
6479
6534
|
const { getProperty, getClassList, getAttribute } = renderer;
|
|
6480
|
-
|
|
6535
|
+
// we don't care about legacy for hydration. it's a new use case
|
|
6536
|
+
const scopedToken = getScopeTokenClass(owner, /* legacy */ false);
|
|
6481
6537
|
const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
|
|
6482
6538
|
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
6483
6539
|
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
@@ -6792,7 +6848,7 @@ function trackMutations(tmpl) {
|
|
|
6792
6848
|
}
|
|
6793
6849
|
function addLegacyStylesheetTokensShim(tmpl) {
|
|
6794
6850
|
// When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
|
|
6795
|
-
// is accessing the old internal API (backwards compat). Details:
|
|
6851
|
+
// is accessing the old internal API (backwards compat). Details: W-14210169
|
|
6796
6852
|
shared.defineProperty(tmpl, 'stylesheetTokens', {
|
|
6797
6853
|
enumerable: true,
|
|
6798
6854
|
configurable: true,
|
|
@@ -6925,5 +6981,5 @@ exports.swapTemplate = swapTemplate;
|
|
|
6925
6981
|
exports.track = track;
|
|
6926
6982
|
exports.unwrap = unwrap;
|
|
6927
6983
|
exports.wire = wire;
|
|
6928
|
-
/** version: 3.0.
|
|
6984
|
+
/** version: 3.0.4 */
|
|
6929
6985
|
//# sourceMappingURL=index.cjs.js.map
|