codex-team / codex-team/editor.js
JS error when Input event is not of type InputEvent
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
Describe a bug.
Steps to reproduce:
1. Please download the attached zip. file - [editojs_issue_dueto_chrome_bug.html.zip](https://github.com/codex-team/editor.js/files/9243287/editojs_issue_dueto_chrome_bug.html.zip). The zip contains a single html file.
2. Put the file in a location so that it can be server by a web server.
3. Open the html in Chrome (issue also exists in Safari). The `input` fields 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.
4. The credentials should not come pre-filled. Click anywhere on the page. This cause the `input` event to fire but this time the object type is not instance of `InputEvent` but `Event`. 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 evaluate `mutationsOrInputEvent.some` but `Event` has no method `some` resulting 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.