Skip to content

Using a real DataTransfer object with a drop event fails #857

Open
@johnjesse

Description

@johnjesse
  • @testing-library/dom version: latest
  • Testing Framework and version:
  • DOM Environment:

Relevant code or config:

value: Object.getOwnPropertyNames(dataTransferValue).reduce(
- this assumes it only needs to copy across named properties - But if the caller uses an actual DataTransfer object e.g. by calling new window.DataTransfer() - adding data to it and passing it in, then this won't read the properties off it.

Try it for yourself - in Chrome Object.getOwnPropertyNames(new window.DataTransfer()) returns an empty array.

This means - it's impossible to use a DataTransfer object, add data to it and then use it for the event.

Suggested solution:

if the dataTransfer value passed to the event is an actual instance of window.DataTransfer then just pass it on - don't try to copy properties over to a new instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions