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
4 changes: 3 additions & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ function diffElementNodes(
// As above, don't diff props during hydration
if (!isHydrating) {
i = 'value';
if (
if (nodeType === 'progress' && inputValue == null) {
dom.removeAttribute('value');
} else if (
inputValue !== undefined &&
// #2756 For the <progress>-element the initial value is 0,
// despite the attribute not being present. When the attribute
Expand Down
14 changes: 14 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,20 @@ describe('render()', () => {
expect(scratch.firstChild.getAttribute('value')).to.equal('0');
});

// #4487
it('should not set value for undefined/null on a progress element', () => {
render(<progress value={undefined} />, scratch);
expect(scratch.firstChild.getAttribute('value')).to.equal(null);
render(<progress value={null} />, scratch);
expect(scratch.firstChild.getAttribute('value')).to.equal(null);
render(<progress value={0} />, scratch);
expect(scratch.firstChild.getAttribute('value')).to.equal('0');
render(<progress value={50} />, scratch);
expect(scratch.firstChild.getAttribute('value')).to.equal('50');
render(<progress value={null} />, scratch);
expect(scratch.firstChild.getAttribute('value')).to.equal(null);
});

it('should always diff `checked` and `value` properties against the DOM', () => {
// See https://github.com/preactjs/preact/issues/1324

Expand Down