@testing-library/user-event
Version:
Fire events the same way the user does
13 lines (10 loc) • 388 B
JavaScript
import { eventWrapper } from '../misc/eventWrapper.js';
import { getActiveElement } from './getActiveElement.js';
import { isFocusable } from './isFocusable.js';
function blur(element) {
if (!isFocusable(element)) return;
const wasActive = getActiveElement(element.ownerDocument) === element;
if (!wasActive) return;
eventWrapper(()=>element.blur());
}
export { blur };