Make hasFocus use document.activeElement, rather than internal flag

This way, it synchronously returns the current value, rather
than only being updated when an async focus/blur event fires.

Closes #2151