Skip to content

Commit

Permalink
support popover boolean attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed May 21, 2024
1 parent 85bed33 commit d315fc7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
name != 'rowSpan' &&
name != 'colSpan' &&
name != 'role' &&
name != 'popover' &&
name in dom
) {
try {
Expand All @@ -135,7 +136,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
if (typeof value == 'function') {
// never serialize functions as attribute values
} else if (value != null && (value !== false || name[4] === '-')) {
dom.setAttribute(name, value);
dom.setAttribute(name, name === 'popover' && value === true ? '' : value);
} else {
dom.removeAttribute(name);
}
Expand Down
15 changes: 15 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,21 @@ describe('render()', () => {
expect(scratch.firstChild.spellcheck).to.equal(false);
});

it('should support popover auto', () => {
render(<div popover="auto" />, scratch);
expect(scratch.innerHTML).to.equal("<div popover=\"auto\"></div>");
});

it('should support popover true boolean', () => {
render(<div popover />, scratch);
expect(scratch.innerHTML).to.equal("<div popover=\"\"></div>");
});

it('should support popover true boolean', () => {
render(<div popover={false} />, scratch);
expect(scratch.innerHTML).to.equal("<div></div>");
});

// Test for preactjs/preact#4340
it('should respect defaultValue in render', () => {
scratch.innerHTML = '<input value="foo">';
Expand Down

0 comments on commit d315fc7

Please sign in to comment.