Skip to content

is it possible to use style objects like JSX? #143

@leeoniya

Description

@leeoniya

i'd like to do some variant of below and have ivi diff the style object for me and apply only what changed. and maybe auto-optimize for cached style objects by referential consistency.

let style = {color: 'red', background: 'green'};
let tpl = html`<td style=${style}>123</td>`;

or a . variant:

let tpl = html`<td .style=${style}>123</td>`;

use case is something like table column or cell styles that have to be determined on the fly / from user config/localStorage.

i guess alternative would be something like using stylis for runtime css class attr generation. this doesn't quite work well if you allow e.g. coloring cells by their value (and styling the value somehow) where you can end up with like 100 classNames to generate instead of just directly assigning the computed styles to the cell from some calculation.

bonus (a bit more theoretical than real use case currently):
the same question for JSX element ...props spreads, in ivi's case it would be spreading attrs or other DOM element props (not component call args).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions