@@ -17,7 +17,7 @@ function getProperty (definition, k, isClassDescriptor)
1717 def = def . value ;
1818 }
1919
20- // This might be a regular property, or it may be a getter/ setter the user defined in a class.
20+ // This might be a regular property, or it may be a getter / setter the user defined in a class.
2121 if ( def && hasGetterOrSetter ( def ) )
2222 {
2323 if ( typeof def . enumerable === 'undefined' )
@@ -34,7 +34,14 @@ function getProperty (definition, k, isClassDescriptor)
3434 }
3535 else
3636 {
37- return false ;
37+ // if (typeof definition[k] === 'object')
38+ // {
39+ // return -1;
40+ // }
41+ // else
42+ // {
43+ return false ;
44+ // }
3845 }
3946}
4047
@@ -60,7 +67,7 @@ function hasNonConfigurable (obj, k)
6067 return false ;
6168}
6269
63- function extend ( ctor , definition , isClassDescriptor , extend )
70+ function extend ( ctor , definition , isClassDescriptor , extendCallback )
6471{
6572 for ( var k in definition )
6673 {
@@ -69,13 +76,78 @@ function extend (ctor, definition, isClassDescriptor, extend)
6976 continue ;
7077 }
7178
79+ if ( typeof definition [ k ] === 'object' )
80+ {
81+ // Here goes nothing ...
82+ extend ( ctor , def , false , extendCallback ) ;
83+ }
84+
7285 var def = getProperty ( definition , k , isClassDescriptor ) ;
7386
74- if ( def !== false )
87+ // Object ...
88+
89+ if ( def === - 1 )
90+ {
91+ console . log ( k , def ) ;
92+
93+ // Iterate the object, and see if any children are getters / setters
94+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
95+
96+ def = definition [ k ] ;
97+
98+ var entry = { } ;
99+
100+ entry [ k ] = { } ;
101+
102+ // ctor.prototype[k] = {};
103+ // Object.defineProperty(ctor.prototype, k, { value: {} });
104+
105+ console . log ( 'iterating' , def ) ;
106+
107+ for ( var key in def )
108+ {
109+ var child = def [ key ] ;
110+
111+ console . log ( '->' , key , child ) ;
112+
113+ if ( child && hasGetterOrSetter ( child ) )
114+ {
115+ if ( typeof child . enumerable === 'undefined' )
116+ {
117+ child . enumerable = true ;
118+ }
119+
120+ if ( typeof child . configurable === 'undefined' )
121+ {
122+ child . configurable = true ;
123+ }
124+
125+ Object . defineProperty ( entry [ k ] , key , child ) ;
126+ }
127+ else
128+ {
129+ Object . defineProperty ( entry [ k ] , key , {
130+ value : child ,
131+ writable : true ,
132+ configurable : true ,
133+ enumerable : true
134+ } ) ;
135+
136+ // ctor.prototype[k][key] = { value: child };
137+ }
138+ }
139+
140+ // ctor.prototype[k] = def;
141+
142+ console . dir ( entry ) ;
143+
144+ Object . defineProperties ( ctor . prototype , entry ) ;
145+ }
146+ else if ( def !== false )
75147 {
76148 // If Extends is used, we will check its prototype to see if the final variable exists.
77149
78- var parent = extend || ctor ;
150+ var parent = extendCallback || ctor ;
79151
80152 if ( hasNonConfigurable ( parent . prototype , k ) )
81153 {
@@ -104,6 +176,8 @@ function extend (ctor, definition, isClassDescriptor, extend)
104176
105177function mixin ( myClass , mixins )
106178{
179+ console . log ( myClass ) ;
180+
107181 if ( ! mixins )
108182 {
109183 return ;
0 commit comments