aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-02-10 21:25:50 -0500
committerScott González <scott.gonzalez@gmail.com>2011-02-10 21:25:50 -0500
commit6096aed0a38948fe02a697d0f5349c6903c90e47 (patch)
tree95943964405e828aa4b9e5a8d244aa4563d82680 /ui
parentfb35d4e5c5638dac72cb53ed37ee240b2fe91f46 (diff)
downloadjquery-ui-6096aed0a38948fe02a697d0f5349c6903c90e47.tar.gz
jquery-ui-6096aed0a38948fe02a697d0f5349c6903c90e47.zip
Widget: Fixed super methods with deep inheritance chains.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.widget.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 6b84f7a9c..27a7cd1b0 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -36,7 +36,9 @@ $.widget = function( name, base, prototype ) {
};
$[ namespace ] = $[ namespace ] || {};
- $[ namespace ][ name ] = $[ namespace ][ name ] || function( options, element ) {
+ // create the constructor using $.extend() so we can carry over any
+ // static properties stored on the existing constructor (if there is one)
+ $[ namespace ][ name ] = $.extend( function( options, element ) {
// allow instantiation without "new" keyword
if ( !this._createWidget ) {
return new $[ namespace ][ name ]( options, element );
@@ -47,19 +49,31 @@ $.widget = function( name, base, prototype ) {
if ( arguments.length ) {
this._createWidget( options, element );
}
- };
+ }, $[ namespace ][ name ] );
var basePrototype = new base();
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
basePrototype.options = $.extend( true, {}, basePrototype.options );
+ $.each( prototype, function( prop, value ) {
+ if ( $.isFunction( value ) ) {
+ prototype[ prop ] = function() {
+ this._super = function( method ) {
+ return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) );
+ };
+ this._superApply = function( method, args ) {
+ return base.prototype[ method ].apply( this, args );
+ };
+ return value.apply( this, arguments );
+ };
+ }
+ });
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
namespace: namespace,
widgetName: name,
widgetEventPrefix: name,
- widgetBaseClass: fullName,
- base: base.prototype
+ widgetBaseClass: fullName
}, prototype );
$.widget.bridge( name, $[ namespace ][ name ] );
@@ -159,13 +173,6 @@ $.Widget.prototype = {
_create: $.noop,
_init: $.noop,
- _super: function( method ) {
- return this.base[ method ].apply( this, slice.call( arguments, 1 ) );
- },
- _superApply: function( method, args ) {
- return this.base[ method ].apply( this, args );
- },
-
destroy: function() {
this._destroy();
// we can probably remove the unbind calls in 2.0