merge method

NotusStyle merge(
  1. NotusAttribute attribute
)

Merges this attribute set with attribute and returns result as a new attribute set.

Performs compaction if attribute is an "unset" value, e.g. removes corresponding attribute from this set completely.

See also put method which does not perform compaction and allows constructing styles with "unset" values.

Implementation

NotusStyle merge(NotusAttribute attribute) {
  final merged = Map<String, NotusAttribute>.from(_data);
  if (attribute.isUnset) {
    merged.remove(attribute.key);
  } else {
    merged[attribute.key] = attribute;
  }
  return NotusStyle._(merged);
}