Skip to content

Commit

Permalink
Widget: Only create _super and _superApply once per method, then assi…
Browse files Browse the repository at this point in the history
…gn on every execution.
  • Loading branch information
scottgonzalez committed Feb 11, 2011
1 parent 6096aed commit 92bae28
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ui/jquery.ui.widget.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ $.widget = function( name, base, prototype ) {
basePrototype.options = $.extend( true, {}, basePrototype.options ); basePrototype.options = $.extend( true, {}, basePrototype.options );
$.each( prototype, function( prop, value ) { $.each( prototype, function( prop, value ) {
if ( $.isFunction( value ) ) { if ( $.isFunction( value ) ) {
prototype[ prop ] = function() { prototype[ prop ] = (function() {
this._super = function( method ) { var _super = function( method ) {
return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) ); return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) );
}; };
this._superApply = function( method, args ) { var _superApply = function( method, args ) {
return base.prototype[ method ].apply( this, args ); return base.prototype[ method ].apply( this, args );
}; };
return value.apply( this, arguments ); return function() {
}; this._super = _super;
this._superApply = _superApply;
return value.apply( this, arguments );
};
}());
} }
}); });
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, { $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
Expand Down

0 comments on commit 92bae28

Please sign in to comment.