Skip to content
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

Add :upward support #102

Closed
AdamWr opened this issue Mar 9, 2020 · 5 comments
Closed

Add :upward support #102

AdamWr opened this issue Mar 9, 2020 · 5 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Mar 9, 2020

In uBlock Origin :upward() will be a synonim for :nth-ancestor, so I think it would be a good idea to supports it too.

More details - gorhill/uBlock@72bb700

@ameshkov ameshkov added this to the 1.3 milestone Mar 9, 2020
@slavaleleka
Copy link
Contributor

Although "upward" is based directly on Xpath, I've found that number-based "upward" entries can be converted into pre-existing AdGuard/ABP syntax with ease.
E.g. example.org##.element:upward(2) → example.org#?#*:-abp-has(> * > .element)

@AdamWr
Copy link
Member Author

AdamWr commented Jul 29, 2020

Positive number >= 1 and < 256, distance from the currently selected node.

If I understand correctly, rule like this:
example.org#?#a:upward(0)
or this:
example.org#?#a:upward(256)
should be treated as invalid, but it seems that currently the first one (example.org#?#a:upward(0)) works the same as:
example.org#?#a:upward(1)

Link - http://example.org/

@AdamWr
Copy link
Member Author

AdamWr commented Aug 4, 2020

Limited to work properly only at the end of selector, except of pseudo-class :remove().

What is the reason of this limitation?
I mean that in third party filters there are few rules like this #?#selector:upward(1) + anotherSelector, so these rules will not work.

For example in Swedish filter:

tidningen.nu##span:has-text(/^Annons$/):upward(1) + .textwidget
viafree.se##.vjs-playing:upward(1) ~ .no-autoplay-overlay

https://github.com/AdguardTeam/FiltersRegistry/blob/6cce7c92672856220f256e85a26a2494196e35c3/filters/ThirdParty/filter_243_FrellwitSwedish/diff.txt#L200

@ameshkov
Copy link
Member

ameshkov commented Aug 4, 2020

@slavaleleka the question makes perfect sense, what's the reason for this limitation?

@slavaleleka slavaleleka reopened this Aug 4, 2020
@ameshkov
Copy link
Member

ameshkov commented Aug 4, 2020

Actually, this won't be easy to handle at least until we ditch Sizzle. Let's live with this limitation for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants