Closed lotomb closed 5 years ago
I read that beforeinput is intended to be cancelable: Editor's draft / 14 October 2018.
beforeinput
On Google Chrome at least, this doesn't seem to be the case. I found that a beforeinput event is cancelable when it is triggered by paste (Ctrl+V / drag / context menu) but when triggered by inserting a character or deleting text, it is not.
Is this by design?
MWE:
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { document.getElementById("i").addEventListener("beforeinput", function(e) { alert(e.cancelable); }); }); </script> </head> <body> <input id="i"> </body> </html>
Related SO post: https://stackoverflow.com/questions/53140803
Hey @nbarto , sorry for late response. Chrome follows version 1 of the spec, which does not promise as much cancelability as version 2.
I read that
beforeinput
is intended to be cancelable: Editor's draft / 14 October 2018.On Google Chrome at least, this doesn't seem to be the case. I found that a beforeinput event is cancelable when it is triggered by paste (Ctrl+V / drag / context menu) but when triggered by inserting a character or deleting text, it is not.
Is this by design?
MWE:
Related SO post: https://stackoverflow.com/questions/53140803