Skip to content

Commit 017568e

Browse files
authored
Support inputType on InputEvent
Also removes the initInputEvent method implementation, which was never exposed (and does not exist in the spec).
1 parent 29f4fdf commit 017568e

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

lib/jsdom/living/events/InputEvent-impl.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
"use strict";
2-
32
const UIEventImpl = require("./UIEvent-impl").implementation;
4-
53
const InputEventInit = require("../generated/InputEventInit");
64

75
// https://w3c.github.io/uievents/#interface-inputevent
8-
class InputEventImpl extends UIEventImpl {
9-
initInputEvent(type, bubbles, cancelable, data, isComposing) {
10-
if (this._dispatchFlag) {
11-
return;
12-
}
13-
14-
this.initUIEvent(type, bubbles, cancelable);
15-
this.data = data;
16-
this.isComposing = isComposing;
17-
}
18-
}
6+
class InputEventImpl extends UIEventImpl { }
197
InputEventImpl.defaultInit = InputEventInit.convert(undefined);
208

219
module.exports = {

lib/jsdom/living/events/InputEvent.webidl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface InputEvent : UIEvent {
55

66
readonly attribute DOMString? data;
77
readonly attribute boolean isComposing;
8+
readonly attribute DOMString inputType;
89
};
910

1011
// https://w3c.github.io/uievents/#idl-inputeventinit
@@ -13,4 +14,5 @@ dictionary InputEventInit : UIEventInit {
1314
// DOMString? data = "";
1415
DOMString? data = null;
1516
boolean isComposing = false;
17+
DOMString inputType = "";
1618
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<title>InputEvent Constructor Tests</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script>
6+
"use strict";
7+
test(() => {
8+
const event = new InputEvent("type");
9+
assert_equals(event.data, null, ".data");
10+
assert_false(event.isComposing, ".isComposing");
11+
assert_equals(event.inputType, "", ".inputType");
12+
}, "InputEvent constructor without InputEventInit.");
13+
14+
test(() => {
15+
const event = new InputEvent("type", { inputType: "insertText" });
16+
assert_equals(event.inputType, "insertText", ".inputType");
17+
}, "InputEvent construtor with InputEventInit where inputType is specified");
18+
</script>

0 commit comments

Comments
 (0)