Thread
#compose-web
    Big Chungus

    Big Chungus

    11 months ago
    Is it possible to set a boolean html attribute (not property) with compose? attr("name", true.unsafeCast<String>()) sets it as name="", whereas it should set it as just name with no empty string value.
    rnett

    rnett

    11 months ago
    Isn't the convention for flag properties to do
    $name="$name"
    ?
    Big Chungus

    Big Chungus

    11 months ago
    Haven't tried that yet, will give it a go and report back
    shikasd

    shikasd

    11 months ago
    attr("name", "true")
    ?
    Big Chungus

    Big Chungus

    11 months ago
    Nope, that one is read as true even if you pass in false value
    a

    Akif Abasov [JB]

    11 months ago
    I believe it’s because of this behaviour of
    setAttribute
    Can you specify your use case?
    Big Chungus

    Big Chungus

    11 months ago
    Setting
    checked
    attribute on input element. Here's the end result I'm chasing:
    <input type="checkbox" checked></input>
    And i need that to be an html attribute as opposed to property
    a

    Akif Abasov [JB]

    11 months ago
    We will take a look how to manage it.
    Is workaround clear for you until that? using dom effect.
    Big Chungus

    Big Chungus

    11 months ago
    Yeah, but it's kinda ugly 😀
    [JB] Shagen

    [JB] Shagen

    11 months ago
    Correct me if I'm wrong but boolean attribute with space is actually by spec a valid way to switch it "on". Not saying we shouldn't discuss API improvements, just want to see the whole picture
    Big Chungus

    Big Chungus

    11 months ago
    That might be true by spec, but many web frameworks don't follow it and demand empty attr without a value to work