-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
- Check if updating to the latest Preact version resolves the issue
Describe the bug
Once <progress> value attribute has been set, it will never be removed.
On this element, the absence of a value attribute has significance:
If there is no value attribute, the progress bar is indeterminate; this indicates that an activity is ongoing with no indication of how long it is expected to take.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress
Currently I'm unable to remove the attribute without resorting to direct DOM manipulation.
To Reproduce
Run the following code at https://preactjs.com/repl
import { render, Component } from 'preact';
class ProgressDemo extends Component {
constructor() {
super();
this.state = { loading: true };
}
render() {
const { loading } = this.state;
const value = loading ? undefined : 1;
return (
<div>
<div>Progress should {loading || 'not'} be animated.</div>
<div>
<progress value={value} />
<button onClick={() => this.setState({ loading: !loading })}>
Loading ({String(loading)})
</>
</>
<div><code>state.loading</code> is {String(loading)}</div>
<div><code>progress.loading</code> is being set to {String(value)}</div>
</>
);
}
}
render(<ProgressDemo />, document.getElementById('app'));Expected behavior
- Progress bar is initially rendered as
<progress>, with novalueattribute, so it animates in an indeterminate state - Clicking the button sets
loadingto false, which results in the html<progress value="1">. Animation stops. - Clicking the button again sets
loadingto true, which results in the same initial html,<progress>with novalueattribute. Animation resumes.
Actual behavior
- Once
valuehas been set once, attempting to set it to a falsey value will will have no effect; the attribute will retain its previous value and will not be removed.
Metadata
Metadata
Assignees
Labels
No labels