-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support complex selector in not #124
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Eugenio Lacuesta <[email protected]>
…lect into add_support_for_has
…lect into add_support_for_has
…_translation_change Revert xpath translation change to make it consistent
d02d89b
to
2c15198
Compare
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
==========================================
+ Coverage 95.39% 96.01% +0.62%
==========================================
Files 3 3
Lines 803 904 +101
Branches 139 150 +11
==========================================
+ Hits 766 868 +102
+ Misses 20 19 -1
Partials 17 17
Continue to review full report at Codecov.
|
2c15198
to
60a4266
Compare
I've found that at least the Chrome developer console supports this selector, so you can test it on something like: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>
<span a="1"></span>
<span a="2"></span>
<span a="3"></span>
</p>
<div>
<span a="1"></span>
</div>
</body>
</html> |
60a4266
to
90d2eee
Compare
"*[not([a] and following-sibling::*[b])]" | ||
) # select anything that is not b or doesn't have a sibling a | ||
assert xpath("*:not(a b)") == ( | ||
'*[not(name()="b" and ancestor::*[name()="a"])]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should also be applied to other 3 combinators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I suppose the tests should look like this:
assert xpath("*:not(a > b)") == '*[not(name()="b" and parent::*[name()="a"])]' # select anything that is not b or doesn't have a parent a
assert xpath("*:not(a + b)") == '*[not(name()="b" and following-sibling::*[position()=1 and name()="a"])]' # select anything that is not b or doesn't have an immediate sibling a
assert xpath("*:not(a ~ b)") == '*[not(name()="b" and following-sibling::*[name()="a"])]' # select anything that is not b or doesn't have a sibling a
assert xpath("*:not(a b)") == '*[not(name()="b" and ancestor::*[name()="a"])]' # select anything that is not b or doesn't have an ancestor a
please correct me if i'm wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's correct.
90d2eee
to
3c86499
Compare
#51
done: parse complex selector, with any type of combinators (
), translating to xpath all those combinators according to this comment
>
,+
,~
,this pr also includes code from pr to support
:has()
pseudo class