I need to programmatically create a ClipboardEvent instance in Chrome.
But when I run the constructor:
new ClipboardEvent("paste", {dataType: "text/plain", data: "some data"})
It throws the following error:
Uncaught TypeError: Illegal constructor
The constructor works as intended in Firefox.
Checked MDN and W3C spec and they don't mention anything about it being illegal to create instances of ClipboardEvent.
Is it possible to create an instance of ClipboardEvent in Chrome in any other way? I prefer to not mock a custom ClipboardEvent when one exists.
Update 2018-07-17: Using the ClipboardEvent seems to work in Chrome 69.
Unfortunately, it's not. This is from http://caniuse.com/#feat=clipboard
Partial support in IE refers using a non-standard method of interacting with the clipboard. For other browsers it refers to not supporting the ClipboardEvent constructor.
Unfortunately, the only browser that properly supports the Clipboard API
is FireFox (since 22). All other browsers (if it supports Clipboard API at all), will not support the ClipbordEvent constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With