addAttributes method

EchoBuilder addAttributes(
  1. Map<String, String> attributes
)

Allows for adding or modifying the attributes of the current element. It takes a Map of key-value pairs as an argument, which are iterated over, and each attribute is either added or modified in the current element based on whether the key exists or not in the Map.

Implementation

EchoBuilder addAttributes(Map<String, String> attributes) {
  /// Iterates all attribute in the attributes [Map].
  for (final attribute in attributes.keys) {
    /// Checks if attributes contain key for verification.
    if (attributes.containsKey(attribute)) {
      if (attributes[attribute] == null) {
        /// If null, then remove attribute from node.
        _node!.removeAttribute(attribute);
      } else {
        _node!.setAttribute(attribute, attributes[attribute].toString());
      }
    }
  }
  return this;
}