From a0580d2d382b8c790e90059adcc44ce9671faa40 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 13 Jan 2021 19:46:27 -0500 Subject: [PATCH] [BUGFIX release] Ensure query param only are properly scoped in engines. Prior to this change, the test would fail with the following: ``` Assertion Failed: You attempted to generate a link for the "UNDEFINED" route, but did not pass the models required for generating its dynamic segments. There is no route named blog.blog.category at assert (http://localhost:7020/tests/ember.js:32996:15) at Class.computeLinkToComponentHref (http://localhost:7020/tests/ember.js:5808:50) at http://localhost:7020/tests/ember.js:11860:25 at untrack (http://localhost:7020/tests/ember.js:54650:14) at ComputedProperty.get (http://localhost:7020/tests/ember.js:11859:32) at Class.getter [as href] (http://localhost:7020/tests/ember.js:10949:25) at getPossibleMandatoryProxyValue (http://localhost:7020/tests/ember.js:11250:19) at _getProp (http://localhost:7020/tests/ember.js:11315:17) at http://localhost:7020/tests/ember.js:45192:45 at http://localhost:7020/tests/ember.js:45140:37 ``` This is because inside a QP only transition we always use `_currentRoute` which has **already been namespaced**. --- .../glimmer/lib/components/link-to.ts | 3 ++- .../integration/application/engine-test.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/@ember/-internals/glimmer/lib/components/link-to.ts b/packages/@ember/-internals/glimmer/lib/components/link-to.ts index 1376eba4ba3..a1d8267bb60 100644 --- a/packages/@ember/-internals/glimmer/lib/components/link-to.ts +++ b/packages/@ember/-internals/glimmer/lib/components/link-to.ts @@ -517,7 +517,8 @@ const LinkComponent = EmberComponent.extend({ _route: computed('route', '_currentRouterState', function computeLinkToComponentRoute(this: any) { let { route } = this; - return this._namespaceRoute(route === UNDEFINED ? this._currentRoute : route); + + return route === UNDEFINED ? this._currentRoute : this._namespaceRoute(route); }), _models: computed('model', 'models', function computeLinkToComponentModels(this: any) { diff --git a/packages/@ember/-internals/glimmer/tests/integration/application/engine-test.js b/packages/@ember/-internals/glimmer/tests/integration/application/engine-test.js index 5104cc5591d..2ceadc86064 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/application/engine-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/application/engine-test.js @@ -890,6 +890,25 @@ moduleFor( }); } + '@test query params only transitions work properly'(assert) { + assert.expect(1); + + let tmpl = 'News'; + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:category', compile(tmpl)); + }); + + return this.visit('/blog/category/1').then(() => { + let suffix = '/blog/category/1?type=news'; + let href = this.element.querySelector('a').href; + + // check if link ends with the suffix + assert.ok(this.stringsEndWith(href, suffix)); + }); + } + async ['@test query params in customized controllerName have stickiness by default between model']( assert ) {