Optimize widget's _createWidget method to not store data and bind remove

when dealing with an instance without an element (element == instance).
This commit is contained in:
jzaefferer 2011-01-31 16:33:45 +01:00
parent 6309061a2b
commit 03dcdd6373

View File

@ -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 );
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();