w3c / input-events

Input Events
https://w3c.github.io/input-events/
Other
23 stars 16 forks source link

Documentation says beforeinput event is cancelable, browser says it's not #92

Closed lotomb closed 5 years ago

lotomb commented 5 years ago

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:

<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

johanneswilm commented 5 years ago

Hey @nbarto , sorry for late response. Chrome follows version 1 of the spec, which does not promise as much cancelability as version 2.