Skip to content

Proposal: Use riot.js super easy event handlers #8

Open

Description

@ilblog

What about this <button on:click="handleClick({ foo: bar })">click me!</button> replace with this <button onclick="handleClick({ foo: bar })">click me!</button>

Activity

  1. arxpoetica commented on May 3, 2018

    @arxpoetica

    Because onclick is a native attribute and shouldn't be touched.

    https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers

  2. IamManchanda commented on May 3, 2018

    @IamManchanda

    Can't it be just @click, @keyup?

    or both on:click & @click with anyone working!


    Yes Vue like!

  3. arxpoetica commented on May 3, 2018

    @arxpoetica

    I say no to both [update: I meant "both" as in "two forms"]. Pick one and stick with it.

    +1 to on:*

  4. IamManchanda commented on May 3, 2018

    @IamManchanda

    @arxpoetica No I mean keep on:* but also keep @* as shorthand

  5. Rich-Harris commented on May 3, 2018

    @Rich-Harris
    Collaborator

    At the moment, elements and components have two types of 'thing': attributes and directives (three if you count spread attributes separately, I suppose). I don't personally think it's worth adding another type of thing that increases the complexity of the language for the sake of saving two characters. It's not a good idea to have multiple ways of doing something, because it creates anxiety in users, who end up asking themselves if one is 'correct', and if there are any differences in behaviour that they haven't understood. It just means more documentation, and the liberal use of @ is something that many people would find off-putting when first seeing HTMLx.

    onclick is a native attribute whose use is discouraged (because it runs in the global scope, etc), so that's not really an option.

  6. vedam commented on Nov 18, 2018

    @vedam

    In addition, isn't @ something used in other libs meaning something else (i.e. mobx @observable)?
    IMO adding more confusion than value.

  7. jfbrennan commented on Dec 4, 2018

    @jfbrennan

    Why can't HTMLx spec that onclick et al are scoped to the component? I really enjoyed coming to Riot and getting to use the real event attributes vs. idioms like v-on:click.

  8. arxpoetica commented on Dec 6, 2018

    @arxpoetica

    @jfbrennan as Rich Harris said, "is a native attribute"—i.e., if you override the native functionality, it won't be available. Idioms are just that: deliberately meant to set things apart as, in the e"x"tra in HTMLx.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions