removeAttributeNS method

void removeAttributeNS(
  1. String? namespaceUri,
  2. String name
)

Implementation

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

  namespaceUri ??= '';

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

    if (name == 'style' && _isHtmlNamespaceUri(namespaceUri)) {
      _style = null;
      return;
    }
  }

  _Attribute? previous;
  var current = _firstAttribute;
  while (current != null) {
    final next = current._next;
    if (current._localName == name && current._namespaceUri == namespaceUri) {
      if (previous == null) {
        _firstAttribute = next;
      } else {
        previous._next = next;
      }
      return;
    }
    previous = current;
    current = next;
  }
}