Implement dom-inputevent

This commit is contained in:
Steven Sinatra
2017-07-03 17:41:00 +10:00
parent ae6459f44a
commit ad428a77e4
4 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
const input = document.createElement('input');
input.addEventListener('input', (event: InputEvent) => {
return event.data === 'foo' && event.isComposing === true;
});
const foo = new InputEvent('input');
const bar = new InputEvent('beforeinput', {
data: 'bar',
isComposing: true,
});

17
types/dom-inputevent/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for UI Events W3C Working Draft — Input Events — Interface InputEvent 1.0
// Project: https://w3c.github.io/uievents/#interface-inputevent
// Definitions by: Steven Sinatra <https://github.com/diagramatics>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface InputEventInit extends UIEventInit {
data?: string;
isComposing: boolean;
}
interface InputEvent extends UIEvent {
readonly data: string;
readonly isComposing: boolean;
}
declare class InputEvent {
constructor(typeArg: 'input' | 'beforeinput', inputEventInit?: InputEventInit);
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dom-inputevent-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }