aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/droppable
diff options
context:
space:
mode:
authorZaven Muradyan <megalivoithos@gmail.com>2013-02-23 21:55:29 -0800
committerScott González <scott.gonzalez@gmail.com>2013-02-26 09:56:18 -0500
commit1c80735acb20a468300a53f85ef49b065d40af3e (patch)
treeefb5fe8f9f031ae008ffa294f0f6e827fd7f23eb /tests/unit/droppable
parente9c04bfa430eb6b18e7fe1be2f8d162e01181a94 (diff)
downloadjquery-ui-1c80735acb20a468300a53f85ef49b065d40af3e.tar.gz
jquery-ui-1c80735acb20a468300a53f85ef49b065d40af3e.zip
Droppable: Changed drop event to loop over a copied array instead of the droppables directly. Fixed #9116 - Droppable: Drop event can cause droppables to remain active if any droppable is created/destroyed in the event handler.
Diffstat (limited to 'tests/unit/droppable')
-rw-r--r--tests/unit/droppable/droppable.html1
-rw-r--r--tests/unit/droppable/droppable_events.js33
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html
index 7cd5eb0f5..d084464c2 100644
--- a/tests/unit/droppable/droppable.html
+++ b/tests/unit/droppable/droppable.html
@@ -42,6 +42,7 @@
<div id="draggable1" style="width: 25px; height: 25px;">Draggable</div>
<div id="droppable1" style="width: 100px; height: 100px;">Droppable</div>
+<div id="droppable2" style="width: 100px; height: 100px;">Droppable</div>
<div style='width:1000px;height:1000px;'>&nbsp;</div>
</div>
diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/droppable_events.js
index 8f842e942..707eea1f4 100644
--- a/tests/unit/droppable/droppable_events.js
+++ b/tests/unit/droppable/droppable_events.js
@@ -5,6 +5,39 @@
module("droppable: events");
+test( "droppable destruction/recreation on drop event", function() {
+ expect( 1 );
+
+ var config = {
+ activeClass: "active",
+ drop: function() {
+ var element = $( this ),
+ newDroppable = $( "<div>" )
+ .css({ width: 100, height: 100 })
+ .text( "Droppable" );
+ element.after( newDroppable );
+ element.remove();
+ newDroppable.droppable( config );
+ }
+ },
+
+ draggable = $( "#draggable1" ).draggable(),
+ droppable1 = $( "#droppable1" ).droppable( config ),
+ droppable2 = $( "#droppable2" ).droppable( config ),
+
+ droppableOffset = droppable1.offset(),
+ draggableOffset = draggable.offset(),
+ dx = droppableOffset.left - draggableOffset.left,
+ dy = droppableOffset.top - draggableOffset.top;
+
+ draggable.simulate( "drag", {
+ dx: dx,
+ dy: dy
+ });
+
+ ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" );
+});
+
// this is here to make JSHint pass "unused", and we don't want to
// remove the parameter for when we finally implement
$.noop();