Files
ladybird/Tests/LibWeb/Text/input/textarea-placeholder-shown.html
Praise-Garfield ebd312689e LibWeb: Support :placeholder-shown pseudo-class for textarea elements
Previously only input elements were matched. Add placeholder_value()
to HTMLTextAreaElement mirroring the HTMLInputElement API and update
both selector matching code paths to handle textarea.
2026-02-11 16:11:11 +01:00

45 lines
1.9 KiB
HTML

<!DOCTYPE html>
<script src="include.js"></script>
<script>
test(() => {
// Textarea with placeholder, empty value: should match.
const t1 = document.createElement("textarea");
t1.setAttribute("placeholder", "Enter text");
document.body.appendChild(t1);
println(`empty value: ${t1.matches(":placeholder-shown")}`);
// Textarea with placeholder, non-empty value: should not match.
const t2 = document.createElement("textarea");
t2.setAttribute("placeholder", "Enter text");
t2.value = "Hello";
document.body.appendChild(t2);
println(`non-empty value: ${t2.matches(":placeholder-shown")}`);
// Textarea without placeholder attribute: should not match.
const t3 = document.createElement("textarea");
document.body.appendChild(t3);
println(`no placeholder attr: ${t3.matches(":placeholder-shown")}`);
// Textarea with empty placeholder, empty value: should match.
const t4 = document.createElement("textarea");
t4.setAttribute("placeholder", "");
document.body.appendChild(t4);
println(`empty placeholder attr: ${t4.matches(":placeholder-shown")}`);
// Textarea with value set then cleared: should match again.
const t5 = document.createElement("textarea");
t5.setAttribute("placeholder", "Enter text");
document.body.appendChild(t5);
t5.value = "Hello";
t5.value = "";
println(`value cleared: ${t5.matches(":placeholder-shown")}`);
// Textarea with placeholder removed: should not match.
const t6 = document.createElement("textarea");
t6.setAttribute("placeholder", "Enter text");
document.body.appendChild(t6);
t6.removeAttribute("placeholder");
println(`placeholder removed: ${t6.matches(":placeholder-shown")}`);
});
</script>