aboutsummaryrefslogtreecommitdiffstats
path: root/ui/widget.js
diff options
context:
space:
mode:
authorFrederik Elvhage <frederik.elvhage@googlemail.com>2014-07-24 15:04:06 +0200
committerScott González <scott.gonzalez@gmail.com>2014-07-24 12:07:12 -0400
commitf7429edfe96d322cdec850f7207efba8125767a6 (patch)
tree7868af0b97a9bd3d5e2766e95e10bc3e95adbe5d /ui/widget.js
parentc399f1f77a015d4f269e3bda98720ebea9bb0c7a (diff)
downloadjquery-ui-f7429edfe96d322cdec850f7207efba8125767a6.tar.gz
jquery-ui-f7429edfe96d322cdec850f7207efba8125767a6.zip
Widget: Improve performance of cleanData method
Fixes #9546 Closes gh-1291
Diffstat (limited to 'ui/widget.js')
-rw-r--r--ui/widget.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/ui/widget.js b/ui/widget.js
index b86232b73..edeb7fa6f 100644
--- a/ui/widget.js
+++ b/ui/widget.js
@@ -25,9 +25,16 @@ var widget_uuid = 0,
$.cleanData = (function( orig ) {
return function( elems ) {
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ var events, elem, i;
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
try {
- $( elem ).triggerHandler( "remove" );
+
+ // Only trigger remove when necessary to save time
+ events = $._data( elem, "events" );
+ if ( events && events.remove ) {
+ $( elem ).triggerHandler( "remove" );
+ }
+
// http://bugs.jquery.com/ticket/8235
} catch( e ) {}
}