Skip to content

Commit 38281fb

Browse files
committed
fix(lint): recognize lit boolean binding on popover hidden attribute
Signed-off-by: John Yanarella <jyanarella@nvidia.com>
1 parent 70f2287 commit 38281fb

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

projects/lint/src/eslint/rules/no-missing-popover-trigger.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ describe('noMissingPopoverTrigger', () => {
7373
});
7474
});
7575

76+
it('should allow popover elements with data binding on hidden attribute', () => {
77+
tester.run('data binding on hidden attribute', rule, {
78+
valid: [
79+
// Lit boolean-attribute binding
80+
'<nve-dropdown id="dropdown" ?hidden="${isHidden}"></nve-dropdown>',
81+
// Lit property binding
82+
'<nve-tooltip id="tooltip" .hidden="${isHidden}">Content</nve-tooltip>',
83+
// Angular property binding
84+
'<nve-toggletip id="toggletip" [hidden]="isHidden">Content</nve-toggletip>'
85+
],
86+
invalid: []
87+
});
88+
});
89+
7690
it('should allow popover elements with commandfor trigger', () => {
7791
tester.run('valid commandfor triggers', rule, {
7892
valid: [

projects/lint/src/eslint/rules/no-missing-popover-trigger.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ function findAttrWithBinding(
5151
return { attr: litAttr, hasBinding: true };
5252
}
5353

54+
// Check for Lit boolean-attribute binding: ?attrName
55+
const litBoolAttr = findAttr(node, `?${attrName}`);
56+
if (litBoolAttr) {
57+
return { attr: litBoolAttr, hasBinding: true };
58+
}
59+
5460
return { attr: undefined, hasBinding: false };
5561
}
5662

@@ -125,7 +131,7 @@ const rule = {
125131
if (!POPOVER_ELEMENTS.includes(tagName as (typeof POPOVER_ELEMENTS)[number])) return;
126132
const { attr: idAttr, hasBinding: hasBindingId } = findAttrWithBinding(node, 'id');
127133
const anchorAttr = findAttr(node, 'anchor');
128-
const hiddenAttr = findAttr(node, 'hidden');
134+
const { attr: hiddenAttr } = findAttrWithBinding(node, 'hidden');
129135
popovers.push({
130136
node,
131137
id: idAttr?.value?.value,

0 commit comments

Comments
 (0)