Skip to content

Commit 653a5a5

Browse files
committed
Merge pull request #20 from sjp/master
Have :empty not match whitespace-only elements.
2 parents 7712c2a + ac10a36 commit 653a5a5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cssselect/tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ def xpath(css):
344344
assert xpath('e:only-of-type') == (
345345
"e[last() = 1]")
346346
assert xpath('e:empty') == (
347-
"e[not(*) and not(normalize-space())]")
347+
"e[not(*) and not(string-length())]")
348348
assert xpath('e:EmPTY') == (
349-
"e[not(*) and not(normalize-space())]")
349+
"e[not(*) and not(string-length())]")
350350
assert xpath('e:root') == (
351351
"e[not(parent::*)]")
352352
assert xpath('e:hover') == (
@@ -575,7 +575,7 @@ def pcss(main, *selectors, **kwargs):
575575
assert pcss('p:only-of-type') == ['paragraph']
576576
assert pcss('a:empty', 'a:EMpty') == ['name-anchor']
577577
assert pcss('li:empty') == [
578-
'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']
578+
'third-li', 'fourth-li', 'fifth-li', 'sixth-li']
579579
assert pcss(':root', 'html:root') == ['html']
580580
assert pcss('li:root', '* :root') == []
581581
assert pcss('*:contains("link")', ':CONtains("link")') == [

cssselect/xpath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def xpath_only_of_type_pseudo(self, xpath):
454454
return xpath.add_condition('last() = 1')
455455

456456
def xpath_empty_pseudo(self, xpath):
457-
return xpath.add_condition("not(*) and not(normalize-space())")
457+
return xpath.add_condition("not(*) and not(string-length())")
458458

459459
def pseudo_never_matches(self, xpath):
460460
"""Common implementation for pseudo-classes that never match."""

0 commit comments

Comments
 (0)