Skip to content

Commit

Permalink
Added namespace defaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
add0n committed Dec 11, 2012
1 parent 4860ee4 commit 698471f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lib/mojito-yaf.js
Expand Up @@ -24,16 +24,29 @@ YUI.add('mojito-yaf', function (Y, NAME) {
registerMojitInstance: function (instanceName, appObj) {
var mojitTypeName,
parts,

mojitNS,
mojitCN,

mojitType,
mojitInst;

// Had a key but there's no data
if (!(mojitTypeName = this.get('mojitData')[instanceName])) {
return;
}

parts = mojitTypeName.split('.');

if (!(mojitType = Y.namespace(parts[0])[parts[1]])) {
if (parts.length == 1) {
mojitNS = 'mojito';
mojitCN = parts[0];
} else if (parts.length == 2) {
mojitNS = parts[0];
mojitCN = parts[1];
}

if (!(mojitType = Y.namespace(mojitNS)[mojitCN])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test.html
Expand Up @@ -61,7 +61,7 @@
// !TODO! Hardcoded data in lieu of application.json / routes.json
// This is a hack for this test!
var instanceMap = {
'mainMojit' : 'mojito.HTMLMojit',
'mainMojit' : 'HTMLMojit',
'rootMojit' : 'mojito.TestRootMojit',
'msgMojit' : 'mojito.MsgMojit'
};
Expand Down

0 comments on commit 698471f

Please sign in to comment.