From 1cff9f1790d9e3dd7bacc645a81a7a2d265240a9 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 5 Apr 2019 20:50:36 -0700 Subject: [PATCH 1/2] [BUGFIX beta] Failing test for #17869 --- .../link-to/query-params-curly-test.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js index 321a986e1b4..6c3c002e381 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js @@ -69,7 +69,7 @@ moduleFor( '{{link-to}} component with query params (routing)', class extends ApplicationTestCase { constructor() { - super(); + super(...arguments); let indexProperties = { foo: '123', bar: 'abc', @@ -736,5 +736,36 @@ moduleFor( this.shouldBeActive(assert, '#foos-link'); }); } + + ['@test [GH#17869] it does not cause shadowing assertion with `hash` local variable']() { + this.router.map(function() { + this.route('post', { path: '/post/:id' }); + }); + + this.add( + 'controller:post', + Controller.extend({ + queryParams: ['showComments'], + showComments: true, + }) + ); + + this.addTemplate( + 'index', + ` + {{#let (hash id="1" title="Hello World!" body="Lorem ipsum dolor sit amet...") as |hash|}} + {{#link-to "post" hash (query-params showComments=false)}}View Post{{/link-to}} + {{/let}} + ` + ); + + return this.visit('/').then(() => { + this.assertComponentElement(this.element.firstElementChild, { + tagName: 'a', + attrs: { href: '/post/1?showComments=false', class: classMatcher('ember-view') }, + content: 'View Post', + }); + }); + } } ); From a39819fc8f8dc73f2cfc86db92da09921625edc3 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 5 Apr 2019 21:06:14 -0700 Subject: [PATCH 2/2] [BUGFIX beta] Fix #17869 (link-to causing `hash` local variable assertions) This doesn't really "fix" the issue, it just silent this particular assertion basically. This is ok, because the test will fail when we implement the "everything is a value" semantics, at which point we can fix it by renaming the hash helper. (We could fix it now by renaming the offending hash local variable too, but that would be pretty difficult to do correctly.) Closes #17869. --- packages/ember-template-compiler/lib/plugins/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ember-template-compiler/lib/plugins/index.ts b/packages/ember-template-compiler/lib/plugins/index.ts index 6667b39c4bc..dbd5f1aff36 100644 --- a/packages/ember-template-compiler/lib/plugins/index.ts +++ b/packages/ember-template-compiler/lib/plugins/index.ts @@ -23,7 +23,6 @@ export type APluginFunc = (env: ASTPluginEnvironment) => ASTPlugin | undefined; const transforms: Array = [ TransformComponentInvocation, - TransformLinkTo, TransformOldClassBindingSyntax, TransformQuotedBindingsIntoJustBindings, AssertReservedNamedArguments, @@ -32,6 +31,7 @@ const transforms: Array = [ TransformEachInIntoEach, TransformHasBlockSyntax, AssertLocalVariableShadowingHelperInvocation, + TransformLinkTo, AssertInputHelperWithoutBlock, TransformInElement, AssertIfHelperWithoutArguments,