union method

void union(
  1. CSSStyleDeclaration declaration
)

Implementation

void union(CSSStyleDeclaration declaration) {
  Map<String, CSSPropertyValue> properties = {}
    ..addAll(_properties)
    ..addAll(_pendingProperties);

  for (String propertyName in declaration._pendingProperties.keys) {
    bool currentIsImportant = _importants[propertyName] ?? false;
    bool otherIsImportant = declaration._importants[propertyName] ?? false;
    CSSPropertyValue? currentValue = properties[propertyName];
    CSSPropertyValue? otherValue = declaration._pendingProperties[propertyName];
    if ((otherIsImportant || !currentIsImportant) && currentValue != otherValue) {
      // Add property.
      if (otherValue != null) {
        _pendingProperties[propertyName] = otherValue;
      } else {
        _pendingProperties.remove(propertyName);
      }
      if (otherIsImportant) {
        _importants[propertyName] = true;
      }
    }
  }
}