Class: FakeDataTransfer
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:18
Internal
Minimal DataTransfer implementation for synthesizing HTML5 drag-and-drop
events under jsdom, which implements neither DragEvent nor DataTransfer
(only MouseEvent — see FakeMouseEvent). @testing-library/dom's
fireEvent.drag* helpers special-case a dataTransfer init value and attach
it to the dispatched event verbatim when window.DataTransfer is absent —
this is that value, shared across one gesture's dragstart → dragenter →
dragover → drop → dragend sequence so a dragstart handler's
setData is readable from drop's getData.
files/items are not supported — the drag primitives synthesize element
drag-and-drop, not OS file drops, which DOMInteractor.setInputFiles
already covers.
See​
https://github.com/jsdom/jsdom/issues/1568
Implements​
DataTransfer
Constructors​
Constructor​
new FakeDataTransfer():
FakeDataTransfer
Returns​
FakeDataTransfer
Properties​
dropEffect​
dropEffect:
"none"|"copy"|"link"|"move"='move'
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:21
The DataTransfer.dropEffect property controls the feedback (typically visual) the user is given during a drag and drop operation. It will affect which cursor is displayed while dragging. For example, when the user hovers over a target drop element, the browser's cursor may indicate which type of operation will occur.
Implementation of​
DataTransfer.dropEffect
effectAllowed​
effectAllowed:
"none"|"copy"|"link"|"move"|"copyLink"|"copyMove"|"linkMove"|"all"|"uninitialized"='all'
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:22
The DataTransfer.effectAllowed property specifies the effect that is allowed for a drag operation. The copy operation is used to indicate that the data being dragged will be copied from its present location to the drop location. The move operation is used to indicate that the data being dragged will be moved, and the link operation is used to indicate that some form of relationship or connection will be created between the source and drop locations.
Implementation of​
DataTransfer.effectAllowed
files​
readonlyfiles:FileList
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:23
The files read-only property of DataTransfer objects is a list of the files in the drag operation. If the operation includes no files, the list is empty.
Implementation of​
DataTransfer.files
items​
readonlyitems:DataTransferItemList
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:24
The read-only items property of the DataTransfer interface is a list of the data transfer items in a drag operation. The list includes one item for each item in the operation and if the operation had no items, the list is empty.
Implementation of​
DataTransfer.items
Accessors​
types​
Get Signature​
get types(): readonly
string[]
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:26
The DataTransfer.types read-only property returns the available types that exist in the items.
Returns​
readonly string[]
Implementation of​
DataTransfer.types
Methods​
clearData()​
clearData(
format?):void
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:30
The DataTransfer.clearData() method removes the drag operation's drag data for the given type. If data for the given type does not exist, this method does nothing.
Parameters​
format?​
string
Returns​
void
Implementation of​
DataTransfer.clearData
getData()​
getData(
format):string
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:38
The DataTransfer.getData() method retrieves drag data (as a string) for the specified type. If the drag operation does not include data, this method returns an empty string.
Parameters​
format​
string
Returns​
string
Implementation of​
DataTransfer.getData
setData()​
setData(
format,data):void
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:42
The DataTransfer.setData() method sets the drag operation's drag data to the specified data and type. If data for the given type does not exist, it is added at the end of the drag data store, such that the last item in the types list will be the new type. If data for the given type already exists, the existing data is replaced in the same position. That is, the order of the types list is not changed when replacing data of the same type.
Parameters​
format​
string
data​
string
Returns​
void
Implementation of​
DataTransfer.setData
setDragImage()​
setDragImage(
_image,_x,_y):void
Defined in: packages/dom-core/src/fakeEvents/FakeDataTransfer.ts:52
No-op: jsdom has no layout/paint, so a custom drag image has nothing to
render. (Overrides the inherited DataTransfer.setDragImage doc comment,
which embeds raw <img>/<canvas> markup that breaks MDX rendering on
the generated API reference page.)
Parameters​
_image​
Element
_x​
number
_y​
number
Returns​
void
Implementation of​
DataTransfer.setDragImage