Skip to content

Commit 7033544

Browse files
committed
Sortable: Don't create functions inside loops.
1 parent 71a332e commit 7033544

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ui/jquery.ui.sortable.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
(function( $, undefined ) {
1717

18-
/*jshint loopfunc: true */
19-
2018
function isOverAxis( x, reference, size ) {
2119
return ( x > reference ) && ( x < ( reference + size ) );
2220
}
@@ -629,10 +627,11 @@ $.widget("ui.sortable", $.ui.mouse, {
629627

630628
queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
631629

630+
function addItems() {
631+
items.push( this );
632+
}
632633
for (i = queries.length - 1; i >= 0; i--){
633-
queries[i][0].each(function() {
634-
items.push(this);
635-
});
634+
queries[i][0].each( addItems );
636635
}
637636

638637
return $(items);
@@ -1190,12 +1189,17 @@ $.widget("ui.sortable", $.ui.mouse, {
11901189

11911190

11921191
//Post events to containers
1192+
function delayEvent( type, instance, container ) {
1193+
return function( event ) {
1194+
container._trigger( type, event, instance._uiHash( instance ) );
1195+
};
1196+
}
11931197
for (i = this.containers.length - 1; i >= 0; i--){
1194-
if(!noPropagation) {
1195-
delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1198+
if (!noPropagation) {
1199+
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
11961200
}
11971201
if(this.containers[i].containerCache.over) {
1198-
delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1202+
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
11991203
this.containers[i].containerCache.over = 0;
12001204
}
12011205
}

0 commit comments

Comments
 (0)