This will log the currently active element as it changes. Really great for accessibility testing when you're trying to figure out what element has focus (so you can either prevent it from getting focus or make the fact that it has focus more visually obvious for example).
Created
July 26, 2018 13:08
-
-
Save kentcdodds/121cd18ef58b0b22873247d29a664cb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){if(window._activeElInterval){clearInterval(window._activeElInterval);delete window._activeElInterval;}else{var activeEl;window._activeElInterval=setInterval(function(){var currentActiveEl=document.activeElement;if(currentActiveEl!==activeEl){activeEl=currentActiveEl;console.log(activeEl);}},200);}})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
if (window._activeElInterval) { | |
clearInterval(window._activeElInterval); | |
delete window._activeElInterval; | |
} else { | |
var activeEl; | |
window._activeElInterval = setInterval(function() { | |
var currentActiveEl = document.activeElement; | |
if (currentActiveEl !== activeEl) { | |
activeEl = currentActiveEl; | |
console.log(activeEl); | |
} | |
}, 200); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment