Describe the bug
In Preact 10.5.0 and later, the defaultValue prop for <textarea> no longer works in Internet Explorer 11 when the value prop is not explicitly passed. The textarea appears empty despite having a defaultValue set. This worked correctly in earlier versions.
To Reproduce
Steps to reproduce the behavior:
- Create a Preact component with
<textarea defaultValue="Hello, World!" />
- Open the application in Internet Explorer 11
- Observe that the textarea is empty
- Add
value={undefined} to the component: <textarea defaultValue="Hello, World!" value={undefined} />
- Observe that the textarea now displays the text
Expected behavior
The textarea should display the value passed to defaultValue in all browsers, including Internet Explorer 11, without requiring value={undefined} to be explicitly passed.
Regression Commit: This issue was introduced in PR #2742 - [wip] optimizations for compat.
Before (working):
// Old condition: checks if valueProp is null (meaning value hasn't been set yet)
if (i === 'defaultValue' && valueProp == null) {
if ('value' in props) {
i = 'value';
} else {
valueProp = value; // Preserve defaultValue as fallback
}
}
// New condition: only works if value prop exists AND is null/undefined
if (i === 'defaultValue' && 'value' in props && props.value == null) {
i = 'value';
}
The Problem:
The old logic handled two cases:
- value is present (even null) → use it
- value is absent → use defaultValue as fallback (valueProp = value)
The new logic handles only one case:
- value={null} or value={undefined} is explicitly passed → transform to value
- value is absent → defaultValue is silently ignored
Why This Is a Regression:
The new condition 'value' in props && props.value == null is fundamentally different from valueProp == null.
By removing the else branch, the refactoring lost the ability to handle the case where value is simply not provided. This was a critical fallback for IE11 compatibility.
Describe the bug
In Preact 10.5.0 and later, the
defaultValueprop for<textarea>no longer works in Internet Explorer 11 when thevalueprop is not explicitly passed. The textarea appears empty despite having adefaultValueset. This worked correctly in earlier versions.To Reproduce
Steps to reproduce the behavior:
<textarea defaultValue="Hello, World!" />value={undefined}to the component:<textarea defaultValue="Hello, World!" value={undefined} />Expected behavior
The textarea should display the value passed to
defaultValuein all browsers, including Internet Explorer 11, without requiringvalue={undefined}to be explicitly passed.Regression Commit: This issue was introduced in PR #2742 -
[wip] optimizations for compat.Before (working):
The Problem:
The old logic handled two cases:
The new logic handles only one case:
Why This Is a Regression:
The new condition 'value' in props && props.value == null is fundamentally different from valueProp == null.
By removing the else branch, the refactoring lost the ability to handle the case where value is simply not provided. This was a critical fallback for IE11 compatibility.