Skip to content

Using dash-case attributes in JSX #1374

@dgibson666

Description

@dgibson666

Stencil version:

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

If you're supposed to use camelCase on attributes in JSX, why does dash-format work almost all of the time? We built an entire demo site for our components using other components. The demoed components are output in their render methods via JSX. But we've been using dash-format for those attributes all along and it worked fine (actually copied from some static HTML demo pages way back). But there's one case where things do not work:

  1. If you define a camelCase Boolean prop and default it to true,
  2. Then try to set it to false via the attribute on the custom element using dash-format, it doesn’t update.
  3. If you use camelCase in the attribute, however (per updated docs CamelCase @Prop() declaration don't work site#114), it does update properly.

If you just use a one-word prop/attribute or no camelCase in the prop, everything works as expected as far as the prop assignment goes.

Expected behavior:

If you're going to still support dash-format for attributes in JSX, then this should still work, as every other case seems to. This would be nice so we don't have to demo two different scenarios for usage in our component docs.

Steps to reproduce:

// insert any relevant code here
@Prop() showHeader: boolean = true;
...
<my-component show-header={false}>  - does not work in JSX (yet dash case works in every other scenario across dozens of components and their props)

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