aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.widget.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2010-12-10 14:11:20 -0500
committerScott González <scott.gonzalez@gmail.com>2010-12-10 14:11:20 -0500
commit9ad2a4b1ccebb32cc745be3ef85a4b634e416ff8 (patch)
treeed68f18d4d84f6bd6d021a668ade484f9b7bda93 /ui/jquery.ui.widget.js
parent0e15f573d6f1d5c138ce63d2a462737dbb874faa (diff)
downloadjquery-ui-9ad2a4b1ccebb32cc745be3ef85a4b634e416ff8.tar.gz
jquery-ui-9ad2a4b1ccebb32cc745be3ef85a4b634e416ff8.zip
Widget: Throw errors for invalid method calls. Fixes #5972 - Widget: Throw error for non-existent method calls.
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r--ui/jquery.ui.widget.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index fadf81f2b..0420bc31a 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -96,19 +96,15 @@ $.widget.bridge = function( name, object ) {
if ( isMethodCall ) {
this.each(function() {
- 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 );
+ var instance = $.data( this, name );
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+ if ( !$.isFunction( instance[options] ) ) {
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
+ }
+ var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;