function onFocus(e) {
    // Prevent IE from focusing the document or HTML element.
    if (!isValidFocusTarget(e.target)) {
      return;
    }

    if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {
      addFocusVisibleAttribute(e.target);
    }
  }
On `focus`, add the `focus-visible` attribute to the target if:
- the target received focus as a result of keyboard navigation, or
- the event target is an element that will likely require interaction
  via the keyboard (e.g. a text box)