Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e59d6bd9c64bc488a7a252c5825c56818ccbfee1
      
https://github.com/WebKit/WebKit/commit/e59d6bd9c64bc488a7a252c5825c56818ccbfee1
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-21 (Tue, 21 Apr 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt
    M Source/WebCore/editing/TextIterator.cpp
    M Source/WebCore/html/HTMLSelectElement.cpp
    M Source/WebCore/html/HTMLSelectElement.h

  Log Message:
  -----------
  innerText should emit a newline for empty <option> or <optgroup> inside 
<select>
https://bugs.webkit.org/show_bug.cgi?id=312770

Reviewed by Anne van Kesteren.

When a <select> contains an empty <option> or <optgroup>, 
collectOptionInnerText()
returns an empty string and the TextIterator emits nothing for the select 
element.
However, per the innerText spec, each <option> and <optgroup> acts as a 
block-level
element that should generate a required line break.

Fix this by adding an EmitNewlineForEmptyItems enum parameter to
collectOptionInnerText(). When passed Yes (as done from the TextIterator), the
method returns "\n" if listItems() is non-empty but all options have empty text.
This keeps the empty-item logic in the select's own method rather than in the
TextIterator. The default is No, preserving the existing behavior when innerText
is called directly on a <select> element.

No new tests, rebaselined existing WPT test. Chrome was already passing
the subtests that we are newly passing.

* 
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt:
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::handleReplacedElement):
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::collectOptionInnerText):
* Source/WebCore/html/HTMLSelectElement.h:

Canonical link: https://commits.webkit.org/311673@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to