File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,11 @@ export default class Model {
116116 static $newproto ( classKey , classProps , className ) {
117117 const proto = { } ;
118118
119+ // Set className alias
120+ if ( className ) {
121+ Model . alias [ className ] = classKey ;
122+ }
123+
119124 // $className property
120125 Object . defineProperty ( proto , '$className' , {
121126 value : className || classKey ,
@@ -383,14 +388,15 @@ export default class Model {
383388 }
384389
385390 static $castobject ( value , model ) {
386- const constructor = Model . constructors [ model ] ;
391+ const classKey = Model . alias [ model ] || model ;
392+ const constructor = Model . constructors [ classKey ] ;
387393 if ( constructor ) {
388394 if ( value instanceof constructor ) {
389395 return value ;
390396 }
391397 return new constructor ( value ) ;
392398 }
393- throw new Error ( `Undefined Model of type ${ model } ` ) ;
399+ throw new Error ( `Undefined Model of type ${ classKey } ` ) ;
394400 }
395401
396402 static $castnumber ( value ) {
@@ -438,6 +444,7 @@ export default class Model {
438444// GLOBALS
439445
440446Model . constructors = { } ;
447+ Model . alias = { } ;
441448Model . models = { } ;
442449Model . types = { } ;
443450Model . primitive = Object . freeze ( {
Original file line number Diff line number Diff line change 11{
22 "name" : " @djthorpe/js-framework" ,
3- "version" : " 0.0.24 " ,
3+ "version" : " 0.0.25 " ,
44 "description" : " Javascript Framework" ,
55 "main" : " dist/js/index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments