esquery icon indicating copy to clipboard operation
esquery copied to clipboard

esquery.matches does not respect subject indicator.

Open ikarienator opened this issue 10 years ago • 0 comments

var esprima = require('esprima');
var esquery = require('esquery');
var ast = esprima.parse('a + !b');
var query = esquery.parse('BinaryExpression! > UnaryExpression.right');

// should be true (does not work)
console.log(esquery.matches(ast.body[0].expression, query, [ast.body[0], ast]));
// should be false (does not work)
console.log(esquery.matches(ast.body[0].expression.right, query, [ast.body[0].expression, ast.body[0], ast]));

// should include only the BinaryExpression (works)
console.log(JSON.stringify(esquery.match(ast, query, []), null, 4));

ikarienator avatar Apr 08 '14 18:04 ikarienator