mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
perf(core): avoid setting the same value to view properties (#10602)
This commit is contained in:
committed by
GitHub
parent
75c8e941a0
commit
499fe8dc82
@ -721,26 +721,41 @@ export class CssState {
|
|||||||
cssExpsProperties[property] = value;
|
cssExpsProperties[property] = value;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property in oldProperties) {
|
||||||
|
const oldValue = oldProperties[property];
|
||||||
|
|
||||||
delete oldProperties[property];
|
delete oldProperties[property];
|
||||||
if (property in oldProperties && oldProperties[property] === value) {
|
|
||||||
|
if (oldValue === value) {
|
||||||
// Skip unchanged values
|
// Skip unchanged values
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isCssVariable(property)) {
|
if (isCssVariable(property)) {
|
||||||
view.style.setScopedCssVariable(property, value);
|
view.style.setScopedCssVariable(property, value);
|
||||||
delete newPropertyValues[property];
|
delete newPropertyValues[property];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
valuesToApply[property] = value;
|
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) {
|
for (const property in cssExpsProperties) {
|
||||||
delete oldProperties[property];
|
|
||||||
const value = evaluateCssExpressions(view, property, cssExpsProperties[property]);
|
const value = evaluateCssExpressions(view, property, cssExpsProperties[property]);
|
||||||
if (property in oldProperties && oldProperties[property] === value) {
|
|
||||||
|
if (property in oldProperties) {
|
||||||
|
const oldValue = oldProperties[property];
|
||||||
|
|
||||||
|
delete oldProperties[property];
|
||||||
|
|
||||||
|
if (oldValue === value) {
|
||||||
// Skip unchanged values
|
// Skip unchanged values
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (value === unsetValue) {
|
if (value === unsetValue) {
|
||||||
delete newPropertyValues[property];
|
delete newPropertyValues[property];
|
||||||
}
|
}
|
||||||
@ -761,9 +776,11 @@ export class CssState {
|
|||||||
view[camelCasedProperty] = unsetValue;
|
view[camelCasedProperty] = unsetValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new values to the style
|
// Set new values to the style
|
||||||
for (const property in valuesToApply) {
|
for (const property in valuesToApply) {
|
||||||
const value = valuesToApply[property];
|
const value = valuesToApply[property];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (property in view.style) {
|
if (property in view.style) {
|
||||||
view.style[`css:${property}`] = value;
|
view.style[`css:${property}`] = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user