Skip to content

DataTransfer.setDragImage() steps are unclear on how to size passed in <img> #13099

Open

Description

@weinig

What is the issue with the HTML Standard?

Step 3 in DataTransfer.setDragImage() states:

  1. If image is an img element, then set the drag data store bitmap to the element's image (at its natural size); otherwise, set the drag data store bitmap to an image generated from the given element (the exact mechanism for doing so is not currently specified).

For images that don't have a natural size, like dimensionless SVG images or an <img> with content: linear-gradient(...), its unclear what to do here.

For the most part, places where images need to be sized and displayed in some way like this should specify a concrete object size resolution algorithm to use.

Here though, I think it might make more sense to just defer to the engine so they can use whatever rules they use of drag-and-drop of images elsewhere. Or, if there is spec text about the normal (non-script) drag-and-drop of images, defer to that.

The one case that might be worth calling out is what to do about an <img> that is detached from the DOM, as that won't be handled in the non-script case. For that case, my suggestion would be to use the default sizing algorithm but allowing engines to set reasonable limits on maximum and minimum concrete sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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