Closed phoerious closed 1 year ago
@phoerious
I have a feeling that you don't understand how the function lxb_selectors_find_reverse() works. It (the function) checks if the specified selectors match or not by node (html element).
HTML
<body><div><span>blah</span></div></body>
We take a node/element <span>
and check which selectors will fit it.
Selectors:
div span -- match
body span -- match
span div -- not match
It's quite possible that misinterpreted how the function is supposed to work, since there is neither documentation nor an example and I didn't have to time to fully reverse-engineer it.
So from what you are saying, this seems to be more like matches(), but from the name I would expect it to behave like closest().
All right, I have now fixed my closest() implementation and migrated my matches() implementation to also use Lexbor's reverse match:
This works well, thanks for the help. Some API documentation would still be appreciated, though. ;-)
Reverse CSS matching doesn't work beyond the start element itself. There is one unit test that uses
lxb_selectors_find()
, but none forlxb_selectors_find_reverse()
, so perhaps this is a regression.Here are a few reproduction examples as diffs of
examples/lexbor/selectors/easy_way.c
:Example 1:
Output:
WORKS! (self-match)
Example 2:
Expected output:
Actual output:
Example 3:
Expected output:
Actual output: