removeAttribute method

  1. @mustCallSuper
void removeAttribute(
  1. String qualifiedName
)

Implementation

@mustCallSuper
void removeAttribute(String qualifiedName) {
  ElementAttributeProperty? propertyHandler =
      _attributeProperties[qualifiedName];

  if (propertyHandler != null && propertyHandler.deleter != null) {
    propertyHandler.deleter!();
  }

  if (hasAttribute(qualifiedName)) {
    attributes.remove(qualifiedName);
    final isNeedRecalculate = _checkRecalculateStyle([qualifiedName]);
    if (DebugFlags.enableCssBatchRecalc) {
      ownerDocument.markElementStyleDirty(this, reason: 'batch:remove:$qualifiedName');

    } else {
      recalculateStyle(rebuildNested: isNeedRecalculate);
    }

    // Maintain attribute presence index
    _updateAttrPresenceIndex(qualifiedName, present: false);

    // Emit CDP DOM.attributeRemoved for DevTools
    try {
      final cb = ownerDocument.controller.view.devtoolsAttributeRemoved;
      if (cb != null) {
        cb(this, qualifiedName);
      } else {
        // Fallback to full tree refresh when incremental hooks are not set
        ownerDocument.controller.view.debugDOMTreeChanged?.call();
      }
    } catch (_) {}

    // Mark semantics dirty for accessibility-relevant attributes.
    _markSemanticsDirtyIfNeeded(qualifiedName);
  }
}