handleFocusChange method

void handleFocusChange()

Implementation

void handleFocusChange() {
  if (_isFocus) {
    ownerDocument.focusedElement = this;
    oldValue = value;
    scheduleMicrotask(() {
      dispatchEvent(FocusEvent(EVENT_FOCUS, relatedTarget: this));
    });
  } else {
    if (ownerDocument.focusedElement == this) {
      ownerDocument.focusedElement = null;
    }
    if (oldValue != value) {
      scheduleMicrotask(() {
        dispatchEvent(Event('change'));
      });
    }
    scheduleMicrotask(() {
      dispatchEvent(FocusEvent(EVENT_BLUR, relatedTarget: this));
    });
  }
}