Skip to content

[css-lists-3] counter-set vs counter-increment #3810

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

Closed
fantasai opened this issue Apr 6, 2019 · 5 comments
Closed

[css-lists-3] counter-set vs counter-increment #3810

fantasai opened this issue Apr 6, 2019 · 5 comments

Comments

@fantasai
Copy link
Collaborator

fantasai commented Apr 6, 2019

Re: Counter properties in CSS Lists Editor's Draft

There's some ergonomc awkwardness about counter-set vs counter-increment, e.g. in #3686 it's pointed out that you'd have to zero out the list-item increment when setting the counter for

  • . (This particular case is technically problematic as well as unweildy because it'd get wiped out by an author counter-increment declaration; but there's some awkwardness either way and it doesn't cascade well for anyone.)

    I'm wondering if instead of applying counter-reset, then counter-set, then counter-increment, we should apply counter-reset, then counter-increment, then counter-set? Then when you “set” a counter on an element, you actually get that value back, which seems a little more intuitive (and also solves the list-item problem).

  • @fantasai fantasai added the css-lists-3 Current Work label Apr 6, 2019
    @fantasai
    Copy link
    Collaborator Author

    fantasai commented Apr 6, 2019

    It also gives better cascading behavior in general (not just for the author/ua list-item negotiation).

    @AmeliaBR
    Copy link
    Contributor

    AmeliaBR commented Apr 6, 2019

    Does counter-set have any implementations? That could create compat issues.

    If there's no compatibility objections, I agree that it is preferable if counter-set overrides any increments. If I specify counter-set: chapter 5, that's probably what I want.

    The downside is that counter-reset: chapter 5 would work differently; an increment declared on the same element would add to the initial value. But that's less likely to be a problem once counter-set is supported; counter-reset can be used as intended, on the parent element that defines the counter scope.

    @emilio
    Copy link
    Collaborator

    emilio commented Apr 6, 2019

    There's Gecko's implementation, but that's not on release yet so we can change that without much hassle I'd guess.

    But I'd rather get a speedy resolution than doing it once it's hit release.

    cc @MatsPalmgren in case he has objections.

    @MatsPalmgren
    Copy link

    I like this proposal. It makes counter-set simpler to use for authors and implementors alike. In particular, we can now map

  • to just counter-set: list-item N making it independent of any counter-increment the author might have on that element (as @heycam noted as a problem in #3686 (comment)).

    (I'm fixing Gecko here.)

  • @css-meeting-bot
    Copy link
    Member

    The CSS Working Group just discussed apply counter-set after counter-increment, and agreed to the following:

    • RESOLVED: apply counter-set after counter-increment
    The full IRC log of that discussion Topic:apply counter-set after counter-increment
    github: https://github.com//issues/3810
    fantasai: This was an issue around interaction. Property values you have to set if you're incremeneting on every item and want to set to a particular value. yOu have to set it minus increment. That's ergonomically awk
    (I'm in favor)
    fantasai: Suggestion is set counter set after increment so if you set foo 5 it will be 5 no matter the counter increment
    fantasai: Generally better cascading behavior. Counterset wins over counter incrememnt rather than adding to it.
    gregwhitworth: When you set counterset it starts from that place?
    fantasai: Sets an explicit value for the counter
    gregwhitworth: And doesn't inc after that?
    fantasai: If you have nth-child 5 counterset: chapter 5 it will have 5 instead of the increment added to that.
    gregwhitworth: Then increment from 5?
    fantasai: On other elements, yeah.
    fantasai: On a particular element you apply counter-reset then counter increment then counter set
    plinss: Makes sense to me. Looking at issue Gecko impl but will change. Any other impl here?
    fantasai: I think they're only ones. They committed the fix a day ago
    plinss: Objections?
    RESOLVED: apply counter-set after counter-increment

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants