-
Notifications
You must be signed in to change notification settings - Fork 91
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
allow naked binaryOp at the start of a selector within :has() #145
allow naked binaryOp at the start of a selector within :has() #145
Conversation
Co-authored-by: Richard Silverton <[email protected]>
@michaelficarra please could you have a look at this? |
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.
Sorry for the delay. This looks great! Thanks for the contribution, @c-harding.
const deepChildMatches = esquery(conditional, 'IfStatement:has(> Identifier[name="x"])'); | ||
assert.equal(0, deepChildMatches.length); | ||
|
||
const shallowChildMatches = esquery(conditional, 'IfStatement:has(> LogicalExpression.test, > Identifier[name="x"])'); |
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.
hey I tried to use a more complex version of this:
it('fails repeated and nested', function () {
const matches = esquery(
esprima.parse(`
if (x) foo; // Target
if (x) { foo; }
if (y) { foo; }
if (x) bar;
`),
'IfStatement:has(>Identifier[name="x"]):has(>ExpressionStatement>Identifier[name="foo"])'
);
assert.equal(1, matches.length);
});
and it doesn't work. Any ideas why, in case this is still fresh on your mind? I found this as a workaround in the mean time:
it('workaround', function () {
const matches = esquery(
esprima.parse(`
if (x) foo; // Target
if (x) { foo; }
if (y) { foo; }
if (x) bar;
`),
'IfStatement:has(>Identifier[name="x"]):has(>ExpressionStatement:has(>Identifier[name="foo"]))'
);
assert.equal(1, matches.length);
});
and extracted a simpler to reproduce test case into #146
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went 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.
An attempt to fix the complex queries #148
Based on #133, rebased and updated to handle @michaelficarra’s PR feedback
Fixes #132