Skip to content

Commit

Permalink
perf(core): avoid setting the same value to view properties (NativeSc…
Browse files Browse the repository at this point in the history
  • Loading branch information
CatchABus authored Aug 8, 2024
1 parent 75c8e94 commit 499fe8d
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions packages/core/ui/styling/style-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,25 +721,40 @@ export class CssState {
cssExpsProperties[property] = value;
continue;
}
delete oldProperties[property];
if (property in oldProperties && oldProperties[property] === value) {
// Skip unchanged values
continue;

if (property in oldProperties) {
const oldValue = oldProperties[property];

delete oldProperties[property];

if (oldValue === value) {
// Skip unchanged values
continue;
}
}

if (isCssVariable(property)) {
view.style.setScopedCssVariable(property, value);
delete newPropertyValues[property];
continue;
}

valuesToApply[property] = value;
}
//we need to parse CSS vars first before evaluating css expressions

// we need to parse CSS vars first before evaluating css expressions
for (const property in cssExpsProperties) {
delete oldProperties[property];
const value = evaluateCssExpressions(view, property, cssExpsProperties[property]);
if (property in oldProperties && oldProperties[property] === value) {
// Skip unchanged values
continue;

if (property in oldProperties) {
const oldValue = oldProperties[property];

delete oldProperties[property];

if (oldValue === value) {
// Skip unchanged values
continue;
}
}
if (value === unsetValue) {
delete newPropertyValues[property];
Expand All @@ -761,9 +776,11 @@ export class CssState {
view[camelCasedProperty] = unsetValue;
}
}

// Set new values to the style
for (const property in valuesToApply) {
const value = valuesToApply[property];

try {
if (property in view.style) {
view.style[`css:${property}`] = value;
Expand Down

0 comments on commit 499fe8d

Please sign in to comment.