merge method
Implementation
bool merge(CSSStyleDeclaration other) {
final List<String> properties = _effectivePropertyNamesSnapshot();
bool updateStatus = false;
// Apply updates + additions based on `other`.
for (final MapEntry<String, CSSPropertyValue> entry in other) {
final String propertyName = entry.key;
final CSSPropertyValue otherValue = entry.value;
final CSSPropertyValue? prevValue = _getEffectivePropertyValueEntry(propertyName);
// Mirror previous behavior: if the property does not exist on `this`,
// stage the incoming value directly (even when empty).
if (prevValue == null) {
_setStagedPropertyValue(propertyName, otherValue);
updateStatus = true;
continue;
}
if (isNullOrEmptyValue(prevValue) && isNullOrEmptyValue(otherValue)) {
continue;
} else if (!isNullOrEmptyValue(prevValue) && isNullOrEmptyValue(otherValue)) {
// Remove property.
removeProperty(propertyName, prevValue.important ? true : null);
updateStatus = true;
} else if (!_samePropertyValue(prevValue, otherValue)) {
_setStagedPropertyValue(propertyName, otherValue);
updateStatus = true;
}
}
// Remove properties missing in `other`.
for (final String propertyName in properties) {
final CSSPropertyValue? prevValue = _getEffectivePropertyValueEntry(propertyName);
if (isNullOrEmptyValue(prevValue)) continue;
if (other._getEffectivePropertyValueEntry(propertyName) != null) continue;
removeProperty(propertyName, prevValue?.important == true ? true : null);
updateStatus = true;
}
return updateStatus;
}