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

Code before:
			view.style['keyframe:opacity'] = unsetValue;
		} else {
			Trace.write(`KeyframeAnimations cannot be stopped because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
		}

		this._playsKeyframeAnimations = false;
	}

	/**
	 * Calculate the difference between the previously applied property values,
	 * and the new set of property values that have to be applied for the provided selectors.
	 * Apply the values and ensure each property setter is called at most once to avoid excessive change notifications.
	 * @param matchingSelectors
	 */
	private setPropertyValues(matchingSelectors: SelectorCore[]): void {
		const view = this.viewRef.get();
		if (!view) {
			Trace.write(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);

			return;
		}

		const newPropertyValues = new view.style.PropertyBag();
		matchingSelectors.forEach((selector) => selector.ruleset.declarations.forEach((declaration) => (newPropertyValues[declaration.property] = declaration.value)));

		const oldProperties = this._appliedPropertyValues || {};
		// Update values for the scope's css-variables
		view.style.resetScopedCssVariables();


		const valuesToApply = {};
		for (const property in newPropertyValues) {
			let value = newPropertyValues[property];
			if (property in oldProperties && oldProperties[property] === value) {
				// Skip unchanged values
				delete oldProperties[property] 
				continue;
			}
			if (isCssVariable(property)) {
				view.style.setScopedCssVariable(property, value);
				delete oldProperties[property] 
				delete newPropertyValues[property];
				continue;
			}
			if (isCssVariableExpression(value) || isCssCalcExpression(value)) {
				value = evaluateCssExpressions(view, property, newPropertyValues[property]);
			}
			if (value === unsetValue) {
				delete newPropertyValues[property];
				continue;
			}

Review comment (suggestion):
This can be left the way it was, no need to add the `|| {}` as _appliedPropertyValues ALWAYS has a value.  It is defaulted to EmptyPropertyBag  on construction.

Code after:
		if (!this._playsKeyframeAnimations) {
			return;
		}

		this._appliedAnimations.filter((animation) => animation.isPlaying).forEach((animation) => animation.cancel());
		this._appliedAnimations = CssState.emptyAnimationArray;

		const view = this.viewRef.get();
		if (view) {
			view.style['keyframe:rotate'] = unsetValue;
			view.style['keyframe:rotateX'] = unsetValue;
			view.style['keyframe:rotateY'] = unsetValue;
			view.style['keyframe:scaleX'] = unsetValue;
			view.style['keyframe:scaleY'] = unsetValue;
			view.style['keyframe:translateX'] = unsetValue;
			view.style['keyframe:translateY'] = unsetValue;
			view.style['keyframe:backgroundColor'] = unsetValue;
			view.style['keyframe:opacity'] = unsetValue;
		} else {
			Trace.write(`KeyframeAnimations cannot be stopped because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
		}

		this._playsKeyframeAnimations = false;
	}

	/**
	 * Calculate the difference between the previously applied property values,
	 * and the new set of property values that have to be applied for the provided selectors.
	 * Apply the values and ensure each property setter is called at most once to avoid excessive change notifications.
	 * @param matchingSelectors
	 */
	private setPropertyValues(matchingSelectors: SelectorCore[]): void {
		const view = this.viewRef.get();
		if (!view) {
			Trace.write(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);

			return;
		}

		const newPropertyValues = new view.style.PropertyBag();
		matchingSelectors.forEach((selector) => selector.ruleset.declarations.forEach((declaration) => (newPropertyValues[declaration.property] = declaration.value)));

		const oldProperties = this._appliedPropertyValues;
		// Update values for the scope's css-variables
		view.style.resetScopedCssVariables();

		const valuesToApply = {};
		const cssExpsProperties = {};

		for (const property in newPropertyValues) {
			const value = newPropertyValues[property];