fix(core): unset css values of type Property (#10199)

This commit is contained in:
Dimitris-Rafail Katsampas
2023-02-05 19:16:01 +02:00
committed by GitHub
parent b993a83f23
commit dcf6a365cd

View File

@ -79,6 +79,7 @@ let currentScopeTag: string = null;
const applicationAdditionalSelectors: RuleSet[] = []; const applicationAdditionalSelectors: RuleSet[] = [];
const applicationKeyframes: any = {}; const applicationKeyframes: any = {};
const animationsSymbol = Symbol('animations'); const animationsSymbol = Symbol('animations');
const kebabCasePattern = /-([a-z])/g;
const pattern = /('|")(.*?)\1/; const pattern = /('|")(.*?)\1/;
class CSSSource { class CSSSource {
@ -575,6 +576,7 @@ export class CssState {
const valuesToApply = {}; const valuesToApply = {};
const cssExpsProperties = {}; const cssExpsProperties = {};
const replacementFunc = (g) => g[1].toUpperCase();
for (const property in newPropertyValues) { for (const property in newPropertyValues) {
const value = newPropertyValues[property]; const value = newPropertyValues[property];
@ -621,7 +623,8 @@ export class CssState {
if (property in view.style) { if (property in view.style) {
view.style[`css:${property}`] = unsetValue; view.style[`css:${property}`] = unsetValue;
} else { } else {
// TRICKY: How do we unset local value? const camelCasedProperty = property.replace(kebabCasePattern, replacementFunc);
view[camelCasedProperty] = unsetValue;
} }
} }
// Set new values to the style // Set new values to the style
@ -631,9 +634,7 @@ export class CssState {
if (property in view.style) { if (property in view.style) {
view.style[`css:${property}`] = value; view.style[`css:${property}`] = value;
} else { } else {
const camelCasedProperty = property.replace(/-([a-z])/g, function (g) { const camelCasedProperty = property.replace(kebabCasePattern, replacementFunc);
return g[1].toUpperCase();
});
view[camelCasedProperty] = value; view[camelCasedProperty] = value;
} }
} catch (e) { } catch (e) {