Skip to content

Commit

Permalink
Avoid mutating the shared queryParams array on the prototype.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Sep 30, 2016
1 parent 172d158 commit 09140df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
6 changes: 1 addition & 5 deletions packages/ember-routing/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ export function calculateCacheKey(prefix, _parts, values) {
'Array of fully defined objects' style.
*/
export function normalizeControllerQueryParams(queryParams) {
if (queryParams._qpMap) {
return queryParams._qpMap;
}

let qpMap = queryParams._qpMap = {};
let qpMap = {};

for (let i = 0; i < queryParams.length; ++i) {
accumulateQueryParamDescriptors(queryParams[i], qpMap);
Expand Down
9 changes: 0 additions & 9 deletions packages/ember-routing/tests/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ import {

QUnit.module('Routing query parameter utils - normalizeControllerQueryParams');

QUnit.test('returns the cached value if that has been previously set', function(assert) {
let cached = {};
let params = ['foo'];
params._qpMap = cached;

let normalized = normalizeControllerQueryParams(params);
equal(cached, normalized, 'cached value returned if previously set');
});

QUnit.test('converts array style into verbose object style', function(assert) {
let paramName = 'foo';
let params = [paramName];
Expand Down

0 comments on commit 09140df

Please sign in to comment.