setAttribute method

  1. @override
void setAttribute(
  1. Node element,
  2. String attrName,
  3. String? attrVal
)
override

Implementation

@override
void setAttribute(Node element, String attrName, String? attrVal) {
  if (element is Element) {
    switch (attrName) {
      case 'selected':
        {
          if (element is OptionElement) {
            element.selected = _parseAttributeBoolValue(attrVal);
          } else {
            element.setAttribute(attrName, attrVal!);
          }
          break;
        }
      case 'multiple':
        {
          if (element is SelectElement) {
            element.multiple = _parseAttributeBoolValue(attrVal);
          } else if (element is InputElement) {
            element.multiple = _parseAttributeBoolValue(attrVal);
          } else {
            element.setAttribute(attrName, attrVal!);
          }
          break;
        }
      case 'hidden':
        {
          element.hidden = _parseAttributeBoolValue(attrVal);
          break;
        }
      case 'inert':
        {
          element.inert = _parseAttributeBoolValue(attrVal);
          break;
        }
      default:
        {
          if (attrVal == null) {
            element.removeAttribute(attrName);
          } else {
            element.setAttribute(attrName, attrVal);
          }
          break;
        }
    }
  }
}