JSFiddle - React, Tailwind, and code Playground
JavaScript
const button = document.createElement('button');
button.textContent = "Hello, Dave!";
document.body.innerHTML = "";
document.body.appendChild(button);
button.addEventListener('blur', () => console.log('blurred'));
button.focus();
// sanity check: "BUTTON"
console.log(document.activeElement.tagName)
// sanity check: logs "blurred"
button.blur();
button.focus();
// actual test: logs "blurred"
button.parentNode.removeChild(button)
// sanity check: "BODY"
console.log(document.activeElement.tagName)