Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: emberjs/ember.js
...
head fork: jbrown/ember.js
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
View
10 packages/ember-views/lib/system/application.js
@@ -89,8 +89,8 @@ Ember.Application = Ember.Namespace.extend(
Example:
- App.PostsController = Ember.ArrayController.create();
- App.CommentsController = Ember.ArrayController.create();
+ App.PostsController = Ember.ArrayController.extend();
+ App.CommentsController = Ember.ArrayController.extend();
var stateManager = Ember.StateManager.create({
...
@@ -105,12 +105,14 @@ Ember.Application = Ember.Namespace.extend(
*/
injectControllers: function(stateManager) {
var properties = Ember.A(Ember.keys(this)),
- namespace = this, controller, name;
+ namespace = this, controller, klass, name;
properties.forEach(function(property) {
if (!/^[A-Z].*Controller$/.test(property)) { return; }
name = property[0].toLowerCase() + property.substr(1);
- controller = namespace[property].create();
+ klass = namespace[property];
+ if (!Ember.Object.detect(klass)) { return; }
+ controller = klass.create();
stateManager.set(name, controller);
controller.set('stateManager', stateManager);
});
View
4 packages/ember-views/tests/system/application_test.js
@@ -75,6 +75,8 @@ test("inject controllers into a state manager", function() {
app.FooController = Ember.Object.extend();
app.BarController = Ember.ArrayController.extend();
+ // instance that uses class naming conventions
+ app.BazController = Ember.ArrayController.create();
app.Foo = Ember.Object.create();
app.fooController = Ember.Object.create();
@@ -84,8 +86,10 @@ test("inject controllers into a state manager", function() {
ok(get(stateManager, 'fooController') instanceof app.FooController, "fooController was assigned");
ok(get(stateManager, 'barController') instanceof app.BarController, "barController was assigned");
+ ok(!get(stateManager, 'bazController'), "existing instances named like classes are not assigned");
ok(get(stateManager, 'foo') === undefined, "foo was not assigned");
equal(getPath(stateManager, 'fooController.stateManager'), stateManager, "the state manager is assigned");
equal(getPath(stateManager, 'barController.stateManager'), stateManager, "the state manager is assigned");
+ ok(!get(app.BazController, "stateManager"), "the state manager is not set on existing instances named like classes");
});

No commit comments for this range

Something went wrong with that request. Please try again.