I was adding type annotations to a slightly customized inputrules plugin when I noticed a type error from https://github.com/ProseMirror/prosemirror-inputrules/blob/master/src/inputrules.js#L69-L72
handleDOMEvents: {
compositionend: (view) => {
setTimeout(() => {
let {$cursor} = view.state.selection
if ($cursor) run(view, $cursor.pos, $cursor.pos, "", rules, plugin)
})
}
}
The documentation says that event handlers are supposed to return booleans, but in this case because it’s wrapped in a setTimeout
, the return value is void.
What’s the reasoning the handler for compositionend is wrapped in a setTimeout
, and is it safe to remove it?
The commit that added it is here.
Originally I thought with the delay parameter on setTimeout
set to 0, it wouldn’t have any effect, but apparently it still removes the function from the execution queue.