Skip to content

Commit

Permalink
backport #3720
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Oct 26, 2022
1 parent a1dca7f commit c6f9fdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/diff/props.js
Expand Up @@ -94,10 +94,7 @@ export function setProperty(dom, name, value, oldValue, isSvg) {

if (typeof value === 'function') {
// never serialize functions as attribute values
} else if (
value != null &&
(value !== false || (name[0] === 'a' && name[1] === 'r'))
) {
} else if (value != null && (value !== false || name.indexOf('-') != -1)) {
dom.setAttribute(name, value);
} else {
dom.removeAttribute(name);
Expand Down
12 changes: 11 additions & 1 deletion test/browser/render.test.js
Expand Up @@ -462,11 +462,21 @@ describe('render()', () => {
expect(scratch.childNodes[0]).to.have.property('className', 'bar');
});

it('should support false aria-* attributes', () => {
it('should support false string aria-* attributes', () => {
render(<div aria-checked="false" />, scratch);
expect(scratch.firstChild.getAttribute('aria-checked')).to.equal('false');
});

it('should support false aria-* attributes', () => {
render(<div aria-checked={false} />, scratch);
expect(scratch.firstChild.getAttribute('aria-checked')).to.equal('false');
});

it('should support false data-* attributes', () => {
render(<div data-checked={false} />, scratch);
expect(scratch.firstChild.getAttribute('data-checked')).to.equal('false');
});

it('should set checked attribute on custom elements without checked property', () => {
render(<o-checkbox checked />, scratch);
expect(scratch.innerHTML).to.equal(
Expand Down

0 comments on commit c6f9fdc

Please sign in to comment.