This snippet is useful for debugging things like who's setting focus on a particular element.
DevTools > Source tab > Top left panel > Select snippet > New snippet
Disclaimer: this snippet only breaks when <HTMLElement>.focus()
is called -- if you want to break on focus events, Safari's debugger lets you set DOM event breakpoints.
Also, it's often helpful to use focusin
/focusout
events for debugging since they bubble.