There is DataTransfer constructor, so you can create one very easily, now you just have to add()
a File
object to its items
list:
const dataTransfer = new DataTransfer();
const file = new File( [ "some content" ], "text-file.txt" );
dataTransfer.items.add( file );
const event = new DragEvent( "drop", { dataTransfer } );
ondrop = (evt) => {
const dT = evt.dataTransfer;
console.log( dT.items[ 0 ], dT.items[ 0 ].webkitGetAsEntry() );
};
dispatchEvent( event );
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…