Skip to content

CSS content does not update on CSS counter changes #4866

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

Open
1 task done
manuel-za opened this issue May 23, 2025 · 0 comments · May be fixed by #4890
Open
1 task done

CSS content does not update on CSS counter changes #4866

manuel-za opened this issue May 23, 2025 · 0 comments · May be fixed by #4890

Comments

@manuel-za
Copy link
Contributor

manuel-za commented May 23, 2025

Ladybird now supports CSS counters. Nice! 😎
However, content containing counters does not update on changes to counters. On, no! 😦

Reproduce

  1. Think of a counter, say, item
  2. Increment it in a class, say, .Inc
  3. Include counter(item) as content in div::before
  4. Apply .Inc to two consecutive divs
    • If you stopped here, the divs will be prefixed by the right counters ("1", "2"). Nice!
  5. After loading, remove .Inc from the first div

Expected: The divs should be prefixed by "0" and "1".
Actual: The prefixes to the divs stay the same "1" and "2".

A more elaborate example

<style>
div > div::before { content: counter(item) '. '; }

.Res4 { counter-reset: item 4; }
.Inc1 { counter-increment: item; }
.Set8 { counter-set: item 8; }

.Fade { opacity: 20%; }
</style>
<script>
window.addEventListener('load', () => {
    document.getElementById('button').addEventListener('click', (e) => {
        document.getElementById('zero' ).classList.toggle('Res4');
        document.getElementById('five' ).classList.toggle('Inc1');
        document.getElementById('six'  ).classList.toggle('Inc1');
        document.getElementById('eight').classList.toggle('Set8');
        document.getElementById('nine' ).classList.toggle('Inc1');

        document.querySelectorAll('span').forEach( e => {
            e.classList.toggle('Fade');
        });
    });
});
</script>

<div id='zero' class='Res4'>
    <div id='five'  class='Inc1'><span>Five </span> <span class='Fade'>Zero</span></div>
    <div id='six'   class='Inc1'><span>Six  </span> <span class='Fade'>Zero</span></div>
    <div id='eight' class='Set8'><span>Eight</span> <span class='Fade'>Zero</span></div>
    <div id='nine'              ><span>Eight</span> <span class='Fade'>One </span></div>
</div>

<br/>

<button id='button'>click this</button>

Firefox:

Image Image

Ladybird:

Image Image

  • I’ll contribute a patch for this myself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant