File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
ext/dom/tests/querySelector Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ CSS Selectors - Pseudo classes: nth-child of
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+
8
+ require __DIR__ . '/test_utils.inc ' ;
9
+
10
+ $ dom = DOM \XMLDocument::createFromString (<<<XML
11
+ <container>
12
+ <h2 class="hi">1</h2>
13
+ <h2>2</h2>
14
+ <h2 class="hi">3</h2>
15
+ <h2 class="hi">4</h2>
16
+ <h2>5</h2>
17
+ <h2 class="hi">6</h2>
18
+ </container>
19
+ XML );
20
+
21
+ test_helper ($ dom , 'h2:nth-child(even of .hi) ' );
22
+ test_helper ($ dom , 'h2.hi:nth-child(even) ' );
23
+ test_helper ($ dom , 'h2:nth-child(odd of .hi) ' );
24
+ test_helper ($ dom , 'h2.hi:nth-child(odd) ' );
25
+
26
+ test_helper ($ dom , 'h2:nth-last-child(even of .hi) ' );
27
+ test_helper ($ dom , 'h2.hi:nth-last-child(even) ' );
28
+ test_helper ($ dom , 'h2:nth-last-child(odd of .hi) ' );
29
+ test_helper ($ dom , 'h2.hi:nth-last-child(odd) ' );
30
+
31
+ ?>
32
+ --EXPECT--
33
+ --- Selector: h2:nth-child(even of .hi) ---
34
+ <h2 class="hi">3</h2>
35
+ <h2 class="hi">6</h2>
36
+ --- Selector: h2.hi:nth-child(even) ---
37
+ <h2 class="hi">4</h2>
38
+ <h2 class="hi">6</h2>
39
+ --- Selector: h2:nth-child(odd of .hi) ---
40
+ <h2 class="hi">1</h2>
41
+ <h2 class="hi">4</h2>
42
+ --- Selector: h2.hi:nth-child(odd) ---
43
+ <h2 class="hi">1</h2>
44
+ <h2 class="hi">3</h2>
45
+ --- Selector: h2:nth-last-child(even of .hi) ---
46
+ <h2 class="hi">1</h2>
47
+ <h2 class="hi">4</h2>
48
+ --- Selector: h2.hi:nth-last-child(even) ---
49
+ <h2 class="hi">1</h2>
50
+ <h2 class="hi">3</h2>
51
+ --- Selector: h2:nth-last-child(odd of .hi) ---
52
+ <h2 class="hi">3</h2>
53
+ <h2 class="hi">6</h2>
54
+ --- Selector: h2.hi:nth-last-child(odd) ---
55
+ <h2 class="hi">4</h2>
56
+ <h2 class="hi">6</h2>
You can’t perform that action at this time.
0 commit comments