Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b6ea7219106b96884ad93458fe50c25325dbbd0d
      
https://github.com/WebKit/WebKit/commit/b6ea7219106b96884ad93458fe50c25325dbbd0d
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-04-08 (Wed, 08 Apr 2026)

  Changed paths:
    M LayoutTests/fast/css/placeholder-shown-basics-expected.html
    M LayoutTests/fast/css/placeholder-shown-basics.html
    M LayoutTests/fast/selectors/placeholder-shown-style-update-expected.txt
    M LayoutTests/fast/selectors/placeholder-shown-style-update.html
    M 
LayoutTests/fast/selectors/placeholder-shown-with-input-basics-expected.txt
    M LayoutTests/fast/selectors/placeholder-shown-with-input-basics.html
    M 
LayoutTests/fast/selectors/placeholder-shown-with-textarea-basics-expected.txt
    M LayoutTests/fast/selectors/placeholder-shown-with-textarea-basics.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/placeholder-shown-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/placeholder-shown-expected.txt
    M Source/WebCore/html/HTMLTextAreaElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.h
    M Source/WebCore/html/TextFieldInputType.cpp

  Log Message:
  -----------
  Fix :placeholder-shown to match elements with empty placeholder attributes
https://bugs.webkit.org/show_bug.cgi?id=311002
rdar://173604635

Reviewed by Ryosuke Niwa and Tim Nguyen.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Per the HTML spec [1], :placeholder-shown must match elements that have
a placeholder attribute "whose value is currently being presented to
the user." An empty placeholder attribute still has a value (the empty
string) that is being presented. WebKit was incorrectly requiring
non-empty placeholder text.

Remove isPlaceholderEmpty() and check attribute presence instead.
Update TextFieldInputType and HTMLTextAreaElement to preserve the
placeholder shadow DOM element when the attribute is present but empty.

[1] https://html.spec.whatwg.org/#selector-placeholder-shown

* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updatePlaceholderText):
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible const):
(WebCore::isNotLineBreak): Deleted.
(WebCore::HTMLTextFormControlElement::isPlaceholderEmpty const): Deleted.
* Source/WebCore/html/HTMLTextFormControlElement.h:
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::updatePlaceholderText):
* 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/placeholder-shown-expected.txt:
 Progression
* 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/placeholder-shown-expected.txt:
 Ditto

Add more tests below:

Merge: 
https://chromium.googlesource.com/chromium/src/+/c9a2ede805faf4305954df116f4b9cfdde1dc5d1

* LayoutTests/fast/css/placeholder-shown-basics-expected.html:
* LayoutTests/fast/css/placeholder-shown-basics.html:

Update below:

Merge: 
https://chromium.googlesource.com/chromium/src/+/42a6faa36ca322b47d02bfce5c05684054141b48

* LayoutTests/fast/css/placeholder-shown-basics-expected.html:
* LayoutTests/fast/selectors/placeholder-shown-style-update-expected.txt:
* LayoutTests/fast/selectors/placeholder-shown-style-update.html:
* LayoutTests/fast/selectors/placeholder-shown-with-input-basics-expected.txt:
* LayoutTests/fast/selectors/placeholder-shown-with-input-basics.html:
* 
LayoutTests/fast/selectors/placeholder-shown-with-textarea-basics-expected.txt:
* LayoutTests/fast/selectors/placeholder-shown-with-textarea-basics.html:

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



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

Reply via email to