diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-01 14:30:02 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-01 14:30:02 +0100 |
commit | 5fda4f6828ad523bd0692b76f903010a458fcac4 (patch) | |
tree | 1f96468e23776b7ce7a7de3bef294582cac9e584 /ui/jquery.ui.widget.js | |
parent | 45ca20fa33204e2304295f2fb194f59c821b1512 (diff) | |
download | jquery-ui-5fda4f6828ad523bd0692b76f903010a458fcac4.tar.gz jquery-ui-5fda4f6828ad523bd0692b76f903010a458fcac4.zip |
Update data naming for Widget, including backwards compability. Updated tests and added one for the custom expression. Partial fix for #7810
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r-- | ui/jquery.ui.widget.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 2d48ae26d..d11f993c6 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -36,7 +36,7 @@ $.widget = function( name, base, prototype ) { // create selector for plugin $.expr[ ":" ][ fullName ] = function( elem ) { - return !!$.data( elem, name ); + return !!$.data( elem, fullName ); }; $[ namespace ] = $[ namespace ] || {}; @@ -148,6 +148,7 @@ $.widget.extend = function( target ) { }; $.widget.bridge = function( name, object ) { + var fullName = object.prototype.widgetBaseClass; $.fn[ name ] = function( options ) { var isMethodCall = typeof options === "string", args = slice.call( arguments, 1 ), @@ -160,7 +161,9 @@ $.widget.bridge = function( name, object ) { if ( isMethodCall ) { this.each(function() { - var instance = $.data( this, name ); + // 1.9 BC for #7810 + // TODO remove fallback to name + var instance = $.data( this, fullName ) || $.data( this, name ); if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); @@ -178,7 +181,9 @@ $.widget.bridge = function( name, object ) { }); } else { this.each(function() { - var instance = $.data( this, name ); + // 1.9 BC for #7810 + // TODO remove fallback to name + var instance = $.data( this, fullName ) || $.data( this, name ); if ( instance ) { instance.option( options || {} )._init(); } else { @@ -217,7 +222,10 @@ $.Widget.prototype = { this.focusable = $(); if ( element !== this ) { + // 1.9 BC for #7810 + // TODO remove dual storage $.data( element, this.widgetName, this ); + $.data( element, this.widgetBaseClass, this ); this._bind({ remove: "destroy" }); this.document = $( element.style ? // element within the document |