mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-10 11:01:53 +00:00
When the return key is pressed, we try to handle it as a commit action for input elements. However, we would then go on to actually insert the return key's code point (U+000D) into the input element. This would be sanitized out, but would leave the input element in a state where it thinks it has text to commit. This would result in a change event being fired when the return key is pressed multiple times in a row. We were also firing the beforeinput/input events twice for all return key presses. To fix this, this patch changes the input event target to signify if it actually handled the return key. If not (i.e. for textarea elements), only then do we insert the code point. We also must not fall through to the generic key handler, to avoid the repeated input events.
18 lines
447 B
HTML
18 lines
447 B
HTML
<!DOCTYPE html>
|
|
<input id=input type=text>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
let input = document.getElementById("input");
|
|
|
|
input.addEventListener("change", () => {
|
|
println(input.value);
|
|
});
|
|
|
|
internals.sendText(input, "wfh :^)");
|
|
internals.commitText();
|
|
|
|
// A second commit should not result in a change event.
|
|
internals.commitText();
|
|
})
|
|
</script>
|