Skip to content

Commit 92bae28

Browse files
committed
Widget: Only create _super and _superApply once per method, then assign on every execution.
1 parent 6096aed commit 92bae28

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ui/jquery.ui.widget.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,19 @@ $.widget = function( name, base, prototype ) {
5858
basePrototype.options = $.extend( true, {}, basePrototype.options );
5959
$.each( prototype, function( prop, value ) {
6060
if ( $.isFunction( value ) ) {
61-
prototype[ prop ] = function() {
62-
this._super = function( method ) {
61+
prototype[ prop ] = (function() {
62+
var _super = function( method ) {
6363
return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) );
6464
};
65-
this._superApply = function( method, args ) {
65+
var _superApply = function( method, args ) {
6666
return base.prototype[ method ].apply( this, args );
6767
};
68-
return value.apply( this, arguments );
69-
};
68+
return function() {
69+
this._super = _super;
70+
this._superApply = _superApply;
71+
return value.apply( this, arguments );
72+
};
73+
}());
7074
}
7175
});
7276
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {

0 commit comments

Comments
 (0)