(to: Element | null)
| 2 | import {getOwnerDocument} from '../utils/domHelpers'; |
| 3 | |
| 4 | export function moveVirtualFocus(to: Element | null): void { |
| 5 | let from = getVirtuallyFocusedElement(getOwnerDocument(to)); |
| 6 | if (from !== to) { |
| 7 | if (from) { |
| 8 | dispatchVirtualBlur(from, to); |
| 9 | } |
| 10 | if (to) { |
| 11 | dispatchVirtualFocus(to, from); |
| 12 | } |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | export function dispatchVirtualBlur(from: Element, to: Element | null): void { |
| 17 | from.dispatchEvent(new FocusEvent('blur', {relatedTarget: to})); |
no test coverage detected