8000 perf(core): avoid setting the same value to view properties (#10602) · NativeScript/NativeScript@499fe8d · GitHub
[go: up one dir, main page]

Skip to content

Commit 499fe8d

Browse files
authored
perf(core): avoid setting the same value to view properties (#10602)
1 parent 75c8e94 commit 499fe8d

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

packages/core/ui/styling/style-scope.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -721,25 +721,40 @@ export class CssState {
721721
cssExpsProperties[property] = value;
722722
continue;
723723
}
724-
delete oldProperties[property];
725-
if (property in oldProperties && oldProperties[property] === value) {
726-
// Skip unchanged values
727-
continue;
724+
725+
if (property in oldProperties) {
726+
const oldValue = oldProperties[property];
727+
728+
delete oldProperties[property];
729+
730+
if (oldValue === value) {
731+
// Skip unchanged values
732+
continue;
733+
}
728734
}
735+
729736
if (isCssVariable(property)) {
730737
view.style.setScopedCssVariable(property, value);
731738
delete newPropertyValues[property];
732739
continue;
733740
}
741+
734742
valuesToApply[property] = value;
735743
}
736-
//we need to parse CSS vars first before evaluating css expressions
744+
745+
// we need to parse CSS vars first before evaluating css expressions
737746
for (const property in cssExpsProperties) {
738-
delete oldProperties[property];
739747
const value = evaluateCssExpressions(view, property, cssExpsProperties[property]);
740-
if (property in oldProperties && oldProperties[property] === value) {
741-
// Skip unchanged values
742-
continue;
748+
749+
if (property in oldProperties) {
750+
const oldValue = oldProperties[property];
751+
752+
delete oldProperties[property];
753+
754+
if (oldValue === value) {
755+
// Skip unchanged values
756+
continue;
757+
}
743758
}
744759
if (value === unsetValue) {
745760
delete newPropertyValues[property];
@@ -761,9 +776,11 @@ export class CssState {
761776
view[camelCasedProperty] = unsetValue;
762777
}
763778
}
779+
764780
// Set new values to the style
765781
for (const property in valuesToApply) {
766782
const value = valuesToApply[property];
783+
767784
try {
768785
if (property in view.style) {
769786
view.style[`css:${property}`] = value;

0 commit comments

Comments
 (0)
0