diff --git a/packages/ember-glimmer/tests/integration/application/engine-test.js b/packages/ember-glimmer/tests/integration/application/engine-test.js index 2a5a8b25d86..799ac1ab1c3 100644 --- a/packages/ember-glimmer/tests/integration/application/engine-test.js +++ b/packages/ember-glimmer/tests/integration/application/engine-test.js @@ -5,6 +5,7 @@ import { Controller, RSVP } from 'ember-runtime'; import { Component } from 'ember-glimmer'; import { Engine } from 'ember-application'; import { Route } from 'ember-routing'; +import { jQuery } from 'ember-views'; moduleFor('Application test: engine rendering', class extends ApplicationTest { setupAppAndRoutableEngine(hooks = []) { @@ -20,6 +21,7 @@ moduleFor('Application test: engine rendering', class extends ApplicationTest { this.route('comments'); this.route('likes'); }); + this.route('category', {path: 'category/:id'}); }); this.registerRoute('application', Route.extend({ model() { @@ -34,6 +36,9 @@ moduleFor('Application test: engine rendering', class extends ApplicationTest { queryParams: ['lang'], lang: '' })); + this.register('controller:category', Controller.extend({ + queryParams: ['type'], + })); this.register('template:application', compile('Engine{{lang}}{{outlet}}')); this.register('route:application', Route.extend({ model() { @@ -572,4 +577,18 @@ moduleFor('Application test: engine rendering', class extends ApplicationTest { }); }); } + + ['@test query params don\'t have stickiness by default between model'](assert) { + assert.expect(1); + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function() { + this.register('template:category', compile('{{#link-to "blog.category" 1337}}Category 1337{{/link-to}}')) + }); + + return this.visit('/blog/category/1?type=news').then(() => { + let href = this.element.querySelector('a').href; + assert.equal(href.match(/type=news/), null); + }); + } }); diff --git a/packages/ember-routing/lib/system/route.js b/packages/ember-routing/lib/system/route.js index 3dae41323ba..ba1f66d0974 100644 --- a/packages/ember-routing/lib/system/route.js +++ b/packages/ember-routing/lib/system/route.js @@ -1334,7 +1334,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { let aQp = queryParams.map[prop]; aQp.values = params; - let cacheKey = calculateCacheKey(aQp.controllerName, aQp.parts, aQp.values); + let cacheKey = calculateCacheKey(aQp.route.fullRouteName, aQp.parts, aQp.values); if (cache) { let value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); @@ -1363,7 +1363,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { _qpChanged(prop, value, qp) { if (!qp) { return; } - let cacheKey = calculateCacheKey(qp.controllerName, qp.parts, qp.values); + let cacheKey = calculateCacheKey(qp.route.fullRouteName, qp.parts, qp.values); // Update model-dep cache let cache = this._bucketCache; diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index 00794ace15e..859e44696a1 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -953,7 +953,7 @@ const EmberRouter = EmberObject.extend(Evented, { delete queryParams[presentProp]; } } else { - let cacheKey = calculateCacheKey(qp.controllerName, qp.parts, state.params); + let cacheKey = calculateCacheKey(qp.route.fullRouteName, qp.parts, state.params); queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); } }