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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html title=":root selector" lang="en">
<head>
<!-- (c) Disruptive Innovations 2008 -->
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>CSS 3 Selectors Test</title>
<script type="text/javascript" charset="utf-8" src="css3-compat.js"></script>
<style type="text/plain" id="teststyle">
<!--
/* TEST 0 : BASIC TESTS */
/* element type selector */
body { background-color: red; margin: 10px; padding: 10px; color: lime; font-family: sans-serif }
div { background-color: red; }
div.header { background-color: #e0e0e0; color: black; padding: 4px; margin-bottom: 4px;}
div.footer { background-color: #e0e0e0; color: black; padding: 4px; margin-top: 4px;}
h3, h4, p, ul { margin: 8px; padding: 0px; list-style: none; }
/* class selector */
.unitTest { width: 10px; background-color: red; margin: 0px; margin-right: 2px; float: left; }
.test { margin-bottom: 2px; background-color: green;}
/* group of selectors */
.unitTest, .test { height: 10px; }
/* :target selector */
.target :target { background-color: lime; }
/* test 1 : childhood selector */
html > body { background-color: green; }
.test > .blox1 { background-color: lime; }
/* test 2 : attribute existence selector */
/* attribute with a value */
.blox2[align] { background-color: lime; }
/* attribute with empty value */
.blox3[align] { background-color: lime; }
/* attribute with almost similar name */
.blox4, .blox5 { background-color: lime }
.blox4[align], .blox5[align] { background-color: red; }
/* test3 : attribute value selector */
.blox6[align="center"] { background-color: lime; }
.blox6[align="c"] { background-color: red; }
.blox6[align="centera"] { background-color: red; }
.blox6[foo="\e9"] { background-color: lime; }
.blox6[\_foo="\e9"] { background-color: lime; }
/* test 4 : [~=] */
.blox7[class~="foo"] { background-color: lime; }
.blox8, .blox9, .blox10 { background-color: lime; }
.blox8[class~=""] { background-color: red; }
.blox9[foo~=""] { background-color: red; }
.blox10[foo~="foo"] { background-color: red; }
/* test5 [^=] */
.attrStart > .t3 { background-color: lime; }
.attrStart > .t1[class^="unit"] { background-color: lime; }
.attrStart > .t2 { background-color: lime; }
.attrStart > .t2[class^="nit"] { background-color: red; }
.attrStart > .t3[align^=""] { background-color: red; }
.attrStart > .t4[foo^="\e9"] { background-color: lime; }
/* test6 [$=] */
.attrEnd > .t3 { background-color: lime; }
.attrEnd > .t1[class$="t1"] { background-color: lime; }
.attrEnd > .t2 { background-color: lime; }
.attrEnd > .t2[class$="unit"] { background-color: red; }
.attrEnd > .t3[align$=""] { background-color: red; }
.attrEnd > .t4[foo$="\e9"] { background-color: lime; }
/* test7 [*=] */
.attrMiddle > .t3 { background-color: lime; }
.attrMiddle > .t1[class*="t t"] { background-color: lime; }
.attrMiddle > .t2 { background-color: lime; }
.attrMiddle > .t2[class*="a"] { background-color: red; }
.attrMiddle > .t3[align*=""] { background-color: red; }
.attrMiddle > .t4[foo*="\e9"] { background-color: lime; }
/* :first-child tests */
.firstChild .unitTest:first-child { background-color: lime; }
.blox12:first-child { background-color: red; }
.blox13:first-child { background-color: red; }
.blox12, .blox13 { background-color: lime }
/* :nth-child(n) tests */
.nthchild1 > :nth-last-child(odd) { background-color: lime; }
.nthchild1 > :nth-child(odd) { background-color: lime; }
.nthchild2 > :nth-last-child(even) { background-color: lime; }
.nthchild2 > :nth-child(even) { background-color: lime; }
.nthchild3 > :nth-child(3n+2) { background-color: lime; }
.nthchild3 > :nth-last-child(3n+1) { background-color: lime; }
.nthchild3 > :nth-last-child(3n+3) { background-color: lime; }
.nthoftype1 > div:nth-of-type(odd) { background-color: lime; }
.nthoftype1 > div:nth-last-of-type(odd) { background-color: lime; }
.nthoftype1 > p { background-color: green; }
.nthoftype2 > div:nth-of-type(even) { background-color: lime; }
.nthoftype2 > div:nth-last-of-type(even) { background-color: lime; }
.nthoftype2 > p { background-color: green; }
.nthoftype3 > div:nth-of-type(3n+1) { background-color: lime; }
.nthoftype3 > div:nth-last-of-type(3n+1) { background-color: lime; }
.nthoftype3 > div:nth-last-of-type(3n+2) { background-color: lime; }
.nthoftype3 > p { background-color: green; }
/* :not() tests */
.blox14:not(span) { background-color: lime; }
.blox15:not([foo="blox14"]) { background-color: lime; }
.blox16 { background-color: red; }
.blox16:not(.blox15) { background-color: lime; }
.blox16:not(.blox15[foo="blox14"]) { background-color: red; }
/* :only-of-type tests */
.blox17 { background-color: red; }
.blox17:only-of-type { background-color: lime; }
.blox18:only-of-type { background-color: red; }
.blox18:not(:only-of-type) { background-color: lime; }
/* :last-child tests */
.lastChild > p { background-color: red; }
.lastChild > :last-child { background-color: lime }
.lastChild > :not(:last-child) { background-color: lime }
/* :first-of-type tests */
.firstOfType > p { background-color: red }
.firstOfType > *:first-of-type { background-color: lime; }
*.firstOfType > :not(:first-of-type) { background-color: lime; }
/* :last-of-type tests */
.lastOfType > p { background-color: red }
.lastOfType > *:last-of-type { background-color: lime; }
*.lastOfType > :not(:last-of-type) { background-color: lime; }
/* :only-child tests */
.onlyChild > *:not(:only-child) { background-color: lime; }
.onlyChild > .unitTest > *:only-child { background-color: lime; }
/* :only-of-type tests */
.onlyOfType *:only-of-type { background-color: lime; }
.onlyOfType *:not(:only-of-type) { background-color: lime; }
/* :empty tests */
.empty > .isEmpty { color: red; }
.empty > *.isEmpty:empty { background-color: lime; color: lime; }
.empty > .isNotEmpty { background-color: blue; color: blue; }
.empty > .isNotEmpty:empty { background-color: red; color: red; }
.empty > .isNotEmpty:not(:empty) { background-color: lime; color: lime; }
/* :lang() tests */
.lang :lang(en) { background-color: lime; }
.lang :lang(fr) { background-color: lime; }
.lang .t1 { background-color: blue; }
.lang .t1:lang(es) { background-color: lime; }
.lang :lang(es-AR) { background-color: red; }
/* [|=] tests */
.attrLang .t1 { background-color: lime; }
.attrLang .t1[lang|="en"] { background-color: red; }
.attrLang [lang|="fr"] { background-color: lime; }
.attrLang .t2[lang|="en"] { background-color: lime; }
.attrLang .t3 { background-color: blue; }
.attrLang .t3[lang|="es"] { background-color: lime; }
.attrLang [lang|="es-AR"] { background-color: red; }
/* UI tests */
.UI > * { float: left }
.UI { clear: both; height: auto; padding-top: 6px;}
.UI .t1:enabled > .unitTest { background-color: lime; }
.UI .t2:disabled > .unitTest { background-color: lime; }
.UI .t3:checked + div { background-color: lime; }
.UI .t4:not(:checked) + div { background-color: lime; }
/* ~ combinator tests */
.tilda { clear: both; height: auto; padding-top: 6px;}
.tilda .t1 { background-color: white; }
.tilda .t1 ~ .unitTest { background-color: lime; }
.tilda .t1:hover ~ .unitTest { background-color: red; }
/* ~ combinator tests */
.plus { clear: both; height: auto; padding-top: 6px;}
.plus .t1, .plus .t2 { background-color: white; }
.plus .t1 + .unitTest + .unitTest { background-color: lime; }
.plus .t1:hover + .unitTest + .unitTest { background-color: red; }
-->
</style>
</head>
<body title="childhood and element type selectors">
<div class="header">
<h3>CSS 3 Selectors tests</h3>
<p><small><a href="http://www.disruptive-innovations.com/zoo/css3tests/selectorTest.html">Original</a> CSS work by
Daniel Glazman (c) <a href="http://www.disruptive-innovations.com">Disruptive Innovations</a> 2008</small></p>
<p>Testing code written by <a href="http://javascript.nwbox.com">Diego Perini</a>. It should help improve the
consistency with <code>querySelectorAll</code> results and match browsers internal CSS selectors behavior.
Selection method calls are wrapped in a try/catch block for all libs to avoid possible errors preventing the
tests to complete. Moving the mouse over the red/lime blocks will show the tooltips with info on the tests.</p>
</div>
<div class="test target">
<div class="unitTest" id="target" title=":target selector"></div>
</div>
<div class="test">
<div class="blox1 unitTest" title="childhood selector"></div>
</div>
<div class="test attributeExistence">
<div class="blox2 unitTest" align="center" title="attribute existence selector"></div>
<div class="blox3 unitTest" align="" title="attribute existence selector with empty string value"></div>
<div class="blox4 unitTest" valign="center" title="attribute existence selector with almost identical attribute"></div>
<div class="blox5 unitTest" alignv="center" title="attribute existence selector with almost identical attribute"></div>
</div>
<div class="test attributeValue">
<div class="blox6 unitTest" align="center" title="attribute value selector"></div>
<div class="blox6 unitTest" foo="é" title="attribute value selector with an entity in the attribute and an escaped value in the selector"></div>
<div class="blox6 unitTest" _foo="é" title="attribute value selector with an entity in the attribute, an escaped value in the selector, and a leading underscore in the attribute name"></div>
</div>
<div class="test attributeSpaceSeparatedValues">
<div class="blox7 foo unitTest" title="[~=] attribute selector"></div>
<div class="blox8 unitTest" title="[~=] attribute selector looking for empty string"></div>
<div class="blox9 unitTest" foo="" title="[~=] attribute selector looking for empty string in empty attribute"></div>
<div class="blox10 unitTest" foo="foobar" title="[~=] attribute selector looking for 'foo' in 'foobar'"></div>
</div>
<div class="test attrStart">
<div class="unitTest t1" title="[^=] attribute selector"></div>
<div class="unitTest t2" title="[^=] attribute selector"></div>
<div class="unitTest t3" align="center" title="[^=] attribute selector looking for empty string"></div>
<div class="unitTest t4" foo="étagada" title="[^=] attribute selector looking for é"></div>
</div>
<div class="test attrEnd">
<div class="unitTest t1" title="[$=] attribute selector"></div>
<div class="unitTest t2" title="[$=] attribute selector"></div>
<div class="unitTest t3" align="center" title="[$=] attribute selector looking for empty string"></div>
<div class="unitTest t4" foo="tagadaé" title="[$=] attribute selector looking for é"></div>
</div>
<div class="test attrMiddle">
<div class="unitTest t1" title="[*=] attribute selector"></div>
<div class="unitTest t2" title="[*=] attribute selector"></div>
<div class="unitTest t3" align="center" title="[*=] attribute selector looking for empty string"></div>
<div class="unitTest t4" foo="tagadaéfoo" title="[*=] attribute selector looking for é"></div>
</div>
<div class="test firstChild">
<div class="unitTest" title=":first-child selector"></div>
<div class="blox12 unitTest" title=":first-child selector should not match non first child"></div>
<div class="blox13 unitTest" title=":first-child selector should not match non first child"></div>
</div>
<div class="test not">
<div class="blox14 unitTest" title="negation pseudo-class with argument being an element type selector"></div>
<div class="blox15 unitTest" foo="blox15" title="negation pseudo-class with argument being an attribute selector"></div>
<div class="blox16 unitTest" foo="blox15" title="negation pseudo-class accepts only simple selectors for argument"></div>
</div>
<div class="test onlyOfType">
<div class="blox17 unitTest" title=":only-of-type selector"></div>
<p class="blox18 unitTest" title="negated :only-of-type selector"></p>
<p class="blox18 unitTest" title="negated :only-of-type selector"></p>
</div>
<div class="test nthchild1">
<div class="unitTest" title=":nth-child(odd) selector"></div>
<div class="unitTest" title=":nth-last-child(odd) selector"></div>
<div class="unitTest" title=":nth-child(odd) selector"></div>
<div class="unitTest" title=":nth-last-child(odd) selector"></div>
<div class="unitTest" title=":nth-child(odd) selector"></div>
<div class="unitTest" title=":nth-last-child(odd) selector"></div>
</div>
<div class="test nthchild2">
<div class="unitTest" title=":nth-last-child(even) selector"></div>
<div class="unitTest" title=":nth-child(even) selector"></div>
<div class="unitTest" title=":nth-last-child(even) selector"></div>
<div class="unitTest" title=":nth-child(even) selector"></div>
<div class="unitTest" title=":nth-last-child(even) selector"></div>
<div class="unitTest" title=":nth-child(even) selector"></div>
</div>
<div class="test nthchild3">
<div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
<div class="unitTest" title=":nth-child(3n+2) selector"></div>
<div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
<div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
<div class="unitTest" title=":nth-child(3n+2) selector"></div>
<div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
</div>
<div class="test nthoftype1">
<div class="unitTest" title=":nth-of-type(odd) selector"></div>
<p class="unitTest"></p>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-of-type(odd) selector"></div>
<div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
</div>
<div class="test nthoftype2">
<div class="unitTest" title=":nth-last-of-type(even) selector"></div>
<p class="unitTest"></p>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-of-type(even) selector"></div>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-last-of-type(even) selector"></div>
<div class="unitTest" title=":nth-of-type(even) selector"></div>
</div>
<div class="test nthoftype3">
<div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
<p class="unitTest"></p>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
<div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
<p class="unitTest"></p>
<div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
<div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
</div>
<div class="test lastChild">
<p class="unitTest" title=":not(:last-child) selector"></p>
<div class="unitTest" title=":last-child selector"></div>
</div>
<div class="test firstOfType">
<p class="unitTest" title=":first-of-type selector"></p>
<div class="unitTest" title=":first-of-type selector"></div>
<p class="unitTest" title=":not(:first-of-type)"></p>
<div class="unitTest" title=":not(:first-of-type)"></div>
</div>
<div class="test lastOfType">
<p class="unitTest" title=":not(:last-of-type)"></p>
<div class="unitTest" title=":not(:last-of-type)"></div>
<p class="unitTest" title=":last-of-type selector"></p>
<div class="unitTest" title=":last-of-type selector"></div>
</div>
<div class="test onlyChild">
<div class="unitTest" title=":only-child where the element is NOT the only child"></div>
<div class="unitTest">
<div class="unitTest" title=":only-child where the element is the only child"></div>
</div>
</div>
<div class="test onlyOfType">
<p class="unitTest" title=":only-of-type"></p>
<div class="unitTest">
<div class="unitTest" title=":only-of-type"></div>
</div>
<div class="unitTest" title=":not(only-of-type)"></div>
</div>
<div class="test empty">
<div class="unitTest isEmpty" title=":empty with empty element"></div>
<div class="unitTest isNotEmpty" title=":empty but element contains a whitespace"> </div>
<div class="unitTest isEmpty" title=":empty and element contains an SGML comment"><!-- foo --></div>
<div class="unitTest isNotEmpty" title=":empty but element contains a SPAN element"><span></span></div>
<div class="unitTest isNotEmpty" title=":empty but element contains an entity reference"> </div>
</div>
<div class="test lang">
<div class="unitTest" title=":lang() where language comes from the document"></div>
<div class="unitTest" lang="fr" title=":lang() where language comes from the element"></div>
<div class="unitTest" lang="en-US" title=":lang() where language comes from the element but is a dialect of the language queried"></div>
<div class="unitTest t1" lang="es" title=":lang() where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
</div>
<div class="test attrLang">
<div class="unitTest t1" title="[|=] where language comes from the document"></div>
<div class="unitTest" lang="fr" title="[|=] where language comes from the element"></div>
<div class="unitTest t2" lang="en-US" title="[|=] where language comes from the element but is a dialect of the language queried"></div>
<div class="unitTest t3" lang="es" title="[|=] where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
</div>
<div class="footer">
<h4>NOTE:</h4>
<ul>
<li>- the native querySelectorAll and querySelector methods are overwritten to force frameworks to use fall back</li>
<li>- the :root pseudo-class in the original test have been removed since it has no wide support across frameworks</li>
<li>- the dynamic part of the original test have been removed since this test only apply static style to elements</li>
<li>- frameworks bugs fixing abilities can be evaluated by running this test in FF 3, Safari 3, Opera 9 or IE6/7/8</li>
</ul>
</div>
</body>
</html>
|