Skip to content

Commit de1836a

Browse files
authored
Merge pull request #1 from elacuesta/add_support_for_has_revert_xpath_translation_change
Revert xpath translation change to make it consistent
2 parents b64eacf + 72bd776 commit de1836a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cssselect/xpath.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ def xpath_relation_child_combinator(self, left, right):
403403

404404
def xpath_relation_direct_adjacent_combinator(self, left, right):
405405
"""right is a sibling immediately after left; select left"""
406-
xpath = left.add_condition("following-sibling::{}[position() = 1]".format(right.element))
406+
xpath = left.add_condition(
407+
"following-sibling::*[(name() = '{}') and (position() = 1)]".format(right.element)
408+
)
407409
return xpath
408410

409411
def xpath_relation_indirect_adjacent_combinator(self, left, right):

tests/test_cssselect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def xpath(css):
516516
assert xpath("e:has(~ f)") == "e[following-sibling::f]"
517517
assert (
518518
xpath("e:has(+ f)")
519-
== "e[following-sibling::f[position() = 1]]"
519+
== "e[following-sibling::*[(name() = 'f') and (position() = 1)]]"
520520
)
521521
assert xpath('e f') == (
522522
"e/descendant-or-self::*/f")

0 commit comments

Comments
 (0)