appendToAttribute method

DOMElement appendToAttribute(
  1. String name,
  2. Object? value
)

Appends value to attribute of name. Useful for attributes like class and style.

Implementation

DOMElement appendToAttribute(String name, Object? value) {
  // ignore: prefer_collection_literals
  _attributes ??= LinkedHashMap();

  var attr = getAttribute(name);

  if (attr == null) {
    return setAttribute(name, value);
  }

  if (attr.isCollection) {
    attr.appendValue(value);
  } else {
    attr.setValue(value);
  }

  return this;
}