diff --git a/bower.json b/bower.json index 24825ea..17d5c21 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-sortable", - "version": "0.12.0", + "version": "0.12.1", "description": "This directive allows you to jQueryUI Sortable.", "author": "https://github.com/angular-ui/ui-sortable/graphs/contributors", "license": "MIT", diff --git a/package.json b/package.json index 98aad5b..78baaf5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-sortable", - "version": "0.12.0", + "version": "0.12.1", "description": "This directive allows you to jQueryUI Sortable.", "author": "https://github.com/angular-ui/ui-sortable/graphs/contributors", "license": "MIT", diff --git a/src/sortable.js b/src/sortable.js index ee6ff37..08cad5e 100644 --- a/src/sortable.js +++ b/src/sortable.js @@ -115,11 +115,9 @@ angular.module('ui.sortable', []) // the start and stop of repeat sections and sortable doesn't // respect their order (even if we cancel, the order of the // comments are still messed up). - savedNodes.detach(); if (element.sortable('option','helper') === 'clone') { - // first detach all the savedNodes and then restore all of them - // except .ui-sortable-helper element (which is placed last). - // That way it will be garbage collected. + // restore all the savedNodes except .ui-sortable-helper element + // (which is placed last). That way it will be garbage collected. savedNodes = savedNodes.not(savedNodes.last()); } savedNodes.appendTo(element); @@ -153,7 +151,7 @@ angular.module('ui.sortable', []) // if the item was not moved, then restore the elements // so that the ngRepeat's comment are correct. if((!('dropindex' in ui.item.sortable) || ui.item.sortable.isCanceled()) && element.sortable('option','helper') !== 'clone') { - savedNodes.detach().appendTo(element); + savedNodes.appendTo(element); } } }; diff --git a/test/karma.conf.js b/test/karma.conf.js index 8545165..89e0c70 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -22,6 +22,7 @@ module.exports = function(config) { 'bower_components/angular-mocks/angular-mocks.js', 'src/sortable.js', 'test/sortable.test-helper.js', + 'test/sortable.test-directives.js', 'test/*.spec.js' ], diff --git a/test/sortable.e2e.directives.spec.js b/test/sortable.e2e.directives.spec.js new file mode 100644 index 0000000..1c071a4 --- /dev/null +++ b/test/sortable.e2e.directives.spec.js @@ -0,0 +1,100 @@ +'use strict'; + +describe('uiSortable', function() { + + // Ensure the sortable angular module is loaded + beforeEach(module('ui.sortable')); + beforeEach(module('ui.sortable.testHelper')); + beforeEach(module('ui.sortable.testDirectives')); + + var EXTRA_DY_PERCENTAGE, listContent, listInnerContent; + + beforeEach(inject(function (sortableTestHelper) { + EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE; + listContent = sortableTestHelper.listContent; + listInnerContent = sortableTestHelper.listInnerContent; + })); + + describe('Inner directives related', function() { + + var host; + + beforeEach(inject(function() { + host = $('
'); + $('body').append(host); + })); + + afterEach(function() { + host.remove(); + host = null; + }); + + it('should work when inner directives are used', function() { + inject(function($compile, $rootScope) { + var element; + element = $compile(''.concat( + '