lit / lit/lit.dev

[docs] outline proper `name` property attribute handling where relevant

Open
#1,159 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
142
Forks
230
PR merge metrics
No merged PRs in 30d

Description

This was an issue we ran into with the use of @lit-labs/react where we had custom form control elements that made use of element internals for form association.

We had a @property() name = ''; value declared, but as you can see, not reflected. Normally, this never causes an issue because we are usually declaring the name via an attribute on the element itself. However, because @lit-labs/react prefers setting values via properties, the name attribute was never declared and the control value was then not represented in submitted forms.

The solution was just to reflect name properly so even when set via property it exists as an attribute in the DOM for the form to recognize.

@property({ reflect: true }) name = '';

Not sure how the team wants to document this, but it seems like with some notes on ElementInternals usage and a reference to that from the @lit-labs/react docs might make sense.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @lit-labs/react documentation and the ElementInternals and form-associated custom element guidance described in the issue. Document when a name property should be reflected and link the relevant guidance from @lit-labs/react; done when the property-versus-attribute behavior and form-submission implication are clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.