Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix for #17869 (link-to causing hash local variable assertions) #17872

Merged
merged 2 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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