Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/cool-walls-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes rendering of the `popover` attribute when it has a boolean value
5 changes: 5 additions & 0 deletions packages/astro/src/runtime/server/render/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
return markHTMLString(` ${key}`);
}

// We cannot add it to htmlBooleanAttributes because it can be: boolean | "auto" | "manual"
if (key === 'popover' && typeof value === 'boolean') {
return markHTMLString(value ? ` popover` : '');
}

return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/astro/test/astro-attrs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ describe('Attributes', async () => {
const $ = cheerio.load(html);

const attrs = {
'popover-auto': { attribute: 'popover', value: 'auto' },
'popover-true': { attribute: 'popover', value: '' },
'popover-false': { attribute: 'popover', value: undefined },
'popover-string-empty': { attribute: 'popover', value: '' },
'boolean-attr-true': { attribute: 'allowfullscreen', value: '' },
'boolean-attr-false': { attribute: 'allowfullscreen', value: undefined },
'boolean-attr-string-truthy': { attribute: 'allowfullscreen', value: '' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<dialog id="popover-auto" popover={'auto'} />
<dialog id="popover-true" popover={true} />
<dialog id="popover-false" popover={false} />
<dialog id="popover-string-empty" popover={''} />

<span id="boolean-attr-true" allowfullscreen={true} />
<span id="boolean-attr-false" allowfullscreen={false} />
<span id="boolean-attr-string-truthy" allowfullscreen={'foo'} />
Expand Down