@@ -44,24 +44,29 @@ Traits.prototype = {
4444 } ,
4545
4646 _applyTo : function ( subject , options ) {
47- var type = this . _configName ,
47+ var me = this ,
48+ type = me . _configName ,
4849 o = { } ,
49- key , tp , excluded , aliases , t ;
50+ tp , excluded , aliases , t ;
5051
51- if ( this . _isApplicable ( options ) ) {
52+ if ( me . _isApplicable ( options ) ) {
5253 o [ type ] = options ;
53- return this . _applyTo ( subject , o ) ;
54+ return me . _applyTo ( subject , o ) ;
5455 }
5556
5657 excluded = [ ] . concat ( options . excludes ) ;
5758 aliases = options . alias || { } ;
5859 t = options [ type ] ;
5960 tp = t . prototype || t ;
6061
61- for ( key in tp ) {
62- this . _raiseErrorIfItIsState ( key , tp ) ;
63- this . _applyIfNotExcluded ( key , excluded , aliases , subject , tp ) ;
64- }
62+ Object . getOwnPropertyNames ( tp )
63+ . filter ( function ( key ) {
64+ return ! key . match ( / ^ (?: c o n s t r u c t o r | p r o t o t y p e | a r g u m e n t s | c a l l e r | n a m e | b i n d | c a l l | a p p l y | t o S t r i n g | l e n g t h ) $ / ) ;
65+ } )
66+ . forEach ( function ( key ) {
67+ me . _raiseErrorIfItIsState ( key , tp ) ;
68+ me . _applyIfNotExcluded ( key , excluded , aliases , subject , tp ) ;
69+ } ) ;
6570 } ,
6671
6772 _applyIfNotExcluded : function ( key , excluded , aliases , subject , tp ) {
@@ -72,7 +77,7 @@ Traits.prototype = {
7277 this . _raiseErrorIfConflict ( alias , subject , tp ) ;
7378
7479 if ( ! subject [ alias ] || subject [ alias ] === Requires . requiredMethod ) {
75- subject [ alias ] = tp [ key ] ;
80+ Object . defineProperty ( subject , alias , Object . getOwnPropertyDescriptor ( tp , key ) ) ;
7681 }
7782 }
7883 } ,
0 commit comments