getAttributeNS method

String? getAttributeNS(
  1. String? namespaceUri,
  2. String name
)

Implementation

String? getAttributeNS(String? namespaceUri, String name) {
  //
  // Loosely based on:
  // https://dom.spec.whatwg.org/#dom-element-getattributens
  //

  namespaceUri ??= '';

  // Should we ignore the case?
  // XML is case sensitive, but HTML is not.
  if (!_isXml) {
    name = name.toLowerCase();

    // Is the attribute 'style'?
    if (name == 'style' && _isHtmlNamespaceUri(namespaceUri)) {
      return _style?.toString();
    }
  }

  var attribute = _firstAttribute;
  while (attribute != null) {
    if (attribute._localName == name &&
        attribute._namespaceUri == namespaceUri) {
      return attribute.value;
    }
    attribute = attribute._next;
  }

  // Didn't find attribute
  return null;
}