Opened 4 months ago

Closed 2 months ago

Last modified 4 weeks ago

#5339 closed change (fixed)

Properly select element from pseudo-element

Reported by: hfiguiere Assignee: hfiguiere
Priority: P2 Milestone:
Module: Core Keywords:
Cc: fhd, trev, arthur, sebastian, mapx, greiner Blocked By:
Blocking: #5000 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29481700

Description (last modified by trev)

Background

We need to be able to match CSS properties in the ::before and ::after pseudo elements.

What to change

When styles from a pseudo-element like foo::before match a CSS properties filter, make sure to hide the actual DOM element (this would be foo here).

See also

Change History (16)

comment:1 Changed 4 months ago by hfiguiere

  • Summary changed from Implement :-abp-properties-before and -abp-properties-after to Implement :-abp-properties-before and :-abp-properties-after

comment:2 Changed 4 months ago by hfiguiere

  • Cc fhd trev arthur added

comment:3 follow-up: Changed 4 months ago by sebastian

  • Cc sebastian added

Is there any particular website in the wild, where we'd need this for?

comment:4 Changed 4 months ago by mapx

  • Cc mapx added

comment:5 in reply to: ↑ 3 Changed 4 months ago by mapx

Replying to sebastian:

Is there any particular website in the wild, where we'd need this for?

https://github.com/uBlockOrigin/uAssets/issues/357

comment:6 Changed 4 months ago by hfiguiere

  • Owner set to hfiguiere
  • Review URL(s) modified (diff)

comment:7 Changed 4 months ago by hfiguiere

  • Status changed from new to reviewing

comment:8 Changed 3 months ago by hfiguiere

  • Blocking 5000 added

comment:9 Changed 3 months ago by greiner

  • Cc greiner added

comment:10 Changed 3 months ago by trev

The way I see it, we will already process CSS rules for ::before and ::after pseudo-elements. However, if these CSS rules match a filter, we will try to hide the pseudo-element rather than the real element. In some cases (pure CSS properties) this succeeds while not producing sufficient results, in others (CSS properties and :-abp-has() combination) it doesn't because the pseudo-elements don't correspond to any DOM elements.

I don't see why we should single out these two pseudo-elements, there are way more listed under https://drafts.csswg.org/css-pseudo-4/. Nor am I convinced that introducing new syntax here is justified. How about we just trim selectors produced for CSS property filters in order to remove the part following ::? This way we could have :-abp-properties(content: "Advertisement") work even if the CSS rule is defined for a pseudo-element.

comment:11 Changed 2 months ago by hfiguiere

  • Description modified (diff)
  • Summary changed from Implement :-abp-properties-before and :-abp-properties-after to Properly select element from pseudo-element.

comment:12 Changed 2 months ago by hfiguiere

  • Summary changed from Properly select element from pseudo-element. to Properly select element from pseudo-element

comment:13 Changed 2 months ago by abpbot

A commit referencing this issue has landed:
Issue 5339 - Properly select element for pseudo-element

comment:14 Changed 2 months ago by hfiguiere

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:15 Changed 8 weeks ago by trev

  • Description modified (diff)
  • Priority changed from Unknown to P2
  • Ready set

comment:16 Changed 4 weeks ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Done. Can match properties in pseudo elements with filters.

ABP 1.13.3.1838
Chrome 52 / 61 / Windows 7
Opera 40 / 47 / Windows 7

Note: See TracTickets for help on using tickets.