Drop nth-child support of all negative sequences
This removes parsing support for selectors such as :nth-child(-n-6). According to the CSS spec this isn't valid anyway (confirmed by testing it in Chromium). As a result there's no point in supporting it in any way.
This commit is contained in:
parent
b31288b7d2
commit
8d8d74ec41
|
@ -413,12 +413,8 @@ end
|
||||||
compare = :lte
|
compare = :lte
|
||||||
end
|
end
|
||||||
|
|
||||||
# -n-6, -n-4, etc
|
|
||||||
if !step and non_positive_number?(offset)
|
|
||||||
node = s(:eq, count_call, s(:int, -1))
|
|
||||||
|
|
||||||
# 2n+2, 2n-4, etc
|
# 2n+2, 2n-4, etc
|
||||||
elsif offset
|
if offset
|
||||||
# -2n
|
# -2n
|
||||||
if step and non_positive_number?(step)
|
if step and non_positive_number?(step)
|
||||||
mod_val = s(:int, -step.children[0])
|
mod_val = s(:int, -step.children[0])
|
||||||
|
|
|
@ -52,12 +52,6 @@ describe Oga::CSS::Parser do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse the x:nth-child(-n-6) pseudo class' do
|
|
||||||
parse_css('x:nth-child(-n-6)').should == parse_xpath(
|
|
||||||
'descendant-or-self::x[count(preceding-sibling::*) = -1]'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
example 'parse the x:nth-child(2n) pseudo class' do
|
example 'parse the x:nth-child(2n) pseudo class' do
|
||||||
parse_css('x:nth-child(2n)').should == parse_css('x:nth-child(even)')
|
parse_css('x:nth-child(2n)').should == parse_css('x:nth-child(even)')
|
||||||
end
|
end
|
||||||
|
@ -83,13 +77,6 @@ describe Oga::CSS::Parser do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse the x:nth-child(-2n-6) pseudo class' do
|
|
||||||
parse_css('x:nth-child(-2n-6)').should == parse_xpath(
|
|
||||||
'descendant-or-self::x[((count(preceding-sibling::*) + 1) <= -2) ' \
|
|
||||||
'and (((count(preceding-sibling::*) + 1) - -2) mod 2) = 0]'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
example 'parse the x:nth-child(-2n+6) pseudo class' do
|
example 'parse the x:nth-child(-2n+6) pseudo class' do
|
||||||
parse_css('x:nth-child(-2n+6)').should == parse_xpath(
|
parse_css('x:nth-child(-2n+6)').should == parse_xpath(
|
||||||
'descendant-or-self::x[((count(preceding-sibling::*) + 1) <= 6) ' \
|
'descendant-or-self::x[((count(preceding-sibling::*) + 1) <= 6) ' \
|
||||||
|
|
|
@ -52,12 +52,6 @@ describe Oga::CSS::Parser do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse the x:nth-last-child(-n-6) pseudo class' do
|
|
||||||
parse_css('x:nth-last-child(-n-6)').should == parse_xpath(
|
|
||||||
'descendant-or-self::x[count(following-sibling::*) = -1]'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
example 'parse the x:nth-last-child(2n) pseudo class' do
|
example 'parse the x:nth-last-child(2n) pseudo class' do
|
||||||
parse_css('x:nth-last-child(2n)').should == parse_css(
|
parse_css('x:nth-last-child(2n)').should == parse_css(
|
||||||
'x:nth-last-child(even)'
|
'x:nth-last-child(even)'
|
||||||
|
|
Loading…
Reference in New Issue