getAttribute method

String? getAttribute(
  1. String name
)

Implementation

String? getAttribute(String name) {
  //
  // Loosely based on:
  // https://dom.spec.whatwg.org/#dom-element-getattribute
  //

  if (!_isXml) {
    name = name.toLowerCase();

    if (name == 'style') {
      return _style?.toString();
    }
  }

  var attribute = _firstAttribute;
  while (attribute != null) {
    if (attribute._qualifiedName == name) {
      return attribute.value;
    }
    attribute = attribute._next;
  }

  // Didn't find attribute
  return null;
}