@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
package/dist/index.js
CHANGED
|
@@ -3086,9 +3086,11 @@ function createInlineStyleVNode(content) {
|
|
|
3086
3086
|
},
|
|
3087
3087
|
}, [api.t(content)]);
|
|
3088
3088
|
}
|
|
3089
|
-
|
|
3089
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3090
|
+
function updateStylesheetToken(vm, template, legacy) {
|
|
3090
3091
|
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3091
|
-
const { stylesheets: newStylesheets
|
|
3092
|
+
const { stylesheets: newStylesheets } = template;
|
|
3093
|
+
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
|
3092
3094
|
const { stylesheets: newVmStylesheets } = vm;
|
|
3093
3095
|
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3094
3096
|
const { hasScopedStyles } = context;
|
|
@@ -3096,7 +3098,19 @@ function updateStylesheetToken(vm, template) {
|
|
|
3096
3098
|
let newHasTokenInClass;
|
|
3097
3099
|
let newHasTokenInAttribute;
|
|
3098
3100
|
// Reset the styling token applied to the host element.
|
|
3099
|
-
|
|
3101
|
+
let oldToken;
|
|
3102
|
+
let oldHasTokenInClass;
|
|
3103
|
+
let oldHasTokenInAttribute;
|
|
3104
|
+
if (legacy) {
|
|
3105
|
+
oldToken = context.legacyStylesheetToken;
|
|
3106
|
+
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
|
3107
|
+
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
|
3108
|
+
}
|
|
3109
|
+
else {
|
|
3110
|
+
oldToken = context.stylesheetToken;
|
|
3111
|
+
oldHasTokenInClass = context.hasTokenInClass;
|
|
3112
|
+
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
|
3113
|
+
}
|
|
3100
3114
|
if (!isUndefined$1(oldToken)) {
|
|
3101
3115
|
if (oldHasTokenInClass) {
|
|
3102
3116
|
getClassList(elm).remove(makeHostToken(oldToken));
|
|
@@ -3124,9 +3138,16 @@ function updateStylesheetToken(vm, template) {
|
|
|
3124
3138
|
}
|
|
3125
3139
|
}
|
|
3126
3140
|
// Update the styling tokens present on the context object.
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3141
|
+
if (legacy) {
|
|
3142
|
+
context.legacyStylesheetToken = newToken;
|
|
3143
|
+
context.hasLegacyTokenInClass = newHasTokenInClass;
|
|
3144
|
+
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
|
3145
|
+
}
|
|
3146
|
+
else {
|
|
3147
|
+
context.stylesheetToken = newToken;
|
|
3148
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3149
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3150
|
+
}
|
|
3130
3151
|
}
|
|
3131
3152
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3132
3153
|
const content = [];
|
|
@@ -3213,9 +3234,12 @@ function getNearestShadowComponent(vm) {
|
|
|
3213
3234
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3214
3235
|
* it returns null.
|
|
3215
3236
|
*/
|
|
3216
|
-
|
|
3237
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3238
|
+
function getScopeTokenClass(owner, legacy) {
|
|
3217
3239
|
const { cmpTemplate, context } = owner;
|
|
3218
|
-
return (context.hasScopedStyles &&
|
|
3240
|
+
return ((context.hasScopedStyles &&
|
|
3241
|
+
(legacy ? cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.legacyStylesheetToken : cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) ||
|
|
3242
|
+
null);
|
|
3219
3243
|
}
|
|
3220
3244
|
/**
|
|
3221
3245
|
* This function returns the host style token for a custom element if it
|
|
@@ -3941,18 +3965,35 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
|
3941
3965
|
patchProps(oldVnode, vnode, renderer);
|
|
3942
3966
|
}
|
|
3943
3967
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3968
|
+
const { getClassList } = renderer;
|
|
3944
3969
|
// Set the class name for `*.scoped.css` style scoping.
|
|
3945
|
-
const scopeToken = getScopeTokenClass(owner);
|
|
3970
|
+
const scopeToken = getScopeTokenClass(owner, /* legacy */ false);
|
|
3946
3971
|
if (!isNull(scopeToken)) {
|
|
3947
|
-
const { getClassList } = renderer;
|
|
3948
3972
|
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3949
3973
|
// probably we should have a renderer api for just the add operation
|
|
3950
3974
|
getClassList(elm).add(scopeToken);
|
|
3951
3975
|
}
|
|
3976
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
|
3977
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
3978
|
+
const legacyScopeToken = getScopeTokenClass(owner, /* legacy */ true);
|
|
3979
|
+
if (!isNull(legacyScopeToken)) {
|
|
3980
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3981
|
+
// probably we should have a renderer api for just the add operation
|
|
3982
|
+
getClassList(elm).add(legacyScopeToken);
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3952
3985
|
// Set property element for synthetic shadow DOM style scoping.
|
|
3953
3986
|
const { stylesheetToken: syntheticToken } = owner.context;
|
|
3954
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */
|
|
3955
|
-
|
|
3987
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3988
|
+
if (!isUndefined$1(syntheticToken)) {
|
|
3989
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3990
|
+
}
|
|
3991
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
3992
|
+
const legacyToken = owner.context.legacyStylesheetToken;
|
|
3993
|
+
if (!isUndefined$1(legacyToken)) {
|
|
3994
|
+
elm.$legacyShadowToken$ = legacyToken;
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3956
3997
|
}
|
|
3957
3998
|
}
|
|
3958
3999
|
function applyDomManual(elm, vnode) {
|
|
@@ -4979,9 +5020,10 @@ function buildParseFragmentFn(createFragmentFn) {
|
|
|
4979
5020
|
return (strings, ...keys) => {
|
|
4980
5021
|
const cache = create(null);
|
|
4981
5022
|
return function () {
|
|
4982
|
-
const { context: { hasScopedStyles, stylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
5023
|
+
const { context: { hasScopedStyles, stylesheetToken, legacyStylesheetToken }, shadowMode, renderer, } = getVMBeingRendered();
|
|
4983
5024
|
const hasStyleToken = !isUndefined$1(stylesheetToken);
|
|
4984
5025
|
const isSyntheticShadow = shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
5026
|
+
const hasLegacyToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS && !isUndefined$1(legacyStylesheetToken);
|
|
4985
5027
|
let cacheKey = 0;
|
|
4986
5028
|
if (hasStyleToken && hasScopedStyles) {
|
|
4987
5029
|
cacheKey |= 1 /* FragmentCache.HAS_SCOPED_STYLE */;
|
|
@@ -4989,12 +5031,19 @@ function buildParseFragmentFn(createFragmentFn) {
|
|
|
4989
5031
|
if (hasStyleToken && isSyntheticShadow) {
|
|
4990
5032
|
cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
|
|
4991
5033
|
}
|
|
5034
|
+
if (hasLegacyToken) {
|
|
5035
|
+
// This isn't strictly required for prod, but it's required for our karma tests
|
|
5036
|
+
// since the lwcRuntimeFlag may change over time
|
|
5037
|
+
cacheKey |= 4 /* FragmentCache.HAS_LEGACY_SCOPE_TOKEN */;
|
|
5038
|
+
}
|
|
4992
5039
|
if (!isUndefined$1(cache[cacheKey])) {
|
|
4993
5040
|
return cache[cacheKey];
|
|
4994
5041
|
}
|
|
4995
|
-
|
|
4996
|
-
const
|
|
4997
|
-
const
|
|
5042
|
+
// If legacy stylesheet tokens are required, then add them to the rendered string
|
|
5043
|
+
const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
|
|
5044
|
+
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
|
|
5045
|
+
const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetTokenToRender}"` : '';
|
|
5046
|
+
const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetTokenToRender : '';
|
|
4998
5047
|
let htmlFragment = '';
|
|
4999
5048
|
for (let i = 0, n = keys.length; i < n; i++) {
|
|
5000
5049
|
switch (keys[i]) {
|
|
@@ -5070,7 +5119,10 @@ function evaluateTemplate(vm, html) {
|
|
|
5070
5119
|
// Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
|
|
5071
5120
|
context.hasScopedStyles = computeHasScopedStyles(html, vm);
|
|
5072
5121
|
// Update the scoping token on the host element.
|
|
5073
|
-
updateStylesheetToken(vm, html);
|
|
5122
|
+
updateStylesheetToken(vm, html, /* legacy */ false);
|
|
5123
|
+
if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
|
|
5124
|
+
updateStylesheetToken(vm, html, /* legacy */ true);
|
|
5125
|
+
}
|
|
5074
5126
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
5075
5127
|
// re-rendering.
|
|
5076
5128
|
const stylesheetsContent = getStylesheetsContent(vm, html);
|
|
@@ -5440,6 +5492,9 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5440
5492
|
stylesheetToken: undefined,
|
|
5441
5493
|
hasTokenInClass: undefined,
|
|
5442
5494
|
hasTokenInAttribute: undefined,
|
|
5495
|
+
legacyStylesheetToken: undefined,
|
|
5496
|
+
hasLegacyTokenInClass: undefined,
|
|
5497
|
+
hasLegacyTokenInAttribute: undefined,
|
|
5443
5498
|
hasScopedStyles: undefined,
|
|
5444
5499
|
styleVNodes: null,
|
|
5445
5500
|
tplCache: EmptyObject,
|
|
@@ -6473,7 +6528,8 @@ function validateClassAttr(vnode, elm, renderer) {
|
|
|
6473
6528
|
const { data, owner } = vnode;
|
|
6474
6529
|
let { className, classMap } = data;
|
|
6475
6530
|
const { getProperty, getClassList, getAttribute } = renderer;
|
|
6476
|
-
|
|
6531
|
+
// we don't care about legacy for hydration. it's a new use case
|
|
6532
|
+
const scopedToken = getScopeTokenClass(owner, /* legacy */ false);
|
|
6477
6533
|
const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
|
|
6478
6534
|
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
6479
6535
|
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
@@ -6788,7 +6844,7 @@ function trackMutations(tmpl) {
|
|
|
6788
6844
|
}
|
|
6789
6845
|
function addLegacyStylesheetTokensShim(tmpl) {
|
|
6790
6846
|
// When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
|
|
6791
|
-
// is accessing the old internal API (backwards compat). Details:
|
|
6847
|
+
// is accessing the old internal API (backwards compat). Details: W-14210169
|
|
6792
6848
|
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6793
6849
|
enumerable: true,
|
|
6794
6850
|
configurable: true,
|
|
@@ -6883,5 +6939,5 @@ function readonly(obj) {
|
|
|
6883
6939
|
}
|
|
6884
6940
|
|
|
6885
6941
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6886
|
-
/** version: 3.0.
|
|
6942
|
+
/** version: 3.0.4 */
|
|
6887
6943
|
//# sourceMappingURL=index.js.map
|