Created
March 22, 2021 18:00
-
-
Save ddbeck/5410a42a84789b1fe6942f1b81f03fad to your computer and use it in GitHub Desktop.
This file contains 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
<html> | |
<head> | |
<title>api.EventTarget.addEventListener.options.signal</title> | |
</head> | |
<body> | |
<p id="target">clickable: <span id="state">yes</span></p> | |
<p id="notice">FAIL</p> | |
<script> | |
var controller = new AbortController(); | |
var target = document.getElementById("target"); | |
var notice = document.getElementById("notice"); | |
var state = document.getElementById("state"); | |
function turnOffClick() { | |
state.firstChild.nodeValue = | |
state.firstChild.nodeValue === "yes" ? "no" : "FAIL"; | |
} | |
target.addEventListener("click", turnOffClick, { | |
signal: controller.signal, | |
}); | |
target.click(); | |
controller.abort(); | |
target.click(); | |
if (state.firstChild.nodeValue === "no" && controller.signal.aborted) { | |
notice.innerHTML = "PASS"; | |
} else { | |
notice.innerHTML = "FAIL"; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment