Skip to content

Commit

Permalink
Cherry-pick 262791@main (d86fed1). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=255230

    REGRESSION (255086@main): Safari 16.4 and above does not render <option> label/text updates until <select> is focused
    https://bugs.webkit.org/show_bug.cgi?id=255230
    rdar://107838336

    Reviewed by Chris Dumez.

    255086@main removed the call to `HTMLSelectElement::setRecalcListItems` in
    `HTMLSelectElement::optionElementChildrenChanged` so that updating the text
    inside an <option> element does not reset the <select> element's selected option.

    However, this broke rendering of the option's new text, since
    `setRecalcListItems` contained logic to update the rendered text. Fix by
    reintroducing the logic that is responsible for ensuring the displayed text
    matches the <option> element's text.

    Add a regression (reference) test which would have caught this issue.

    * LayoutTests/fast/forms/select/selected-option-update-inner-html-expected.html: Added.
    * LayoutTests/fast/forms/select/selected-option-update-inner-html.html: Added.
    * Source/WebCore/html/HTMLSelectElement.cpp:
    (WebCore::HTMLSelectElement::optionElementChildrenChanged):

    Canonical link: https://commits.webkit.org/262791@main
  • Loading branch information
pxlcoder authored and aperezdc committed Apr 12, 2023
1 parent aec6f0d commit de3f899
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<select>
<option>Bar</option>
</select>
</body>
</html>
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<select>
<option>Foo</option>
</select>
<script>

addEventListener("load", () => {
let option = document.querySelector("option");
option.innerHTML = "Bar";
});

</script>
</body>
</html>
2 changes: 2 additions & 0 deletions Source/WebCore/html/HTMLSelectElement.cpp
Expand Up @@ -426,6 +426,8 @@ void HTMLSelectElement::childrenChanged(const ChildChange& change)

void HTMLSelectElement::optionElementChildrenChanged()
{
setOptionsChangedOnRenderer();
invalidateStyleForSubtree();
updateValidity();
if (auto* cache = document().existingAXObjectCache())
cache->childrenChanged(this);
Expand Down

0 comments on commit de3f899

Please sign in to comment.