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 1
1
{
2
2
"name" : " angular-ui-sortable" ,
3
- "version" : " 0.12.2 " ,
3
+ "version" : " 0.12.3 " ,
4
4
"description" : " This directive allows you to jQueryUI Sortable." ,
5
5
"author" : " https://github.com/angular-ui/ui-sortable/graphs/contributors" ,
6
6
"license" : " MIT" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " angular-ui-sortable" ,
3
- "version" : " 0.12.2 " ,
3
+ "version" : " 0.12.3 " ,
4
4
"description" : " This directive allows you to jQueryUI Sortable." ,
5
5
"author" : " https://github.com/angular-ui/ui-sortable/graphs/contributors" ,
6
6
"license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -174,18 +174,21 @@ angular.module('ui.sortable', [])
174
174
} ;
175
175
176
176
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 ) ;
183
187
}
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
+ }
189
192
} , true ) ;
190
193
191
194
angular . forEach ( callbacks , function ( value , key ) {
Original file line number Diff line number Diff line change @@ -46,6 +46,27 @@ describe('uiSortable', function() {
46
46
} ) ;
47
47
} ) ;
48
48
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
+
49
70
} ) ;
50
71
51
72
} ) ;
You can’t perform that action at this time.
0 commit comments