aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.widget.js
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2011-01-31 16:33:45 +0100
committerjzaefferer <joern.zaefferer@gmail.com>2011-01-31 16:33:45 +0100
commit03dcdd6373299bc5bc476e698b74dc5bf3ddda1f (patch)
treef92927d79e2ecc0e05eb8ee22dcce33945c3fedb /ui/jquery.ui.widget.js
parent6309061a2b3abb7d20bfbb65602efe1a35081494 (diff)
downloadjquery-ui-03dcdd6373299bc5bc476e698b74dc5bf3ddda1f.tar.gz
jquery-ui-03dcdd6373299bc5bc476e698b74dc5bf3ddda1f.zip
Optimize widget's _createWidget method to not store data and bind remove
when dealing with an instance without an element (element == instance).
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r--ui/jquery.ui.widget.js15
1 files 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();