Commit 44108518 authored by HyeockJinKim's avatar HyeockJinKim Committed by Commit Bot

Always update placeholder's visibility

Always call SetPlaceholderVisibility if !placeholder
to prevent :placeholder-shown style from being applied

Bug: 884696
Change-Id: I5f078dad825de91253bc99d133dc7978a59bbda3
Reviewed-on: https://chromium-review.googlesource.com/c/1292666Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: HyeockJin Kim <kherootz@gmail.com>
Cr-Commit-Position: refs/heads/master@{#604529}
parent 8993d590
<!DOCTYPE html>
<title>When non-empty placeholder becomes empty, :placeholder-shown test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://drafts.csswg.org/selectors-4/#placeholder">
<input id="myinput" type="text" placeholder="FAIL">
<textarea id="mytextarea" placeholder="FAIL"></textarea>
<script>
test(() => {
const input = document.querySelector("input");
input.placeholder = "";
input.value = "NO RED";
assert_false(input.matches(":placeholder-shown"));
}, "input:placeholder-shown should not be matched");
test(() => {
const textarea = document.querySelector("textarea");
textarea.placeholder = "";
textarea.value = "No RED";
assert_false(textarea.matches(":placeholder-shown"));
}, "textarea:placeholder-shown should not be matched");
</script>
......@@ -180,6 +180,7 @@ void TextControlElement::UpdatePlaceholderVisibility() {
HTMLElement* placeholder = PlaceholderElement();
if (!placeholder) {
UpdatePlaceholderText();
SetPlaceholderVisibility(PlaceholderShouldBeVisible());
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment