mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
LibWeb: Implement the HTMLLabelElement.form attribute
This returns the form element associated with the given label element's control or null if the label has no control.
This commit is contained in:
committed by
Andreas Kling
parent
5296338e7a
commit
6bf22075ed
Notes:
sideshowbarker
2024-07-17 00:49:59 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/6bf22075ed Pull-request: https://github.com/SerenityOS/serenity/pull/24346 Reviewed-by: https://github.com/shannonbooth ✅
28
Tests/LibWeb/Text/input/HTML/HTMLLabelElement-form.html
Normal file
28
Tests/LibWeb/Text/input/HTML/HTMLLabelElement-form.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<label id="label-no-for"></label>
|
||||
<span id="non-labelable"></span>
|
||||
<form id="form1">
|
||||
<input id="input1">
|
||||
</form>
|
||||
<form id="form2">
|
||||
<label id="parent-of-input2"><input id="input2" ></label>
|
||||
<label id="label-for-input2" for="input2"></label>
|
||||
<label id="label-for-input1" for="input1"></label>
|
||||
<label id="label-for-non-labelable-element" for="non-labelable"></label>
|
||||
<label id="label-for-nonexistent-element" for="invalid"></label>
|
||||
</form>
|
||||
</form>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
for (const labelElement of document.querySelectorAll("label")) {
|
||||
if (labelElement.form) {
|
||||
println(`Form for #${labelElement.id}: #${labelElement.form.id}`);
|
||||
println(`label.form is the same as label.control.form for #${labelElement.id}: ${labelElement.form === labelElement.control.form}`);
|
||||
} else {
|
||||
println(`Form for #${labelElement.id} is null`);
|
||||
println(`Control for #${labelElement.id} is null: ${labelElement.control === null}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user