Skip to content

Commit

Permalink
Merge pull request #11878 from machty/qp-object-prototype-clash-fix
Browse files Browse the repository at this point in the history
[BUGFIX beta] QP routes named after Obj.prototype props should work
  • Loading branch information
rwjblue committed Jul 24, 2015
2 parents 708d335 + 2793173 commit 82b123c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/ember-application/lib/system/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ export default EmberObject.extend({
resolveTemplate(parsedName) {
var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/');

if (Ember.TEMPLATES[templateName]) {
if (Ember.TEMPLATES.hasOwnProperty(templateName)) {
return Ember.TEMPLATES[templateName];
}

templateName = decamelize(templateName);
if (Ember.TEMPLATES[templateName]) {
if (Ember.TEMPLATES.hasOwnProperty(templateName)) {
return Ember.TEMPLATES[templateName];
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var EmberRouter = EmberObject.extend(Evented, {

init() {
this._activeViews = {};
this._qpCache = {};
this._qpCache = Object.create(null);
this._resetQueuedQueryParameterChanges();
},

Expand Down
25 changes: 25 additions & 0 deletions packages/ember/tests/routing/query_params_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3079,3 +3079,28 @@ QUnit.test('warn user that routes query params configuration must be an Object,
bootApplication();
}, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array');
});

QUnit.test('handle routes names that class with Object.prototype properties', function() {
expect(1);

Router.map(function() {
this.route('constructor');
});

App.ConstructorRoute = Ember.Route.extend({
queryParams: {
foo: {
defaultValue: '123'
}
}
});

bootApplication();

Ember.run(router, 'transitionTo', 'constructor', { queryParams: { foo: '999' } });

var controller = container.lookup('controller:constructor');
equal(get(controller, 'foo'), '999');
});


0 comments on commit 82b123c

Please sign in to comment.