Skip to content

Commit

Permalink
Widget: Don't throw errors for invalid method calls (wait till 1.9 to…
Browse files Browse the repository at this point in the history
… add this back). Reverts fix for #5972 - Widget: Throw error for non-existent method calls.
  • Loading branch information
scottgonzalez committed Oct 21, 2010
1 parent eab0a6d commit 6ba75aa
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ui/jquery.ui.widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ $.widget.bridge = function( name, object ) {

if ( isMethodCall ) {
this.each(function() {
var instance = $.data( this, name );
if ( !instance ) {
throw "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'";
}
if ( !$.isFunction( instance[options] ) ) {
throw "no such method '" + options + "' for " + name + " widget instance";
}
var methodValue = instance[ options ].apply( instance, args );
var instance = $.data( this, name ),
methodValue = instance && $.isFunction( instance[options] ) ?
instance[ options ].apply( instance, args ) :
instance;
// TODO: add this back in 1.9 and use $.error() (see #5972)
// if ( !instance ) {
// throw "cannot call methods on " + name + " prior to initialization; " +
// "attempted to call method '" + options + "'";
// }
// if ( !$.isFunction( instance[options] ) ) {
// throw "no such method '" + options + "' for " + name + " widget instance";
// }
// var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;
Expand Down

0 comments on commit 6ba75aa

Please sign in to comment.