Skip to content
Open
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
36 changes: 36 additions & 0 deletions packages/lit-analyzer/src/test/indexer/index-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,42 @@ tsTest("Attribute references can reference properties defined in `observedAttrib
});
});

tsTest("Attribute references can reference properties defined with a @property decorator", t => {
const { indexEntries, sourceFile } = getIndexEntries([
{
fileName: "main.ts",
entry: true,
text: `
class SomeElement extends HTMLElement {
@property({ attribute: "some-attr") someAttr: string;
}
customElements.define('some-element', SomeElement);

declare global {
interface HTMLElementTagNameMap {
'some-element': SomeElement;
}
}

const html = x => x;
html\`<some-element some-attr="abc"></some-element>\`;
`
}
]);

const entries = Array.from(indexEntries).filter(entry => entry.kind === "ATTRIBUTE-REFERENCE");
t.is(entries.length, 1);

assertIsAttrRefTargetingClass({
t,
entry: entries[0],
name: "some-attr",
kind: HtmlNodeAttrKind.ATTRIBUTE,
sourceFile,
className: "SomeElement"
});
});

tsTest("Boolean attribute references have the right kind.", t => {
const { indexEntries, sourceFile } = getIndexEntries([
{
Expand Down