@@ -25,6 +25,9 @@ $.cleanData = function( elems ) {
25
25
26
26
$ . widget = function ( name , base , prototype ) {
27
27
var fullName , existingConstructor , constructor , basePrototype ,
28
+ // proxiedPrototype allows the provided prototype to remain unmodified
29
+ // so that it can be used as a mixin for multiple widgets (#8876)
30
+ proxiedPrototype = { } ,
28
31
namespace = name . split ( "." ) [ 0 ] ;
29
32
30
33
name = name . split ( "." ) [ 1 ] ;
@@ -71,38 +74,40 @@ $.widget = function( name, base, prototype ) {
71
74
// inheriting from
72
75
basePrototype . options = $ . widget . extend ( { } , basePrototype . options ) ;
73
76
$ . each ( prototype , function ( prop , value ) {
74
- if ( $ . isFunction ( value ) ) {
75
- prototype [ prop ] = ( function ( ) {
76
- var _super = function ( ) {
77
- return base . prototype [ prop ] . apply ( this , arguments ) ;
78
- } ,
79
- _superApply = function ( args ) {
80
- return base . prototype [ prop ] . apply ( this , args ) ;
81
- } ;
82
- return function ( ) {
83
- var __super = this . _super ,
84
- __superApply = this . _superApply ,
85
- returnValue ;
86
-
87
- this . _super = _super ;
88
- this . _superApply = _superApply ;
89
-
90
- returnValue = value . apply ( this , arguments ) ;
91
-
92
- this . _super = __super ;
93
- this . _superApply = __superApply ;
94
-
95
- return returnValue ;
96
- } ;
97
- } ) ( ) ;
77
+ if ( ! $ . isFunction ( value ) ) {
78
+ proxiedPrototype [ prop ] = value ;
79
+ return ;
98
80
}
81
+ proxiedPrototype [ prop ] = ( function ( ) {
82
+ var _super = function ( ) {
83
+ return base . prototype [ prop ] . apply ( this , arguments ) ;
84
+ } ,
85
+ _superApply = function ( args ) {
86
+ return base . prototype [ prop ] . apply ( this , args ) ;
87
+ } ;
88
+ return function ( ) {
89
+ var __super = this . _super ,
90
+ __superApply = this . _superApply ,
91
+ returnValue ;
92
+
93
+ this . _super = _super ;
94
+ this . _superApply = _superApply ;
95
+
96
+ returnValue = value . apply ( this , arguments ) ;
97
+
98
+ this . _super = __super ;
99
+ this . _superApply = __superApply ;
100
+
101
+ return returnValue ;
102
+ } ;
103
+ } ) ( ) ;
99
104
} ) ;
100
105
constructor . prototype = $ . widget . extend ( basePrototype , {
101
106
// TODO: remove support for widgetEventPrefix
102
107
// always use the name + a colon as the prefix, e.g., draggable:start
103
108
// don't prefix for widgets that aren't DOM-based
104
109
widgetEventPrefix : existingConstructor ? basePrototype . widgetEventPrefix : name
105
- } , prototype , {
110
+ } , proxiedPrototype , {
106
111
constructor : constructor ,
107
112
namespace : namespace ,
108
113
widgetName : name ,
0 commit comments