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
13
ui/jquery.ui.widget.js
vendored
13
ui/jquery.ui.widget.js
vendored
@ -134,18 +134,19 @@ $.Widget.prototype = {
|
|||||||
},
|
},
|
||||||
_createWidget: function( options, element ) {
|
_createWidget: function( options, element ) {
|
||||||
element = $( element || this.defaultElement || this )[ 0 ];
|
element = $( element || this.defaultElement || this )[ 0 ];
|
||||||
$.data( element, this.widgetName, this );
|
|
||||||
this.element = $( element );
|
this.element = $( element );
|
||||||
this.options = $.extend( true, {},
|
this.options = $.extend( true, {},
|
||||||
this.options,
|
this.options,
|
||||||
this._getCreateOptions(),
|
this._getCreateOptions(),
|
||||||
options );
|
options );
|
||||||
|
if (element !== this) {
|
||||||
|
$.data(element, this.widgetName, this);
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.element.bind( "remove." + this.widgetName, function() {
|
this.element.bind("remove." + this.widgetName, function(){
|
||||||
self.destroy();
|
self.destroy();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
this._create();
|
this._create();
|
||||||
this._trigger( "create" );
|
this._trigger( "create" );
|
||||||
this._init();
|
this._init();
|
||||||
|
Loading…
Reference in New Issue
Block a user