Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b37b0cb33a7cc5461943fc7d0dc83e72deaa29ba
https://github.com/WebKit/WebKit/commit/b37b0cb33a7cc5461943fc7d0dc83e72deaa29ba
Author: Chris Dumez <[email protected]>
Date: 2026-04-20 (Mon, 20 Apr 2026)
Changed paths:
M
LayoutTests/fast/forms/menulist-no-renderer-for-unexpected-children-expected.txt
M LayoutTests/fast/forms/menulist-no-renderer-for-unexpected-children.html
M
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt
M Source/WebCore/dom/Element.cpp
M Source/WebCore/editing/TextIterator.cpp
M Source/WebCore/html/HTMLSelectElement.cpp
M Source/WebCore/html/HTMLSelectElement.h
Log Message:
-----------
Element.innerText should collect option text when called directly on a
<select> element
https://bugs.webkit.org/show_bug.cgi?id=312738
Reviewed by Anne van Kesteren.
When innerText is called directly on a <select>, Element::innerText() calls
plainText() with a range over the select's children. Since <option> elements
inside a <select> have no renderers, TextIterator skips them and returns an
empty string. The special <select> handling in
TextIterator::handleReplacedElement()
only fires when the <select> is encountered as a child of another element.
Fix this by adding HTMLSelectElement::collectOptionInnerText() which uses
m_listItems to collect all option text regardless of nesting depth, and
calling it from Element::innerText() when the element is a <select>. The
same method is now also used by TextIterator::handleReplacedElement(),
replacing the previous static collectSelectInnerText() which only checked
direct children and missed options nested inside <div> or <optgroup> wrappers.
No new tests, rebaselined existing WPT test. Chrome was already passing
the subtests we are now passing. The test that went from FAIL to FAIL
is also failing in Chrome.
*
LayoutTests/fast/forms/menulist-no-renderer-for-unexpected-children-expected.txt:
* LayoutTests/fast/forms/menulist-no-renderer-for-unexpected-children.html:
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::innerText):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::handleReplacedElement):
(WebCore::collectSelectInnerText): Deleted.
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::collectOptionInnerText const):
* Source/WebCore/html/HTMLSelectElement.h:
Canonical link: https://commits.webkit.org/311576@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications