diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 8102b1f4fa8..4aed98fd435 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -375,6 +375,37 @@ test( "inheritance", function() {
delete $.ui.testWidgetExtension;
});
+test( "private methods", function() {
+ expect( 4 );
+
+ $.widget( "ui.testWidgetBase", {
+ publicBase: function() {
+ deepEqual("a", this._private("__private"), "private method call");
+ deepEqual("b", this._protected(), "protected method call");
+ },
+ _protected: function() { return "a"; },
+ __private: function() { return "a"; }
+ });
+
+ $.widget( "ui.testWidgetExtension", $.ui.testWidgetBase, {
+ publicExt: function() {
+ deepEqual("b", this._private("__private"), "private method call");
+ deepEqual("b", this._protected(), "protected method call");
+ },
+ _protected: function() { return "b"; },
+ __private: function() { return "b"; }
+ });
+
+ var instance = $( "
" ).testWidgetExtension();
+ instance.testWidgetExtension("publicBase");
+ instance.testWidgetExtension("publicExt");
+
+ delete $.ui.testWidgetBase;
+ delete $.ui.testWidgetExtension;
+ delete $.fn.testWidgetBase;
+ delete $.fn.testWidgetExtension;
+});
+
test( "._super()", function() {
expect( 9 );
var instance;
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index af1acb02b2f..124d89254d1 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -428,7 +428,7 @@ $.widget( "ui.autocomplete", {
return function( content ) {
if ( index === requestIndex ) {
- that.__response( content );
+ that._real_response( content );
}
that.pending--;
@@ -438,7 +438,7 @@ $.widget( "ui.autocomplete", {
};
},
- __response: function( content ) {
+ _real_response: function( content ) {
if ( content ) {
content = this._normalize( content );
}
@@ -596,7 +596,7 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
}
},
- __response: function( content ) {
+ _real_response: function( content ) {
var message;
this._superApply( arguments );
if ( this.options.disabled || this.cancelSearch ) {
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index c581e4b8156..a2e8ccc8145 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -28,6 +28,7 @@ $.widget = function( name, base, prototype ) {
// proxiedPrototype allows the provided prototype to remain unmodified
// so that it can be used as a mixin for multiple widgets (#8876)
proxiedPrototype = {},
+ privatePrototype = {},
namespace = name.split( "." )[ 0 ];
name = name.split( "." )[ 1 ];
@@ -78,29 +79,40 @@ $.widget = function( name, base, prototype ) {
proxiedPrototype[ prop ] = value;
return;
}
- proxiedPrototype[ prop ] = (function() {
+ var func = (function() {
var _super = function() {
return base.prototype[ prop ].apply( this, arguments );
},
_superApply = function( args ) {
return base.prototype[ prop ].apply( this, args );
+ },
+ _private = function(prop) {
+ return privatePrototype[ prop ].apply(this, slice.call(arguments, 1));
};
return function() {
var __super = this._super,
__superApply = this._superApply,
+ __private = this._private,
returnValue;
this._super = _super;
this._superApply = _superApply;
+ this._private = _private;
returnValue = value.apply( this, arguments );
this._super = __super;
this._superApply = __superApply;
+ this._private = __private;
return returnValue;
};
})();
+ if (prop.indexOf("__") === 0) {
+ privatePrototype[prop] = func;
+ } else {
+ proxiedPrototype[ prop ] = func;
+ }
});
constructor.prototype = $.widget.extend( basePrototype, {
// TODO: remove support for widgetEventPrefix