1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

LibHTML: Add adjacent (+) and general (~) sibling combinators

This patch implements two more selector features:

- "div + p" matches the <p> sibling immediately after a <div>.
- "div ~ p" matches all <p> siblings after a <div>.
This commit is contained in:
Andreas Kling 2019-10-06 19:59:07 +02:00
parent 5a6c36dc91
commit bedb00603c
5 changed files with 53 additions and 2 deletions

View file

@ -15,6 +15,11 @@ div > .boo > .bee {
background-color: #000000;
color: #ff00ff;
}
#gen_sib ~ div,
#adj_sib + div {
background-color: #0000ff;
color: #ffffff;
}
</style>
</head>
<body>
@ -45,5 +50,16 @@ div > .boo > .bee {
</div>
</div>
</div>
</div>
<div>
<div id="gen_sib">All the siblings of this &lt;div&gt; should be blue.</div>
<div>First sibling (should be blue)</div>
<div>Second sibling (should be blue)</div>
</div>
<div>
<div id="adj_sib">The first sibling of this &lt;div&gt; should be blue.</div>
<div>First sibling (should be blue)</div>
<div>Second sibling (should not be blue)</div>
</div>
</body>
</html>