diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-08-27 14:48:17 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-08-27 14:48:17 -0400 |
commit | 1e28040cf358d0fe81ee83a2e35d7dbb65362afa (patch) | |
tree | 721a02ecfcfb52284e0d55a79ff303a5c98c4787 /ui/jquery.ui.widget.js | |
parent | 52a052be79d21aa519ccb513dc00a7c54868ef03 (diff) | |
download | jquery-ui-1e28040cf358d0fe81ee83a2e35d7dbb65362afa.tar.gz jquery-ui-1e28040cf358d0fe81ee83a2e35d7dbb65362afa.zip |
Widget: Throw errors when calling non-existent methods or methods on uninistantiated widgets. 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.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index ead4af12b..d08dbb81f 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -86,10 +86,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; + 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 ); if ( methodValue !== instance && methodValue !== undefined ) { returnValue = methodValue; return false; |