Created
December 10, 2024 09:35
-
-
Save SilentImp/6f0c1ad9750a23d5a29ac978d0551fc4 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
<article id="article-1"> | |
<p>Some text</p> | |
<p>Some text</p> | |
<menu> | |
<button commandfor="article-1" command="--record-like">like</button> | |
</menu> | |
</article> | |
<script> | |
document.body.addEventListener("command", ({ action, target }) => { | |
switch(action) { | |
case "--record-like": | |
navigator.sendBeacon(BuildArticleLikeURL(target.getAttribute('id'))); | |
optimisticLike(target.getAttribute('id')) | |
break; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment