Setting input.value for <input type=range> does not update the position of the slider thumb.
Hm, I can't reproduce this in a smaller testcase. Maybe it's a bug with the page I was working on...
Turns out I was wrong. This works! \o/
Ok, so this bug does happen, but only if you've dragged the thumb once. Attaching a testcase.
Created attachment 16341 [details] testcase
Created attachment 16342 [details] potential fix So this patch seems to fix the bug, though I'd like Adele's opinion on whether this is the right way to go about it.
Adele said she didn't think the approach in my first patch was right, so I debugged a bit more, and I think I have found the real cause. It looks as though the thumb's position will only get updated if HTMLInputElement::setChanged() is called at some point. When setting the value through JS, this happens in HTMLInputElement::parseMappedAttribute: } else if (attr->name() == valueAttr) { // We only need to setChanged if the form is looking at the default value right now. if (m_value.isNull()) setChanged(); setValueMatchesRenderer(false); Note the check for if (m_value.isNull()). Normally, modifications to m_value only happen if HTMLInputElement::storesValueSeparateFromAttribute() returns true (which it does not for <input type=range>). So for an <input type=range>, we would expect m_value.isNull() to always be true, and therefore setChanged() to always be called when input.value is modified. However, there is one place where m_value is set without first checking storesValueSeparateFromAttribute(): HTMLInputElement::setValueFromRenderer(). This method gets called from RenderSlider::setValueForPosition(), which is called when you drag the thumb. This sets m_value, so setChanged() is never subsequently called when input.value is set from JS. It seems like RenderSlider really wants to set the value attribute directly, not HTMLInputElement::m_value.
"It seems like RenderSlider really wants to set the value attribute directly, not HTMLInputElement::m_value." I don't think so... you need to be able to reset a slider back to its default value. The value attribute represents the default value that you will reset to (as well as the initial value). If the user drags the slider thumb, then this should not change the default value. It is just changing the current value. If the user then resets the form, the slider should revert back to its default value.
The patch in this bug is absolutely correct, although you'll need to make sure Safari RSS doesn't break.
This is a regression from Safari 2.
<rdar://problem/5498169>
Looks like resetting via form.reset() is also broken.
Fixed in r25701