Skip to content

Commit 6ba75aa

Browse files
committed
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.
1 parent eab0a6d commit 6ba75aa

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ui/jquery.ui.widget.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,19 @@ $.widget.bridge = function( name, object ) {
9696

9797
if ( isMethodCall ) {
9898
this.each(function() {
99-
var instance = $.data( this, name );
100-
if ( !instance ) {
101-
throw "cannot call methods on " + name + " prior to initialization; " +
102-
"attempted to call method '" + options + "'";
103-
}
104-
if ( !$.isFunction( instance[options] ) ) {
105-
throw "no such method '" + options + "' for " + name + " widget instance";
106-
}
107-
var methodValue = instance[ options ].apply( instance, args );
99+
var instance = $.data( this, name ),
100+
methodValue = instance && $.isFunction( instance[options] ) ?
101+
instance[ options ].apply( instance, args ) :
102+
instance;
103+
// TODO: add this back in 1.9 and use $.error() (see #5972)
104+
// if ( !instance ) {
105+
// throw "cannot call methods on " + name + " prior to initialization; " +
106+
// "attempted to call method '" + options + "'";
107+
// }
108+
// if ( !$.isFunction( instance[options] ) ) {
109+
// throw "no such method '" + options + "' for " + name + " widget instance";
110+
// }
111+
// var methodValue = instance[ options ].apply( instance, args );
108112
if ( methodValue !== instance && methodValue !== undefined ) {
109113
returnValue = methodValue;
110114
return false;

0 commit comments

Comments
 (0)