1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Selectors Test: :has(:is()) invalidation for sibling change</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational">
<style>
#test-container > div { background-color: green; }
#target1:has(:is(.item + .item + .item)) { background-color: red; }
#target2:has(:is(.invalid .item, .item + .item + .item)) { background-color: red; }
#target3:has(:is(.item + .item + .item > .child + .child + .child)) { background-color: red; }
#target4:has(:is(.item + .item + .item > .child):is(.child + .child + .child)) { background-color: red; }
#target5:has(:is(.item + .item + .item > .child)) { background-color: red; }
#target6:has(:is(.invalid .item, .item + .item + .item > .child)) { background-color: red; }
#target7:has(:is(.item + .item + .item > .child + .child + .child)) { background-color: red; }
#target8:has(:is(.child + .child + .child):is(.item + .item + .item > .child)) { background-color: red; }
#target9:has(:is(:where(:is(.item + .item + .item) > .child) + .child + .child)) { background-color: red; }
#target10:has(:is(.item:nth-child(3))) { background-color: red; }
#target11:has(:is(.item:nth-child(3) > .child:nth-child(3))) { background-color: red; }
#target12:has(:is(.item:nth-last-child(3))) { background-color: red; }
#target13:has(:is(.item:nth-last-child(3) > .child:nth-last-child(3))) { background-color: red; }
#target14:has(:is(.item:nth-child(3) > .child)) { background-color: red; }
#target15:has(:is(.item:nth-child(3) > .child:nth-child(3))) { background-color: red; }
#target16:has(:is(.item:nth-last-child(3) > .child)) { background-color: red; }
#target17:has(:is(.item:nth-last-child(3) > .child:nth-last-child(3))) { background-color: red; }
.item + .item + .item {
#target18:has(&) { background-color: red; }
#target19:has(:is(& > .child + .child + .child)) { background-color: red; }
}
.item + .item + .item > .child {
#target20:has(:is(& + .child + .child)) { background-color: red; }
}
</style>
<div id="test-container">
<div id="target1">
<div class="item" id="item1">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">This text should have a green background</div>
</div>
<div id="target2">
<div class="item" id="item2">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">This text should have a green background</div>
</div>
<div id="target3">
<div class="item"></div>
<div class="item"></div>
<div class="item">
<span class="child" id="item3">(FAIL if you see this text)</span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target4">
<div class="item"></div>
<div class="item"></div>
<div class="item">
<span class="child" id="item4">(FAIL if you see this text)</span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target5">
<div class="item" id="item5">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target6">
<div class="item" id="item6">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target7">
<div class="item"></div>
<div class="item" id="item7">FAIL if you see this text</div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target8">
<div class="item"></div>
<div class="item" id="item8">FAIL if you see this text</div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target9">
<div class="item"></div>
<div class="item" id="item9">FAIL if you see this text</div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target10">
<div class="item" id="item10">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">This text should have a green background</div>
</div>
<div id="target11">
<div class="item"></div>
<div class="item"></div>
<div class="item">
<span class="child" id="item11">(FAIL if you see this text)</span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target12">
<div class="item">This text should have a green background</div>
<div class="item"></div>
<div class="item" id="item12">FAIL if you see this text</div>
</div>
<div id="target13">
<div class="item">
<span class="child">This text should have a green background</span>
<span class="child"></span>
<span class="child" id="item13">(FAIL if you see this text)</span>
</div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="target14">
<div class="item" id="item14">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target15">
<div class="item" id="item15">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target16">
<div class="item">
<span class="child">This text should have a green background</span>
</div>
<div class="item"></div>
<div class="item" id="item16">FAIL if you see this text</div>
</div>
<div id="target17">
<div class="item">
<span class="child">This text should have a green background</span>
<span class="child"></span>
<span class="child"></span>
</div>
<div class="item"></div>
<div class="item" id="item17">FAIL if you see this text</div>
</div>
<div id="target18">
<div class="item" id="item18">FAIL if you see this text</div>
<div class="item"></div>
<div class="item">This text should have a green background</div>
</div>
<div id="target19">
<div class="item"></div>
<div class="item" id="item19">FAIL if you see this text</div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
<div id="target20">
<div class="item"></div>
<div class="item" id="item20">FAIL if you see this text</div>
<div class="item">
<span class="child"></span>
<span class="child"></span>
<span class="child">This text should have a green background</span>
</div>
</div>
</div>
<script>
test(() => {
assert_equals(getComputedStyle(target1).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target2).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target3).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target4).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target5).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target6).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target7).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target8).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target9).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target10).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target11).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target12).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target13).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target14).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target15).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target16).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target17).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target18).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target19).backgroundColor, "rgb(255, 0, 0)");
assert_equals(getComputedStyle(target20).backgroundColor, "rgb(255, 0, 0)");
}, "Initially red");
test(() => {
item1.remove();
assert_equals(getComputedStyle(target1).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector enclosed by :is() no longer matching after removal (1)");
test(() => {
item2.remove();
assert_equals(getComputedStyle(target2).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector enclosed by :is() no longer matching after removal (2)");
test(() => {
item3.remove();
assert_equals(getComputedStyle(target3).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector enclosed by :is() no longer matching after removal (3)");
test(() => {
item4.remove();
assert_equals(getComputedStyle(target4).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector enclosed by :is() no longer matching after removal (4)");
test(() => {
item5.remove();
assert_equals(getComputedStyle(target5).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in non-subject enclosed by :is() no longer matching after removal (1)");
test(() => {
item6.remove();
assert_equals(getComputedStyle(target6).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in non-subject enclosed by :is() no longer matching after removal (2)");
test(() => {
item7.remove();
assert_equals(getComputedStyle(target7).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in non-subject enclosed by :is() no longer matching after removal (3)");
test(() => {
item8.remove();
assert_equals(getComputedStyle(target8).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in non-subject enclosed by :is() no longer matching after removal (4)");
test(() => {
item9.remove();
assert_equals(getComputedStyle(target9).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in non-subject enclosed by :is() no longer matching after removal (5)");
test(() => {
item10.remove();
assert_equals(getComputedStyle(target10).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-child() enclosed by :is() no longer matching after removal (1)");
test(() => {
item11.remove();
assert_equals(getComputedStyle(target11).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-child() enclosed by :is() no longer matching after removal (2)");
test(() => {
item12.remove();
assert_equals(getComputedStyle(target12).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-last-child() enclosed by :is() no longer matching after removal (1)");
test(() => {
item13.remove();
assert_equals(getComputedStyle(target13).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-last-child() enclosed by :is() no longer matching after removal (2)");
test(() => {
item14.remove();
assert_equals(getComputedStyle(target14).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-child() in non-subject enclosed by :is() no longer matching after removal (1)");
test(() => {
item15.remove();
assert_equals(getComputedStyle(target15).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-child() in non-subject enclosed by :is() no longer matching after removal (2)");
test(() => {
item16.remove();
assert_equals(getComputedStyle(target16).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-last-child() in non-subject enclosed by :is() no longer matching after removal (1)");
test(() => {
item17.remove();
assert_equals(getComputedStyle(target17).backgroundColor, "rgb(0, 128, 0)");
}, ":nth-last-child() in non-subject enclosed by :is() no longer matching after removal (2)");
test(() => {
item18.remove();
assert_equals(getComputedStyle(target18).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in parent selector enclosed by :is() no longer matching after removal");
test(() => {
item19.remove();
assert_equals(getComputedStyle(target19).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in parent selector non-subject position enclosed by :is() no longer matching after removal (1)");
test(() => {
item20.remove();
assert_equals(getComputedStyle(target20).backgroundColor, "rgb(0, 128, 0)");
}, "sibling selector in parent selector non-subject position enclosed by :is() no longer matching after removal (2)");
</script>
|