Skip to content

bug on different property vs attribute names via Lit property decorator #86

@scottnath

Description

@scottnath

Hi @break-stuff ,

When creating a different attribute name vs a property name using Lit's @property() decorator, the property is picked up by Storybook docs, but the attribute is not.

Minimal reproduction (minor changes to lit-starter-kit)
break-stuff/lit-starter-kit@main...scottnath:lit-starter-kit:main

I adjusted variation in the lit-starter-kit to be:

  @property({ type: String, attribute: 'data-variation' })
  variation?: 'default' | 'primary' | 'hollow' | 'transparent';

meaning the attribute is data-variation but the property is just variation.

I added two stories, and the first one AttrVsProp shows the attribute data-variation as empty and this.variation is not configured. In the second, PropVsAttr the attribute data-variation is populated correctly and this.variation has the correct content

export const AttrVsProp: Story = {
  args: {
    'default-slot': 'My Button',
    variation: 'primary'
  },
};

export const PropVsAttr: Story = {
  args: {
    'default-slot': 'My Button',
    'data-variation': 'primary'
  },
};

Is there a way to configure either cem-creation or the break-stuff tools to have this work as expected (both attribute and property properly populate the component and storybook controls when used) or is this a bug?

thank you for any help,
Scott

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