-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Check all siblings in ancestors chain while invalidating :has()
Fixes underinvalidaiton of `:has()` selectors with sibling combinators.
- Loading branch information
1 parent
7dbef8d
commit 976af84
Showing
3 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Tests/LibWeb/Text/expected/css/invalidate-sibling-affected-by-has.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
background-color before: rgb(204, 204, 255) | ||
background-color after: rgb(238, 238, 255) |
59 changes: 59 additions & 0 deletions
59
Tests/LibWeb/Text/input/css/invalidate-sibling-affected-by-has.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<script src="../include.js"></script> | ||
<style> | ||
div { | ||
min-height: 50px; | ||
min-width: 50px; | ||
margin: 5px; | ||
padding: 5px; | ||
border: 1px solid #ccc; | ||
color: grey; | ||
} | ||
|
||
#parent { | ||
border: 2px solid black; | ||
padding: 10px; | ||
} | ||
|
||
.blue { | ||
background-color: #eef; | ||
} | ||
|
||
.f_has_scope { | ||
background-color: #efe; | ||
border: 2px dotted green; | ||
} | ||
|
||
.invalid { | ||
background-color: #ffc; | ||
border: 2px solid orange; | ||
} | ||
|
||
.blue:has(~ #indirect_next:is(.p + .f_has_scope ~ .g)) { | ||
color: blue; | ||
background-color: #ccf; | ||
border: 2px solid blue; | ||
} | ||
</style> | ||
<div id="parent"> | ||
<div class="p"></div> | ||
<div id="previous" class="f_has_scope"></div> | ||
<div id="has_scope" class="blue"></div> | ||
<div id="indirect_next" class="g"></div> | ||
</div> | ||
<script> | ||
test(() => { | ||
const blue = document.getElementById("has_scope"); | ||
println(`background-color before: ${getComputedStyle(blue).backgroundColor}`); | ||
|
||
let insertBefore = document.getElementById("previous"); | ||
let parent = insertBefore.parentElement; | ||
|
||
let div = document.createElement("div"); | ||
div.classList.add("invalid"); | ||
|
||
parent.insertBefore(div, insertBefore); | ||
|
||
println(`background-color after: ${getComputedStyle(blue).backgroundColor}`); | ||
}); | ||
</script> |