]> source.dussan.org Git - jquery-ui.git/commitdiff
Update Widget data naming/usage. Remove unnecessary fallbacks, update .removeData...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 1 Mar 2012 14:03:30 +0000 (15:03 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 1 Mar 2012 14:03:30 +0000 (15:03 +0100)
tests/unit/widget/widget_core.js
ui/jquery.ui.widget.js

index b4bb6356dcfd5410e7987fdd2cadded24a4429ad..e104d4ae91e25dc4ca30913de7e6c020d9ed025f 100644 (file)
@@ -82,7 +82,7 @@ test( "custom selector expression", function() {
 });
 
 test( "jQuery usage", function() {
-       expect( 15 );
+       expect( 16 );
 
        var shouldCreate = false;
 
@@ -140,6 +140,9 @@ test( "jQuery usage", function() {
        ret = elem.testWidget( "jQueryObject" );
        equal( ret[ 0 ], document.body, "returned jQuery object" );
        equal( ret.end(), elem, "stack preserved" );
+
+       elem.testWidget( "destroy" );
+       equal( elem.data( "ui-testWidget" ), null );
 });
 
 test( "direct usage", function() {
index d06b2654f0b09fea41b757736bffbcb368bc7aad..17416ff9f39e7fc423a4b83b262e918fe2b7b66d 100644 (file)
@@ -163,9 +163,7 @@ $.widget.bridge = function( name, object ) {
 
                if ( isMethodCall ) {
                        this.each(function() {
-                               // 1.9 BC for #7810
-                               // TODO remove fallback to name
-                               var instance = $.data( this, fullName ) || $.data( this, name );
+                               var instance = $.data( this, fullName );
                                if ( !instance ) {
                                        return $.error( "cannot call methods on " + name + " prior to initialization; " +
                                                "attempted to call method '" + options + "'" );
@@ -183,9 +181,7 @@ $.widget.bridge = function( name, object ) {
                        });
                } else {
                        this.each(function() {
-                               // 1.9 BC for #7810
-                               // TODO remove fallback to name
-                               var instance = $.data( this, fullName ) || $.data( this, name );
+                               var instance = $.data( this, fullName );
                                if ( instance ) {
                                        instance.option( options || {} )._init();
                                } else {
@@ -252,7 +248,7 @@ $.Widget.prototype = {
                // all event bindings should go through this._bind()
                this.element
                        .unbind( "." + this.widgetName )
-                       .removeData( this.widgetName );
+                       .removeData( this.widgetFullName );
                this.widget()
                        .unbind( "." + this.widgetName )
                        .removeAttr( "aria-disabled" )