Skip to content

Commit

Permalink
Merge pull request #17872 from emberjs/fix-17869
Browse files Browse the repository at this point in the history
[BUGFIX beta] Fix for #17869 (link-to causing `hash` local variable assertions)
  • Loading branch information
chancancode authored Apr 6, 2019
2 parents 8d19759 + a39819f commit b40fdb3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
});
});
}
}
);
2 changes: 1 addition & 1 deletion packages/ember-template-compiler/lib/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type APluginFunc = (env: ASTPluginEnvironment) => ASTPlugin | undefined;

const transforms: Array<APluginFunc> = [
TransformComponentInvocation,
TransformLinkTo,
TransformOldClassBindingSyntax,
TransformQuotedBindingsIntoJustBindings,
AssertReservedNamedArguments,
Expand All @@ -32,6 +31,7 @@ const transforms: Array<APluginFunc> = [
TransformEachInIntoEach,
TransformHasBlockSyntax,
AssertLocalVariableShadowingHelperInvocation,
TransformLinkTo,
AssertInputHelperWithoutBlock,
TransformInElement,
AssertIfHelperWithoutArguments,
Expand Down

0 comments on commit b40fdb3

Please sign in to comment.