mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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:
parent
6309061a2b
commit
03dcdd6373
5
ui/jquery.ui.widget.js
vendored
5
ui/jquery.ui.widget.js
vendored
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user