setAttribute method
Implementation
void setAttribute(String name, String value) {
//
// Loosely based on:
// https://dom.spec.whatwg.org/#dom-element-setattribute
//
_validateAttributeName('setAttribute', null, name);
if (!_isXml) {
name = name.toLowerCase();
if (name == 'style') {
_setAttribute('style', value);
return;
}
}
_Attribute? previous;
var attribute = _firstAttribute;
while (attribute != null) {
if (attribute._localName == name) {
attribute.value = value;
return;
}
previous = attribute;
attribute = attribute._next;
}
final newAttribute = _Attribute(false, '', name, name, value);
if (previous == null) {
_firstAttribute = newAttribute;
} else {
previous._next = newAttribute;
}
}