Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Mar 27, 2023
1 parent 1441335 commit c873f21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/@glimmer/syntax/lib/get-template-locals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ function tokensFromType(
return;
}

// the tag may be from a yielded object
// example:
// <x.button>
// An ElementNode does not parse the "tag" in to a PathExpression
// so we have to split on `.`, just like how `this` presence is checked.
if (tag.indexOf('.') !== -1) {
let [potentialLocal] = tag.split('.');

if (scopedTokens.indexOf(potentialLocal) === -1) {
return;
}
}

if (scopedTokens.indexOf(tag) !== -1) {
return;
}
Expand Down
12 changes: 12 additions & 0 deletions packages/@glimmer/syntax/test/template-locals-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ QUnit.test('it does not include locals', function (assert) {
assert.deepEqual(locals, ['SomeComponent']);
});

QUnit.test('it can include object-locals', function (assert) {
let locals = getTemplateLocals(
`
<SomeComponent as |b|>
<b.button />
</SomeComponent>
`
);

assert.deepEqual(locals, ['SomeComponent']);
});

QUnit.test('it can include keywords', function (assert) {
let locals = getTemplateLocals(
`
Expand Down

0 comments on commit c873f21

Please sign in to comment.