From 03dcdd6373299bc5bc476e698b74dc5bf3ddda1f Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Mon, 31 Jan 2011 16:33:45 +0100 Subject: [PATCH] Optimize widget's _createWidget method to not store data and bind remove when dealing with an instance without an element (element == instance). --- ui/jquery.ui.widget.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 7dfcb4447..ece6e9e16 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -134,18 +134,19 @@ $.Widget.prototype = { }, _createWidget: function( options, element ) { element = $( element || this.defaultElement || this )[ 0 ]; - $.data( element, this.widgetName, this ); this.element = $( element ); this.options = $.extend( true, {}, this.options, this._getCreateOptions(), options ); - - var self = this; - this.element.bind( "remove." + this.widgetName, function() { - self.destroy(); - }); - + if (element !== this) { + $.data(element, this.widgetName, this); + + var self = this; + this.element.bind("remove." + this.widgetName, function(){ + self.destroy(); + }); + } this._create(); this._trigger( "create" ); this._init(); -- 2.39.5