Skip to content

Can we have a convenience to mutate class by adding a class name instead of replacing the whole attribute value? #182

@Frizlab

Description

@Frizlab

Currently I don’t think there’s a way to modify an attribute by adding stuff to the value; we have to replace everything.

Example of API use I think of, and why it is needed:

Division{ }
   .class("full-height")
   .modify(if: isToday(), element: { $0.addClass("today") /* <== HERE */ })

Possibly some other attributes would benefit from this.

More generally we could have the possibility to access the value of an attribute to be able to at least do something like element.class(element.class + " today") (a bit less elegant, but clients could add an extension on Division in which they would implement addClass that would do the addition; currently AFAICT doing the extension is not even possible).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions