Opened 3 months ago

Last modified 2 months ago

#5864 new change

Maintain one at most one style sheet for element hiding emulation

Reported by: mjethani Assignee: mjethani
Priority: P2 Milestone:
Module: Platform Keywords:
Cc: sebastian, hfiguiere, kzar Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description (last modified by sebastian)


Currently -abp-properties causes multiple style sheets, or multiple sets of selectors (in the case of styles injected into the DOM), to be added to the document as the DOM is updated and new elements are affected.

This HTML, for example:

  .greeting1 { color: blue }
  <h1 class="greeting1">Hello</h1>
  <h1 class="greeting2">Hi</h1>
  setTimeout(() =>
    let style = document.createElement("style");
    style.innerHTML = ".greeting2 { color: blue }";

With the filter localhost#?#h1:-abp-properties(color: blue), the first H1 with the greeting1 class ends up with two sets of selectors applying to it:

h1.greeting1 { display: none !important }
h1.greeting1, h1.greeting2 { display: none !important }

The first set is redundant here.

If style sheets are removed from the document, the elements affected by the change still remain hidden, thus potentially breaking the page's functionality.

What to change

Remove previous stylesheet before adding a new one.

Change History (7)

comment:1 Changed 3 months ago by mjethani

  • Cc sebastian dave added

comment:2 Changed 3 months ago by mjethani

  • Review URL(s) modified (diff)

comment:3 Changed 3 months ago by hfiguiere

  • Cc hfiguiere added

comment:4 Changed 3 months ago by mapx

  • Cc kzar added; dave removed

comment:5 Changed 3 months ago by sebastian

  • Priority changed from Unknown to P2
  • Ready set

comment:6 Changed 3 months ago by sebastian

  • Description modified (diff)

comment:7 Changed 2 months ago by mjethani

  • Owner set to mjethani
Note: See TracTickets for help on using tickets.