Skip to content

Commit b9be6bb

Browse files
committed
Sortable: Copy the src of the original item when creating a placeholder from an image. Fixes #5129 - Sortable: Unable to use an image as a placeholder in Firefox.
1 parent ca0b4b8 commit b9be6bb

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

tests/unit/sortable/sortable.html

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ <h2 id="qunit-userAgent"></h2>
8484
</tbody>
8585
</table>
8686

87+
<div id="sortable-images">
88+
<img src="../images/jqueryui_32x32.png">
89+
<img src="../images/jqueryui_32x32.png">
90+
<img src="../images/jqueryui_32x32.png">
91+
<img src="../images/jqueryui_32x32.png">
92+
</div>
93+
8794
</div>
8895
</body>
8996
</html>

tests/unit/sortable/sortable_options.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
module("sortable: options");
77

8-
// this is here to make JSHint pass "unused", and we don't want to
9-
// remove the parameter for when we finally implement
10-
$.noop();
11-
128
/*
139
test("{ appendTo: 'parent' }, default", function() {
1410
ok(false, "missing test - untested code is broken code.");
@@ -186,6 +182,23 @@ test("{ placeholder: false }, default", function() {
186182
ok(false, "missing test - untested code is broken code.");
187183
});
188184
*/
185+
186+
test( "{ placeholder: false } img", function() {
187+
expect( 3 );
188+
189+
var element = $( "#sortable-images" ).sortable({
190+
start: function( event, ui ) {
191+
equal( ui.placeholder.attr( "src" ), "../images/jqueryui_32x32.png", "placeholder img has correct src" );
192+
equal( ui.placeholder.height(), 32, "placeholder has correct height" );
193+
equal( ui.placeholder.width(), 32, "placeholder has correct width" );
194+
}
195+
});
196+
197+
element.find( "img" ).eq( 0 ).simulate( "drag", {
198+
dy: 1
199+
});
200+
});
201+
189202
test( "{ placeholder: String }", function() {
190203
expect( 1 );
191204

ui/jquery.ui.sortable.js

+2
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ $.widget("ui.sortable", $.ui.mouse, {
762762
// width of the table (browsers are smart enough to
763763
// handle this properly)
764764
element.append( "<td colspan='99'>&#160;</td>" );
765+
} else if ( nodeName === "img" ) {
766+
element.attr( "src", that.currentItem.attr( "src" ) );
765767
}
766768

767769
if ( !className ) {

0 commit comments

Comments
 (0)