Commit ffdff572 authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

Update UI when changing input's value with setAttribute

This patch fixes a bug where setting a range input element's default
value with setAttribute('value', defaultValue) does not update the UI of
the range input to show the new default value.
The bug is present in WebKit, but not present in Firefox.

Bug: 852938
Change-Id: Ibef8c0c6cefeb221a0d9220a966b04a03d815c76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834647
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704667}
parent 58dfbae2
...@@ -415,4 +415,8 @@ Decimal RangeInputType::FindClosestTickMarkValue(const Decimal& value) { ...@@ -415,4 +415,8 @@ Decimal RangeInputType::FindClosestTickMarkValue(const Decimal& value) {
return closest_left; return closest_left;
} }
void RangeInputType::ValueAttributeChanged() {
UpdateView();
}
} // namespace blink } // namespace blink
...@@ -85,6 +85,7 @@ class RangeInputType final : public InputType, public InputTypeView { ...@@ -85,6 +85,7 @@ class RangeInputType final : public InputType, public InputTypeView {
// InputTypeView function: // InputTypeView function:
void UpdateView() override; void UpdateView() override;
void ValueAttributeChanged() override;
bool tick_mark_values_dirty_; bool tick_mark_values_dirty_;
Vector<Decimal> tick_mark_values_; Vector<Decimal> tick_mark_values_;
......
...@@ -375,8 +375,8 @@ void TextFieldInputType::ListAttributeTargetChanged() { ...@@ -375,8 +375,8 @@ void TextFieldInputType::ListAttributeTargetChanged() {
} }
void TextFieldInputType::AttributeChanged() { void TextFieldInputType::AttributeChanged() {
// FIXME: Updating on any attribute update should be unnecessary. We should // TODO(crbug.com/1012774): Updating on any attribute update should be
// figure out what attributes affect. // unnecessary. We should figure out what attributes affect.
UpdateView(); UpdateView();
} }
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>range input element setAttribute value appearance</title>
<p>Test passes if the range element below visually has its slider at 2/10 from the left</p>
<input type=range min=0 max=10 value=2></input>
<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element">
<link rel="match" href="range-setattribute-value-ref.html">
<title>range input element setAttribute value appearance</title>
<p>Test passes if the range element below visually has its slider at 2/10 from the left</p>
<script>
window.onload = () => {
const input = document.createElement('input');
input.type = 'range';
input.min = 0;
input.max = 10;
document.body.appendChild(input);
requestAnimationFrame(() => {
requestAnimationFrame(() => {
input.setAttribute('value', 2);
document.documentElement.classList.remove('reftest-wait');
});
});
};
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment