Skip to content

Commit

Permalink
Merge pull request #1017 from thoov/handle-static-getter-components
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Nov 11, 2021
2 parents ff97e7e + a5e1027 commit dcd4eaa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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('helper defined in component not failing if there is no arguments', function () {
let findDependencies = configure({ staticComponents: true, staticHelpers: true });
expect(findDependencies('templates/application.hbs', `{{#if (this.myHelper)}}{{/if}}`)).toEqual([]);
});
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

0 comments on commit dcd4eaa

Please sign in to comment.