Bug 268597 - Counters and :before interaction with parent element with display:none
Summary: Counters and :before interaction with parent element with display:none
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://forums.developer.apple.com/fo...
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2024-02-01 18:38 PST by Karl Dubost
Modified: 2024-02-21 18:46 PST (History)
4 users (show)

See Also:


Attachments
testcase (3.13 KB, text/html)
2024-02-01 18:38 PST, Karl Dubost
no flags Details
rendering in safari, firefox, chrome after the click (481.58 KB, image/png)
2024-02-01 18:38 PST, Karl Dubost
no flags Details
web inspector (58.41 KB, image/png)
2024-02-04 21:01 PST, Karl Dubost
no flags Details
testcase reduced, but not working (1.96 KB, text/html)
2024-02-04 21:05 PST, Karl Dubost
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Dubost 2024-02-01 18:38:26 PST
Created attachment 469669 [details]
testcase

1. Load the test case
2. Click on More

Expected:
Number 20 is displayed as - [20] -

Actual:
Number 17 is displayed as - [17] -

Both Firefox and Chrome display - [20] - after the click.
Comment 1 Karl Dubost 2024-02-01 18:38:59 PST
Created attachment 469670 [details]
rendering in safari, firefox, chrome after the click
Comment 2 Radar WebKit Bug Importer 2024-02-01 18:39:21 PST
<rdar://problem/122150415>
Comment 3 Karl Dubost 2024-02-04 16:52:31 PST
There is a shorter version there
https://jsfiddle.net/Rolf_b/axjvuo5y/

But it is still a bit hard to understand what is happening. It would be great to be able to reduce the testcase to its absolute minimum, so that the WebKit engineers can clearly easily isolate what is happening.
Comment 4 Karl Dubost 2024-02-04 18:13:25 PST
ok.

The testcase shows two cases (in fact 4 cases with more/less):

The big purple number counts ALL the visible li elements.
My first column is the li element count.
Then the list structure with nested li/ul/li elements.

1 * A1
2 * A2
3 * A3
4   * A3.1
5   * A3.2 (hidden with display:none)
6 * A4 
7   * A4.1
8   * A4.2 (hidden with display:none)
9   * A4.3


So we can see in the HTML, there are 9 li elements.

The total count changes if and only if `::before` is used on all li elements to show the index on each li element.

In Safari:
==========
When all elements are shown (no us of display:none), 
the total count of li elements is:
  * 7 without ::before to display  counter on each li element
  * 9 with ::before

When some elements are hidden (aka two li hidden in the tests):
the total count of li element is 
  * 7 without ::before 
  * 7 with ::before


In Firefox/Chrome:
==================
When all elements are shown (no us of display:none), 
the total count of li elements is:
  * 9 without ::before to display  counter on each li element
  * 9 with ::before

When some elements are hidden (aka two li hidden in the tests):
the total count of li element is 
  * 7 without ::before 
  * 7 with ::before


Safari doesn't count the li elements which start a nested list, textnode or not. (adding text nodes help to understand a bit more the test).
Comment 5 Karl Dubost 2024-02-04 21:01:17 PST
Created attachment 469720 [details]
web inspector

hmm I wonder if it's in fact an issue with nested parsing.
See the attachment
Comment 6 Karl Dubost 2024-02-04 21:05:39 PST
Created attachment 469721 [details]
testcase reduced, but not working

That Said I have not been able to reproduce it yet.
even with a more simplified test case.
Comment 7 Karl Dubost 2024-02-04 21:06:46 PST
Adding Matthieu just in case.
Comment 9 stevestasteislost 2024-02-08 14:46:06 PST
Safari got an update, the bug grew!
Now ::after doesn’t count any more (in the code, where I found this thing).
https://developer.apple.com/forums/thread/745708
Comment 10 stevestasteislost 2024-02-08 15:39:47 PST
Well, not only Safari …
After first having an eye on „my“ bug in Safari, I thought “something else”? And: yes: FireFox doesn’t count too! No hint inside its inspector. But with a closer look I found: FireFox doesn’t apply the ::after to the li-elment. The ::after appears in it’s inspector after the included a.
Instead of
<li class…>
  <a …>…</a>
</li>
::after …
it shows up as
<li class…>
  <a …>…</a>
  ::after …
</li>
Well, this isn’t the place where the stylesheet says “count” …
Comment 11 stevestasteislost 2024-02-21 18:46:07 PST
Latest update for Safari (und Preview) didn’t change the “broken ::after”. Just one thing happened: both, Safari and Firefox (updated too) don’t count any more in my case! All ::after show “1”. But only Safari shows an error(!?!) for the related CSS.