[webkit-changes] [WebKit/WebKit] efb64f: HTMLOptionElement::defaultSelected should affect s...

Ahmad Saleem noreply at github.com
Wed Jun 14 14:52:50 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: efb64fda19d2c873b1714e2d8a387c0e97ddc4c1
      https://github.com/WebKit/WebKit/commit/efb64fda19d2c873b1714e2d8a387c0e97ddc4c1
  Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
  Date:   2023-06-14 (Wed, 14 Jun 2023)

  Changed paths:
    A LayoutTests/fast/forms/select/option-defaultselected-expected.txt
    A LayoutTests/fast/forms/select/option-defaultselected.html
    M Source/WebCore/html/HTMLOptionElement.cpp

  Log Message:
  -----------
  HTMLOptionElement::defaultSelected should affect selection state of other option elements once added or removed

https://bugs.webkit.org/show_bug.cgi?id=119291

Reviewed by Ryosuke Niwa.

This patch aligns WebKit with Gecko / Firefox, Blink / Chromium and Web-Spec.

Merge: https://chromium.googlesource.com/chromium/blink/+/e8f0337fdc86554b48cf81d7ed8c286f251d2405 &
https://chromium.googlesource.com/chromium/src.git/+/4288626a69e2e6426555bb174a99e555e174f755

According to the standard, we should set selectedness to true if defaultSelected is set to
true, and we should not set selectedness to false if defaultSelected is set to false
because the standard says nothing about it.

[1]
> Whenever an option element's selected attribute is added, its selectedness
> must be set to true.

When the selectedness of an option is updated, other options's selectedness should become
false.

[2]
> If the multiple attribute is absent, whenever an option element in the select
> element's list of options has its selectedness set to true, and whenever an
> option element with its selectedness set to true is added to the select
> element's list of options, the user agent must set the selectedness of all the
> other option elements in its list of options to false.

The old behavior doesn't match to the standard and any other browsers. The new behavior
matches to IE10, Chrome, Gecko and the standard.

Additionally, this patch also ensure that we update selectedness only if
selected attribute is added or removed and not value.

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#attr-option-selected
[2] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-select-element

* Source/WebCore/html/HTMLOptionElement.cpp
(HTMLOptionElement::attributeChanged): As below:
(1) Update FIXME and bug link
(2) Link to spec
(3) As per commit log
* LayoutTests/fast/forms/select/option-defaultselected-expected.txt: Added Test Case Expectation
* LayoutTests/fast/forms/select/option-defaultselected.html: Added Test Case

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




More information about the webkit-changes mailing list