[whatwg] Drag and drop: bugged implementation of setting drag feedback with setDragImage?

Ian Hickson ian at hixie.ch
Thu Jan 26 15:08:24 PST 2012

On Thu, 29 Sep 2011, RafaÅ~B MiÅ~Becki wrote:
> I've a question regarding setDragImage. I've implemented "dragstart" 
> event handler in the following way:
> event.setDragImage(this, 0, 0);
> this.style.background = 'yellow';
> What do I expect:
> 1) Origin element to have yellow background
> 2) Drag feedback element (the one under cursor) to have original background
> Are my expectations correct?

Sort of. The spec doesn't say that the drag image needs to exactly match 
the element, so technically browsers are allowed to set the bitmap to 
what the element will look like at some time in the future... But yeah, in 
principle, what you describe is correct.

> Because Webkit and Gecko implementation doesn't match it. In their cases 
> both elements have modified background. It seems that both engines delay 
> setting drag image until the end of event handler.

On Fri, 30 Sep 2011, Daniel Cheng wrote:
> The reason it works that way is inside the dragstart handler, when you 
> call setDragImage, we merely retain a reference to the element you 
> passed in. We don't actually create the drag image until after dragstart 
> processing is finished.

Makes sense.

Seems more useful to support what Rafal is trying to do, though, so I 
haven't currently changed the spec for this.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list