mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 17:48:37 +00:00
LibWeb: Implement the exclusive <details> accordion
This is a relatively new feature which allows naming <details> groups to ensure only one <details> element in that group is opened at a time.
This commit is contained in:
parent
1fb1d5fcb9
commit
59a4203cf0
Notes:
github-actions[bot]
2025-01-17 09:23:27 +00:00
Author: https://github.com/trflynn89
Commit: 59a4203cf0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3264
4 changed files with 155 additions and 4 deletions
56
Tests/LibWeb/Text/input/HTML/details-name.html
Normal file
56
Tests/LibWeb/Text/input/HTML/details-name.html
Normal file
|
@ -0,0 +1,56 @@
|
|||
<details id="details0" name="group1">
|
||||
<summary>Summary 0</summary>
|
||||
<span>Contents 0</span>
|
||||
</details>
|
||||
<details id="details1" name="group1">
|
||||
<summary>Summary 1</summary>
|
||||
<span>Contents 1</span>
|
||||
</details>
|
||||
<details id="details2" name="group1">
|
||||
<summary>Summary 2</summary>
|
||||
<span>Contents 2</span>
|
||||
</details>
|
||||
<details id="details3" name="group2">
|
||||
<summary>Summary 3</summary>
|
||||
<span>Contents 3</span>
|
||||
</details>
|
||||
<details id="details4">
|
||||
<summary>Summary 4</summary>
|
||||
<span>Contents 4</span>
|
||||
</details>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(done => {
|
||||
const elements = document.getElementsByTagName("details");
|
||||
|
||||
const logState = () => {
|
||||
let result = "";
|
||||
|
||||
for (const element of elements) {
|
||||
result += `${element.id}=${element.open ? "✓" : "✗"} `;
|
||||
}
|
||||
|
||||
println(result.trimEnd());
|
||||
};
|
||||
|
||||
logState();
|
||||
|
||||
elements[0].toggleAttribute("open");
|
||||
logState();
|
||||
|
||||
elements[1].toggleAttribute("open");
|
||||
logState();
|
||||
|
||||
elements[2].toggleAttribute("open");
|
||||
logState();
|
||||
|
||||
elements[3].toggleAttribute("open");
|
||||
logState();
|
||||
|
||||
elements[4].toggleAttribute("open");
|
||||
logState();
|
||||
|
||||
elements[0].toggleAttribute("open");
|
||||
logState();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue