editor.js
editor.js copied to clipboard
JS error when Input event is not of type InputEvent
Describe a bug.
Steps to reproduce:
- Please download the attached zip. file - editojs_issue_dueto_chrome_bug.html.zip. The zip contains a single html file.
- Put the file in a location so that it can be server by a web server.
- Open the html in Chrome (issue also exists in Safari). The
inputfields needs to be pre-filled with username and password. If for the domain from where the html is served has no saved credentials then save one and reload the page. - The credentials should not come pre-filled. Click anywhere on the page. This cause the
inputevent to fire but this time the object type is not instance ofInputEventbutEvent. Because of that the code shown below: https://github.com/codex-team/editor.js/blob/6c0555a3229a16641709cdc83ec248af87f3c77a/src/components/block/index.ts#L206 It tries to evaluatemutationsOrInputEvent.somebutEventhas no methodsomeresulting into this error.
Expected behavior:
It seems to be a browser defect but the same issue exists in Safari as well. Today only I have filed this defect (https://bugs.chromium.org/p/chromium/issues/detail?id=1349207) so not sure if this will get accepted or it will be dismissed. Either way I think Editor JS should take care of this edge case and not run into JS error.
The fix is simple. Just check if it is instanceof Event with type property set to input.
Screenshots:

Device, Browser, OS: Chrome 103.0.5060.134 (Official Build) (x86_64) MacOS 12.5
Editor.js version: 2.25.0
Plugins you use with their versions: None