Skip to content

Commit

Permalink
add regression test and fix self closing custom-element in another test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJakubowicz committed Jan 8, 2024
1 parent e0bda3c commit 53f7b56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tsTest("Cannot assign 'undefined' in attribute binding", t => {
tsTest("Can assign 'undefined' in property binding", t => {
const { diagnostics } = getDiagnostics([
makeElement({ slots: ["foo: number | undefined"] }),
'html`<my-element .foo="${{} as number | undefined}" />`'
'html`<my-element .foo="${{} as number | undefined}"></my-element>`'
]);
hasNoDiagnostics(t, diagnostics);
});
Expand Down
8 changes: 8 additions & 0 deletions packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ tsTest("Report unclosed 'p' tag that is implicitly closed via tag omission conta
hasDiagnostic(t, diagnostics, "no-unclosed-tag");
});

// Regeression test for https://github.com/runem/lit-analyzer/issues/283
tsTest("Report 'p' tag that is implicitly closed via tag omission containing a space", t => {
// Note, the browser will parse this case into: `<p> </p><div></div><p></p>` which can be
// unexpected, but technically means the first `<p>` tag is not explicitly closed.
const { diagnostics } = getDiagnostics("html`<p> <div></div></p>`", { rules: { "no-unclosed-tag": true } });
hasDiagnostic(t, diagnostics, "no-unclosed-tag");
});

// Self-closing tags do not exist in HTML. They are only valid in SVG and MathML.
tsTest("Report non-void element using self closing syntax", t => {
const { diagnostics } = getDiagnostics("html`<p /><div></div>`", { rules: { "no-unclosed-tag": true } });
Expand Down

0 comments on commit 53f7b56

Please sign in to comment.