@@ -109,58 +109,34 @@ var Base = this.Base = new function() { // Straps scope
109109 // string values starting with '#'
110110 if ( typeof val === 'string' && val [ 0 ] === '#' )
111111 val = src [ val . substring ( 1 ) ] || val ;
112- var func = typeof val === 'function' ,
112+ var isFunc = typeof val === 'function' ,
113113 res = val ,
114114 // Only lookup previous value if we preserve or define a
115115 // function that might need it for this.base(). If we're
116116 // defining a getter, don't lookup previous value, but look if
117117 // the property exists (name in dest) and store result in prev
118- prev = preserve || func
118+ prev = preserve || isFunc
119119 ? ( val && val . get ? name in dest : dest [ name ] ) : null ;
120120 if ( ( dontCheck || val !== undefined && src . hasOwnProperty ( name ) )
121121 && ( ! preserve || ! prev ) ) {
122- if ( func ) {
123- if ( prev && / \b t h i s \. b a s e \b / . test ( val ) ) {
124- var fromBase = base && base [ name ] == prev ;
125- res = function ( ) {
126- // Look up the base function each time if we can,
127- // to reflect changes to the base class after
128- // inheritance.
129- var tmp = describe ( this , 'base' ) ;
130- define ( this , 'base' , { value : fromBase
131- ? base [ name ] : prev , configurable : true } ) ;
132- try {
133- return val . apply ( this , arguments ) ;
134- } finally {
135- tmp ? define ( this , 'base' , tmp )
136- : delete this . base ;
137- }
138- } ;
139- // Make wrapping closure pretend to be the original
140- // function on inspection
141- res . toString = function ( ) {
142- return val . toString ( ) ;
143- } ;
144- res . valueOf = function ( ) {
145- return val . valueOf ( ) ;
146- } ;
147- }
148- // Produce bean properties if getters are specified. This
149- // does not produce properties for setter-only properties.
150- // Just collect beans for now, and look them up in dest at
151- // the end of fields injection. This ensures this.base()
152- // works in beans too, and inherits setters for redefined
153- // getters in subclasses. Only add getter beans if they do
154- // not expect arguments. Functions that should function both
155- // with optional arguments and as beans should not declare
156- // the parameters and use the arguments array internally
157- // instead.
158- if ( beans && val . length === 0
159- && ( bean = name . match ( / ^ ( g e t | i s ) ( ( [ A - Z ] ) ( .* ) ) $ / ) ) )
160- beans . push ( [ bean [ 3 ] . toLowerCase ( ) + bean [ 4 ] , bean [ 2 ] ] ) ;
161- }
122+ // Expose the 'super' function (meaning the one this function is
123+ // overriding) through #base:
124+ if ( isFunc && prev )
125+ val . base = prev ;
126+ // Produce bean properties if getters are specified. This does
127+ // not produce properties for setter-only properties. Just
128+ // collect beans for now, and look them up in dest at the end of
129+ // fields injection. This ensures base works for beans too, and
130+ // inherits setters for redefined getters in subclasses. Only
131+ // add getter beans if they do not expect arguments. Functions
132+ // that should function both with optional arguments and as
133+ // beans should not declare the parameters and use the arguments
134+ // array internally instead.
135+ if ( isFunc && beans && val . length === 0
136+ && ( bean = name . match ( / ^ ( g e t | i s ) ( ( [ A - Z ] ) ( .* ) ) $ / ) ) )
137+ beans . push ( [ bean [ 3 ] . toLowerCase ( ) + bean [ 4 ] , bean [ 2 ] ] ) ;
162138 // No need to look up getter if this is a function already.
163- if ( ! res || func || ! res . get )
139+ if ( ! res || isFunc || ! res . get )
164140 res = { value : res , writable : true } ;
165141 // Only set/change configurable and enumerable if this field is
166142 // configurable
@@ -171,7 +147,7 @@ var Base = this.Base = new function() { // Straps scope
171147 }
172148 define ( dest , name , res ) ;
173149 }
174- if ( generics && func && ( ! preserve || ! generics [ name ] ) ) {
150+ if ( generics && isFunc && ( ! preserve || ! generics [ name ] ) ) {
175151 generics [ name ] = function ( bind ) {
176152 // Do not call Array.slice generic here, as on Safari,
177153 // this seems to confuse scopes (calling another
0 commit comments