This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +37
-13
lines changed
Expand file tree Collapse file tree 4 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " angular-ui-sortable" ,
3- "version" : " 0.12.2 " ,
3+ "version" : " 0.12.3 " ,
44 "description" : " This directive allows you to jQueryUI Sortable." ,
55 "author" : " https://github.com/angular-ui/ui-sortable/graphs/contributors" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change 11{
22 "name" : " angular-ui-sortable" ,
3- "version" : " 0.12.2 " ,
3+ "version" : " 0.12.3 " ,
44 "description" : " This directive allows you to jQueryUI Sortable." ,
55 "author" : " https://github.com/angular-ui/ui-sortable/graphs/contributors" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -174,18 +174,21 @@ angular.module('ui.sortable', [])
174174 } ;
175175
176176 scope . $watch ( attrs . uiSortable , function ( newVal /*, oldVal*/ ) {
177- angular . forEach ( newVal , function ( value , key ) {
178- if ( callbacks [ key ] ) {
179- if ( key === 'stop' ) {
180- // call apply after stop
181- value = combineCallbacks (
182- value , function ( ) { scope . $apply ( ) ; } ) ;
177+ if ( ! ! element . data ( 'ui-sortable' ) ) {
178+ angular . forEach ( newVal , function ( value , key ) {
179+ if ( callbacks [ key ] ) {
180+ if ( key === 'stop' ) {
181+ // call apply after stop
182+ value = combineCallbacks (
183+ value , function ( ) { scope . $apply ( ) ; } ) ;
184+ }
185+ // wrap the callback
186+ value = combineCallbacks ( callbacks [ key ] , value ) ;
183187 }
184- // wrap the callback
185- value = combineCallbacks ( callbacks [ key ] , value ) ;
186- }
187- element . sortable ( 'option' , key , value ) ;
188- } ) ;
188+
189+ element . sortable ( 'option' , key , value ) ;
190+ } ) ;
191+ }
189192 } , true ) ;
190193
191194 angular . forEach ( callbacks , function ( value , key ) {
Original file line number Diff line number Diff line change @@ -46,6 +46,27 @@ describe('uiSortable', function() {
4646 } ) ;
4747 } ) ;
4848
49+ it ( 'should not try to apply options to a destroyed sortable' , function ( ) {
50+ inject ( function ( $compile , $rootScope , $timeout ) {
51+ var element ;
52+ var childScope = $rootScope . $new ( ) ;
53+ element = $compile ( '<div><ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items">{{ item }}</li></ul></div>' ) ( childScope ) ;
54+ $rootScope . $apply ( function ( ) {
55+ childScope . items = [ 'One' , 'Two' , 'Three' ] ;
56+ childScope . opts = {
57+ update : function ( ) { }
58+ } ;
59+
60+ element . remove ( element . firstChild ) ;
61+ } ) ;
62+
63+ expect ( function ( ) {
64+ $timeout . flush ( ) ;
65+ } ) . not . toThrow ( ) ;
66+
67+ } ) ;
68+ } ) ;
69+
4970 } ) ;
5071
5172} ) ;
You can’t perform that action at this time.
0 commit comments