Skip to content

Commit 5e51b8d

Browse files
committed
Update Widget data naming/usage. Remove unnecessary fallbacks, update .removeData to use full name.
1 parent d901cd4 commit 5e51b8d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

tests/unit/widget/widget_core.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test( "custom selector expression", function() {
8282
});
8383

8484
test( "jQuery usage", function() {
85-
expect( 15 );
85+
expect( 16 );
8686

8787
var shouldCreate = false;
8888

@@ -140,6 +140,9 @@ test( "jQuery usage", function() {
140140
ret = elem.testWidget( "jQueryObject" );
141141
equal( ret[ 0 ], document.body, "returned jQuery object" );
142142
equal( ret.end(), elem, "stack preserved" );
143+
144+
elem.testWidget( "destroy" );
145+
equal( elem.data( "ui-testWidget" ), null );
143146
});
144147

145148
test( "direct usage", function() {

ui/jquery.ui.widget.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ $.widget.bridge = function( name, object ) {
163163

164164
if ( isMethodCall ) {
165165
this.each(function() {
166-
// 1.9 BC for #7810
167-
// TODO remove fallback to name
168-
var instance = $.data( this, fullName ) || $.data( this, name );
166+
var instance = $.data( this, fullName );
169167
if ( !instance ) {
170168
return $.error( "cannot call methods on " + name + " prior to initialization; " +
171169
"attempted to call method '" + options + "'" );
@@ -183,9 +181,7 @@ $.widget.bridge = function( name, object ) {
183181
});
184182
} else {
185183
this.each(function() {
186-
// 1.9 BC for #7810
187-
// TODO remove fallback to name
188-
var instance = $.data( this, fullName ) || $.data( this, name );
184+
var instance = $.data( this, fullName );
189185
if ( instance ) {
190186
instance.option( options || {} )._init();
191187
} else {
@@ -252,7 +248,7 @@ $.Widget.prototype = {
252248
// all event bindings should go through this._bind()
253249
this.element
254250
.unbind( "." + this.widgetName )
255-
.removeData( this.widgetName );
251+
.removeData( this.widgetFullName );
256252
this.widget()
257253
.unbind( "." + this.widgetName )
258254
.removeAttr( "aria-disabled" )

0 commit comments

Comments
 (0)