Properly fixed AST for first-of-type/last-of-type
This requires keeping track of the current element being processed. This in turn allows the usage of count() + preceding-sibling/following-sibling.
This commit is contained in:
1 parent
e559b4b89b
commit
1c301d40e2
3 files changed
+54
-9
No files matched your search
@@ -4,13 +4,13 @@ describe Oga::CSS::Parser do
|
||||
context ':first-of-type pseudo class' do
|
||||
example 'parse the :first-of-type pseudo class' do
|
||||
parse_css(':first-of-type').should == parse_xpath(
|
||||
'descendant::*[position() = 1]'
|
||||
'descendant::*[count(preceding-sibling::*) = 0]'
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the a:first-of-type pseudo class' do
|
||||
parse_css('a:first-of-type').should == parse_xpath(
|
||||
'descendant::a[position() = 1]'
|
||||
'descendant::a[count(preceding-sibling::a) = 0]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,13 @@ describe Oga::CSS::Parser do
|
||||
context ':last-of-type pseudo class' do
|
||||
example 'parse the :last-of-type pseudo class' do
|
||||
parse_css(':last-of-type').should == parse_xpath(
|
||||
'descendant::*[position() = last()]'
|
||||
'descendant::*[count(following-sibling::*) = 0]'
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the a:last-of-type pseudo class' do
|
||||
parse_css('a:last-of-type').should == parse_xpath(
|
||||
'descendant::a[count(following-sibling::a) = 0]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user