Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 300656133429cb9c46126d3ce5829eac61957b10
https://github.com/WebKit/WebKit/commit/300656133429cb9c46126d3ce5829eac61957b10
Author: Chris Dumez <[email protected]>
Date: 2026-04-21 (Tue, 21 Apr 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-option-element/option-selected-expected.txt
M Source/WebCore/html/HTMLOptionElement.cpp
M Source/WebCore/html/HTMLOptionElement.h
M Source/WebCore/html/HTMLOptionElement.idl
M Source/WebCore/html/HTMLSelectElement.cpp
Log Message:
-----------
Implement 'dirtiness' for HTMLOptionElement
https://bugs.webkit.org/show_bug.cgi?id=312876
Reviewed by Anne van Kesteren.
The HTML spec defines a 'dirtiness' concept for option elements: once
option.selected is set via the IDL (JavaScript), the option becomes
"dirty" and subsequent changes to the selected content attribute should
not affect selectedness. This was missing in WebKit, causing two WPT
test failures.
Spec:
https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
The implementation follows Blink's approach: use ImplementedAs in the
IDL to separate the JS binding setter (which sets the dirty flag) from
the internal setSelected() method (which does not). In attributeChanged,
the selected attribute only updates selectedness when the option is not
dirty. Form reset clears the dirty flag.
For web compatibility, dirtiness is not set when the option is owned
by a select element and the selectedness did not actually change. This
matches Blink behavior (https://crbug.com/570367).
No new tests, rebaselined existing WPT test. This test was already passing
in both Chrome and Firefox.
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-option-element/option-selected-expected.txt:
* Source/WebCore/html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::attributeChanged):
(WebCore::HTMLOptionElement::selectedForBindings const):
(WebCore::HTMLOptionElement::setSelectedForBindings):
* Source/WebCore/html/HTMLOptionElement.h:
* Source/WebCore/html/HTMLOptionElement.idl:
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::reset):
Canonical link: https://commits.webkit.org/311746@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications