(node: DOMElement)
| 25 | } |
| 26 | |
| 27 | focus(node: DOMElement): void { |
| 28 | if (node === this.activeElement) return |
| 29 | if (!this.enabled) return |
| 30 | |
| 31 | const previous = this.activeElement |
| 32 | if (previous) { |
| 33 | // Deduplicate before pushing to prevent unbounded growth from Tab cycling |
| 34 | const idx = this.focusStack.indexOf(previous) |
| 35 | if (idx !== -1) this.focusStack.splice(idx, 1) |
| 36 | this.focusStack.push(previous) |
| 37 | if (this.focusStack.length > MAX_FOCUS_STACK) this.focusStack.shift() |
| 38 | this.dispatchFocusEvent(previous, new FocusEvent('blur', node)) |
| 39 | } |
| 40 | this.activeElement = node |
| 41 | this.dispatchFocusEvent(node, new FocusEvent('focus', previous)) |
| 42 | } |
| 43 | |
| 44 | blur(): void { |
| 45 | if (!this.activeElement) return |
no test coverage detected