How to create an event with filled data of the Transfer property?

I have a local html file with javascript code.

I have to cover drag and drop with tests.

It uses only IE.

In the javascript code, the "drop" event occurs and the contents of dataTransfer (e.dataTransfer.getData ("Text")).

In the test, I simulate an event with the following code:

event = document.createEventObject();

Here an event is created that contains dataTransfer == null.

Writing is not possible because the property is read only.

target.fireEvent("ondrop", event);

The event is fired in javascript code, but dataTransfer is null.

I have to put some test item in dataTransfer.

How can I solve this problem?

+5
source share
1 answer

CustomEvent, , IE.

var event = new CustomEvent('build', { 'detail': elem.dataset.time });

https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent#Adding_custom_data_.E2.80.93_CustomEvent

0

All Articles