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

Ensure components + helpers can work from this paths with staticComponents = true & staticHelpers = true #1017

Merged
merged 5 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions packages/compat/src/resolver-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export function makeResolverTransform(resolver: Resolver) {
if (scopeStack.inScope(node.path.parts[0])) {
return;
}
if (node.path.this === true) {
return;
}
if (node.path.parts.length > 1) {
// paths with a dot in them (which therefore split into more than
// one "part") are classically understood by ember to be contextual
Expand Down Expand Up @@ -80,6 +83,9 @@ export function makeResolverTransform(resolver: Resolver) {
if (scopeStack.inScope(node.path.parts[0])) {
return;
}
if (node.path.this === true) {
return;
}
if (node.path.parts.length > 1) {
// paths with a dot in them (which therefore split into more than
// one "part") are classically understood by ember to be contextual
Expand Down
14 changes: 14 additions & 0 deletions packages/compat/tests/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,20 @@ describe('compat-resolver', function () {
let findDependencies = configure({ staticHelpers: true });
expect(findDependencies('templates/application.hbs', `{{(this.myHelper 42)}}`)).toEqual([]);
});
test('class defined component not failing if there is no arguments', function () {
let findDependencies = configure({ staticComponents: true, staticHelpers: true });
expect(findDependencies('templates/application.hbs', `{{this.myComponent}}`)).toEqual([]);
});
thoov marked this conversation as resolved.
Show resolved Hide resolved
test('class defined component not failing if there is a block', function () {
let findDependencies = configure({ staticComponents: true, staticHelpers: true });
expect(findDependencies('templates/application.hbs', `{{#this.myComponent}}hello{{/this.myComponent}}`)).toEqual(
[]
);
});
test('class defined component not failing with arguments', function () {
let findDependencies = configure({ staticComponents: true, staticHelpers: true });
expect(findDependencies('templates/application.hbs', `{{#this.myComponent 42}}{{/this.myComponent}}`)).toEqual([]);
});
test('mustache missing, no args', function () {
let findDependencies = configure({
staticComponents: true,
Expand Down