Make ":has"/":has-text" equivalent to ":-abp-has"/":-abp-contains"
Background
Now that I've become an employee of Eyeo GmbH as of today, that should hopefully give me a bit more clout to influence the codebase to make it more suited for all the listmakers out there.
Essentially, I've noticed that many listmakers out there, somewhere north of 50%, possibly as many as 80%, are completely unaware of the existence of the :-abp-has
and :-abp-contains
syntaxes. Instead they only know about :has
and :has-text
, thinking that such pseudo-selectors are non-existent in ABP, and they also often lock them behind !#include
file-loadings meant for uBlock Origin).
This makes their lists often work considerably worse in ABP than in other major adblockers. Example of general unawareness among listmakers: The ":has" entries in the extra-file of Frellwit's Swedish Filters
In other cases, they may be unaware of such pseudoselectors at all, which means their lists are still pretty much only using 2015-16-era ABP syntaxes. Example: Slovenian List
What to change
Create a syntax synonym(?) where :has
entries are treated as :-abp-has
, and :has-text
entries are treated as :-abp-contains
.
For 100% implementation of this, it may also become necessary to have ABP begin to treat all entries as if they had question marks in the hashtags (e.g. #?#.
), since question-mark use is also pretty rare among listmakers who are more familiar with uBO. I plan to make a separate issue report for that, if this particular issue report became a success. In fact I have a lot of change suggestions I could've made in the next couple weeks or so.
It is decided to keep the Element Hiding Emulation separator #?#
as a requirement.
- uBO silently converts
#?#
into##
, so filters' authors can write#?#:has(...)
once, and see this working as expected in multiple extensions. AdGuard supports it. -
##:has(...)
will be CSS4 native spec and is not widely available yet. When it is it can be used, still with the condition that the browser supports it without change he. - we keep separated our own emulation vs native CSS as it may have subtle behaviour difference that could break when the is a native CSS4 implementation. Also there is no
:has-text()
in any current proposal, so this ensure there is no long term conflict.
Ref: https://github.com/uBlockOrigin/uBlock-issues/issues/1011#issuecomment-884839072
Hints for testers
- Any filter
#?#
with:-abp-has()
or:-abp-has-content()
can be duplicated and changed to:has()
and:has-text()
.:-abp-has()
and:-abp-has-content()
remain unchanged -
##:has()
and##:has-text()
don't work (behaviour unchanged) - testpages could be updated, albeit it's not backward compatible
Integration notes
- If any validation was performed, this new allowance in the syntax might need to be taken care of.
- Documentation should be updated.