Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix namespaced resolves for all types #92

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/ember-resolver-spade.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ember-resolver-tests.js

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions dist/ember-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,30 @@ define("ember/resolver",

if (fullName.parsedName === true) { return fullName; }

var prefixParts = fullName.split('@');
var prefix;
var prefix, type, name;
var fullNameParts = fullName.split('@');

if (prefixParts.length === 2) {
if (prefixParts[0].split(':')[0] === 'view') {
prefixParts[0] = prefixParts[0].split(':')[1];
prefixParts[1] = 'view:' + prefixParts[1];
}
if (fullNameParts.length === 2) {
var prefixParts = fullNameParts[0].split(':');

if (prefixParts.length === 2) {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
} else {
var nameParts = fullNameParts[1].split(':');

prefix = prefixParts[0];
prefix = fullNameParts[0];
type = nameParts[0];
name = nameParts[1];
}
} else {
fullNameParts = fullName.split(':');
type = fullNameParts[0];
name = fullNameParts[1];
}

var nameParts = prefixParts[prefixParts.length - 1].split(":");
var type = nameParts[0], fullNameWithoutType = nameParts[1];
var name = fullNameWithoutType;
var fullNameWithoutType = name;
var namespace = get(this, 'namespace');
var root = namespace;

Expand Down
2 changes: 1 addition & 1 deletion dist/ember-resolver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions dist/ember-resolver.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,30 @@ define("ember/resolver",

if (fullName.parsedName === true) { return fullName; }

var prefixParts = fullName.split('@');
var prefix;
var prefix, type, name;
var fullNameParts = fullName.split('@');

if (prefixParts.length === 2) {
if (prefixParts[0].split(':')[0] === 'view') {
prefixParts[0] = prefixParts[0].split(':')[1];
prefixParts[1] = 'view:' + prefixParts[1];
}
if (fullNameParts.length === 2) {
var prefixParts = fullNameParts[0].split(':');

if (prefixParts.length === 2) {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
} else {
var nameParts = fullNameParts[1].split(':');

prefix = prefixParts[0];
prefix = fullNameParts[0];
type = nameParts[0];
name = nameParts[1];
}
} else {
fullNameParts = fullName.split(':');
type = fullNameParts[0];
name = fullNameParts[1];
}

var nameParts = prefixParts[prefixParts.length - 1].split(":");
var type = nameParts[0], fullNameWithoutType = nameParts[1];
var name = fullNameWithoutType;
var fullNameWithoutType = name;
var namespace = get(this, 'namespace');
var root = namespace;

Expand Down
32 changes: 32 additions & 0 deletions dist/modules/ember-resolver-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ test("can lookup something in another namespace", function(){
adapter();
});

test("can lookup something in another namespace with different syntax", function(){
expect(2);

define('other/adapters/post', [], function(){
ok(true, "adapter was invoked properly");

return Ember.K;
});

var adapter = resolver.resolve('adapter:other@post');

ok(adapter, 'adapter was returned');

adapter();
});

test("can lookup a view in another namespace", function() {
expect(2);

Expand All @@ -205,6 +221,22 @@ test("can lookup a view in another namespace", function() {
return Ember.K;
});

var view = resolver.resolve('other@view:post');

ok(view, 'view was returned');

view();
});

test("can lookup a view in another namespace with different syntax", function() {
expect(2);

define('other/views/post', [], function(){
ok(true, "view was invoked properly");

return Ember.K;
});

var view = resolver.resolve('view:other@post');

ok(view, 'view was returned');
Expand Down
31 changes: 20 additions & 11 deletions dist/modules/ember-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,30 @@ define("ember/resolver",

if (fullName.parsedName === true) { return fullName; }

var prefixParts = fullName.split('@');
var prefix;
var prefix, type, name;
var fullNameParts = fullName.split('@');

if (prefixParts.length === 2) {
if (prefixParts[0].split(':')[0] === 'view') {
prefixParts[0] = prefixParts[0].split(':')[1];
prefixParts[1] = 'view:' + prefixParts[1];
}
if (fullNameParts.length === 2) {
var prefixParts = fullNameParts[0].split(':');

if (prefixParts.length === 2) {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
} else {
var nameParts = fullNameParts[1].split(':');

prefix = prefixParts[0];
prefix = fullNameParts[0];
type = nameParts[0];
name = nameParts[1];
}
} else {
fullNameParts = fullName.split(':');
type = fullNameParts[0];
name = fullNameParts[1];
}

var nameParts = prefixParts[prefixParts.length - 1].split(":");
var type = nameParts[0], fullNameWithoutType = nameParts[1];
var name = fullNameWithoutType;
var fullNameWithoutType = name;
var namespace = get(this, 'namespace');
var root = namespace;

Expand Down
31 changes: 20 additions & 11 deletions packages/ember-resolver/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,30 @@ define("ember/resolver",

if (fullName.parsedName === true) { return fullName; }

var prefixParts = fullName.split('@');
var prefix;
var prefix, type, name;
var fullNameParts = fullName.split('@');

if (prefixParts.length === 2) {
if (prefixParts[0].split(':')[0] === 'view') {
prefixParts[0] = prefixParts[0].split(':')[1];
prefixParts[1] = 'view:' + prefixParts[1];
}
if (fullNameParts.length === 2) {
var prefixParts = fullNameParts[0].split(':');

if (prefixParts.length === 2) {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
} else {
var nameParts = fullNameParts[1].split(':');

prefix = prefixParts[0];
prefix = fullNameParts[0];
type = nameParts[0];
name = nameParts[1];
}
} else {
fullNameParts = fullName.split(':');
type = fullNameParts[0];
name = fullNameParts[1];
}

var nameParts = prefixParts[prefixParts.length - 1].split(":");
var type = nameParts[0], fullNameWithoutType = nameParts[1];
var name = fullNameWithoutType;
var fullNameWithoutType = name;
var namespace = get(this, 'namespace');
var root = namespace;

Expand Down
32 changes: 32 additions & 0 deletions packages/ember-resolver/tests/core_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ test("can lookup something in another namespace", function(){
adapter();
});

test("can lookup something in another namespace with different syntax", function(){
expect(2);

define('other/adapters/post', [], function(){
ok(true, "adapter was invoked properly");

return Ember.K;
});

var adapter = resolver.resolve('adapter:other@post');

ok(adapter, 'adapter was returned');

adapter();
});

test("can lookup a view in another namespace", function() {
expect(2);

Expand All @@ -94,6 +110,22 @@ test("can lookup a view in another namespace", function() {
return Ember.K;
});

var view = resolver.resolve('other@view:post');

ok(view, 'view was returned');

view();
});

test("can lookup a view in another namespace with different syntax", function() {
expect(2);

define('other/views/post', [], function(){
ok(true, "view was invoked properly");

return Ember.K;
});

var view = resolver.resolve('view:other@post');

ok(view, 'view was returned');
Expand Down