File tree 2 files changed +10
-8
lines changed
2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -166,9 +166,11 @@ test( "direct usage", function() {
166
166
} ) ;
167
167
168
168
test ( "error handling" , function ( ) {
169
- expect ( 2 ) ;
169
+ expect ( 3 ) ;
170
170
var error = $ . error ;
171
- $ . widget ( "ui.testWidget" , { } ) ;
171
+ $ . widget ( "ui.testWidget" , {
172
+ _privateMethod : function ( ) { }
173
+ } ) ;
172
174
$ . error = function ( msg ) {
173
175
equal ( msg , "cannot call methods on testWidget prior to initialization; " +
174
176
"attempted to call method 'missing'" , "method call before init" ) ;
@@ -179,6 +181,11 @@ test( "error handling", function() {
179
181
"invalid method call on widget instance" ) ;
180
182
} ;
181
183
$ ( "<div>" ) . testWidget ( ) . testWidget ( "missing" ) ;
184
+ $ . error = function ( msg ) {
185
+ equal ( msg , "no such method '_privateMethod' for testWidget widget instance" ,
186
+ "invalid method call on widget instance" ) ;
187
+ } ;
188
+ $ ( "<div>" ) . testWidget ( ) . testWidget ( "_privateMethod" ) ;
182
189
$ . error = error ;
183
190
} ) ;
184
191
Original file line number Diff line number Diff line change @@ -104,19 +104,14 @@ $.widget.bridge = function( name, object ) {
104
104
$ . extend . apply ( null , [ true , options ] . concat ( args ) ) :
105
105
options ;
106
106
107
- // prevent calls to internal methods
108
- if ( isMethodCall && options . charAt ( 0 ) === "_" ) {
109
- return returnValue ;
110
- }
111
-
112
107
if ( isMethodCall ) {
113
108
this . each ( function ( ) {
114
109
var instance = $ . data ( this , name ) ;
115
110
if ( ! instance ) {
116
111
return $ . error ( "cannot call methods on " + name + " prior to initialization; " +
117
112
"attempted to call method '" + options + "'" ) ;
118
113
}
119
- if ( ! $ . isFunction ( instance [ options ] ) ) {
114
+ if ( ! $ . isFunction ( instance [ options ] ) || options . charAt ( 0 ) === "_" ) {
120
115
return $ . error ( "no such method '" + options + "' for " + name + " widget instance" ) ;
121
116
}
122
117
var methodValue = instance [ options ] . apply ( instance , args ) ;
You can’t perform that action at this time.
0 commit comments