Widget: Don't throw errors for invalid method calls (wait till 1.9 to add this back). Reverts fix for #5972 - Widget: Throw error for non-existent method calls.

This commit is contained in:
Scott González 2010-10-21 09:52:27 -04:00
parent eab0a6dac1
commit 6ba75aa698

View File

@ -96,15 +96,19 @@ $.widget.bridge = function( name, object ) {
if ( isMethodCall ) { if ( isMethodCall ) {
this.each(function() { this.each(function() {
var instance = $.data( this, name ); var instance = $.data( this, name ),
if ( !instance ) { methodValue = instance && $.isFunction( instance[options] ) ?
throw "cannot call methods on " + name + " prior to initialization; " + instance[ options ].apply( instance, args ) :
"attempted to call method '" + options + "'"; instance;
} // TODO: add this back in 1.9 and use $.error() (see #5972)
if ( !$.isFunction( instance[options] ) ) { // if ( !instance ) {
throw "no such method '" + options + "' for " + name + " widget instance"; // throw "cannot call methods on " + name + " prior to initialization; " +
} // "attempted to call method '" + options + "'";
var methodValue = instance[ options ].apply( instance, args ); // }
// 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 ) { if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue; returnValue = methodValue;
return false; return false;