@@ -101,12 +101,11 @@ public function getCssToXPathTestData()
101
101
array ('e[foo*="bar"] ' , "e[@foo and contains(@foo, 'bar')] " ),
102
102
array ('e[hreflang|="en"] ' , "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))] " ),
103
103
array ('e:nth-child(1) ' , "*/*[name() = 'e' and (position() = 1)] " ),
104
- array ('e:nth-last-child(1) ' , "*/*[name() = 'e' and (position() = last() - 1 )] " ),
105
- array ('e:nth-last-child(2n+2) ' , "*/*[name() = 'e' and (( position() +2) mod -2 = 0 and position() < (last( ) -2) )] " ),
104
+ array ('e:nth-last-child(1) ' , "*/*[name() = 'e' and (position() = last() - 0 )] " ),
105
+ array ('e:nth-last-child(2n+2) ' , "*/*[name() = 'e' and (last() - position() - 1 > = 0 and (last() - position( ) - 1) mod 2 = 0 )] " ),
106
106
array ('e:nth-of-type(1) ' , "*/e[position() = 1] " ),
107
- array ('e:nth-last-of-type(1) ' , "*/e[position() = last() - 1] " ),
108
- array ('e:nth-last-of-type(1) ' , "*/e[position() = last() - 1] " ),
109
- array ('div e:nth-last-of-type(1) .aclass ' , "div/descendant-or-self::*/e[position() = last() - 1]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')] " ),
107
+ array ('e:nth-last-of-type(1) ' , "*/e[position() = last() - 0] " ),
108
+ array ('div e:nth-last-of-type(1) .aclass ' , "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')] " ),
110
109
array ('e:first-child ' , "*/*[name() = 'e' and (position() = 1)] " ),
111
110
array ('e:last-child ' , "*/*[name() = 'e' and (position() = last())] " ),
112
111
array ('e:first-of-type ' , "*/e[position() = 1] " ),
@@ -121,7 +120,7 @@ public function getCssToXPathTestData()
121
120
array ('e:ConTains(foo) ' , "e[contains(string(.), 'foo')] " ),
122
121
array ('e.warning ' , "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')] " ),
123
122
array ('e#myid ' , "e[@id = 'myid'] " ),
124
- array ('e:not(:nth-child(odd)) ' , "e[not(( position() -1) mod 2 = 0 and position() >= 1 )] " ),
123
+ array ('e:not(:nth-child(odd)) ' , "e[not(position() - 1 > = 0 and ( position() - 1) mod 2 = 0 )] " ),
125
124
array ('e:nOT(*) ' , "e[0] " ),
126
125
array ('e f ' , "e/descendant-or-self::*/f " ),
127
126
array ('e > f ' , "e/f " ),
@@ -188,17 +187,32 @@ public function getHtmlIdsTestData()
188
187
array ('li:nth-child(+2n+1) ' , array ('first-li ' , 'third-li ' , 'fifth-li ' , 'seventh-li ' )),
189
188
array ('li:nth-child(odd) ' , array ('first-li ' , 'third-li ' , 'fifth-li ' , 'seventh-li ' )),
190
189
array ('li:nth-child(2n+4) ' , array ('fourth-li ' , 'sixth-li ' )),
191
- // FIXME: I'm not 100% sure this is right:
192
190
array ('li:nth-child(3n+1) ' , array ('first-li ' , 'fourth-li ' , 'seventh-li ' )),
193
- array ('li:nth-last-child(0) ' , array ('seventh-li ' )),
191
+ array ('li:nth-child(n) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
192
+ array ('li:nth-child(n-1) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
193
+ array ('li:nth-child(n+1) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
194
+ array ('li:nth-child(n+3) ' , array ('third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
195
+ array ('li:nth-child(-n) ' , array ()),
196
+ array ('li:nth-child(-n-1) ' , array ()),
197
+ array ('li:nth-child(-n+1) ' , array ('first-li ' )),
198
+ array ('li:nth-child(-n+3) ' , array ('first-li ' , 'second-li ' , 'third-li ' )),
199
+ array ('li:nth-last-child(0) ' , array ()),
194
200
array ('li:nth-last-child(2n) ' , array ('second-li ' , 'fourth-li ' , 'sixth-li ' )),
195
201
array ('li:nth-last-child(even) ' , array ('second-li ' , 'fourth-li ' , 'sixth-li ' )),
196
- array ('li:nth-last-child(2n+2) ' , array ('second-li ' , 'fourth-li ' )),
202
+ array ('li:nth-last-child(2n+2) ' , array ('second-li ' , 'fourth-li ' , 'sixth-li ' )),
203
+ array ('li:nth-last-child(n) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
204
+ array ('li:nth-last-child(n-1) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
205
+ array ('li:nth-last-child(n-3) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
206
+ array ('li:nth-last-child(n+1) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
207
+ array ('li:nth-last-child(n+3) ' , array ('first-li ' , 'second-li ' , 'third-li ' , 'fourth-li ' , 'fifth-li ' )),
208
+ array ('li:nth-last-child(-n) ' , array ()),
209
+ array ('li:nth-last-child(-n-1) ' , array ()),
210
+ array ('li:nth-last-child(-n+1) ' , array ('seventh-li ' )),
211
+ array ('li:nth-last-child(-n+3) ' , array ('fifth-li ' , 'sixth-li ' , 'seventh-li ' )),
197
212
array ('ol:first-of-type ' , array ('first-ol ' )),
198
- array ('ol:nth-child(1) ' , array ()),
213
+ array ('ol:nth-child(1) ' , array (' first-ol ' )),
199
214
array ('ol:nth-of-type(2) ' , array ('second-ol ' )),
200
- // FIXME: like above (1) or (2)?
201
- array ('ol:nth-last-of-type(1) ' , array ('first-ol ' )),
215
+ array ('ol:nth-last-of-type(1) ' , array ('second-ol ' )),
202
216
array ('span:only-child ' , array ('foobar-span ' )),
203
217
array ('li div:only-child ' , array ('li-div ' )),
204
218
array ('div *:only-child ' , array ('li-div ' , 'foobar-span ' )),
0 commit comments