Repository: NativeScript/NativeScript
File: packages/core/ui/styling/style-scope.ts (TypeScript)

Code before:
		// Unset removed values
		for (const property in oldProperties) {
			if (property in view.style) {
				view.style[`css:${property}`] = unsetValue;
			}
			else {
				// TRICKY: How do we unset local value?
			}
		}
		// 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;
				} else {
					const camelCasedProperty = property.replace(/-([a-z])/g, function (g) {
						return g[1].toUpperCase();
					});
					view[camelCasedProperty] = value;
				}
			} catch (e) {
				Trace.write(`Failed to apply property [${property}] with value [${value}] to ${view}. ${e.stack}`, Trace.categories.Error, Trace.messageType.error);
			}
		}

		this._appliedPropertyValues = newPropertyValues;
	}

	private subscribeForDynamicUpdates(): void {
		const changeMap = this._match.changeMap;
		changeMap.forEach((changes, view) => {
			if (changes.attributes) {
				changes.attributes.forEach((attribute) => {
					view.addEventListener(attribute + 'Change', this._onDynamicStateChangeHandler);
				});
			}
			if (changes.pseudoClasses) {
				changes.pseudoClasses.forEach((pseudoClass) => {
					const eventName = ':' + pseudoClass;
					view.addEventListener(':' + pseudoClass, this._onDynamicStateChangeHandler);
					if (view[eventName]) {
						view[eventName](+1);
					}
				});
			}
		});
		this._appliedChangeMap = changeMap;
	}

	private unsubscribeFromDynamicUpdates(): void {

Review comment (suggestion):
If I read your code correctly You do realize that without this check, you can end up doing double the work on all css properties.   Example: Say the property is `background` then Line 587 will be triggered, then later 598 causing the new background to be applied twice; if the background property is long running you created extra runtime overhead for the same set value.   The purpose of this check is to eliminate double setting of the value since it will be set below at line 598.

Code after:
				// we handle css exp separately because css vars must be evaluated first
				cssExpsProperties[property] = value;
				continue;
			}
			delete oldProperties[property];
			if (property in oldProperties && oldProperties[property] === 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
		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 (value === unsetValue) {
				delete newPropertyValues[property];
			}
			if (isCssVariable(property)) {
				view.style.setScopedCssVariable(property, value);
				delete newPropertyValues[property];
			}

			valuesToApply[property] = value;
		}

		// Unset removed values
		for (const property in oldProperties) {
			if (property in view.style) {
				view.style[`css:${property}`] = unsetValue;
			} else {
				// TRICKY: How do we unset local value?
			}
		}
		// 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;
				} else {
					const camelCasedProperty = property.replace(/-([a-z])/g, function (g) {