Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lit-html] Detect duplicate attributes in DEV_MODE #4194

Closed
1 task done
filimon-danopoulos-stratsys opened this issue Sep 13, 2023 · 0 comments · Fixed by #4523
Closed
1 task done

[lit-html] Detect duplicate attributes in DEV_MODE #4194

filimon-danopoulos-stratsys opened this issue Sep 13, 2023 · 0 comments · Fixed by #4523
Assignees

Comments

@filimon-danopoulos-stratsys

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

When a property is accidentally duplicated it is perceived that Lit silently "fails". It would be nice to get a warning about this in DEV_MODE as it can lead to obscure bugs that are hard to track down otherwise.

See the full discussion from Discord here: https://discord.com/channels/1012791295170859069/1149635522646515774

Here is a small case where I would like to get a warning: https://lit.dev/playground/#gist=932be48698b63a7b9d38a78b75a8a3ef

When the template looks like this:

<textarea 
      ?disabled=${this.disabled} 
      ?disabled=${this.disabled} 
      placeholder=${this.placeholder}
></textarea>

Not sure if an explanation is necessary but the placeholder will not render properly as the duplicate properties are removed by the <template> resulting in a discrepancy between parts and values. Thomas Boyer explained it well in the attached Discord thread.

If the template is large, with event handlers, classMap and styleMap, a single duplicate line can be really hard to track down and is unintuitive as the cause of the resulting bug. A message like > Possible duplicate attribute detected. would be very helpful. Ideally with some way to identify where said duplication might exist.

Alternatives and Workarounds

This could also be solved by expanded editor support where heavier analysis can be done during development.

@augustjk augustjk changed the title Detect duplicate attributes in DEV_MODE [lit-html] Detect duplicate attributes in DEV_MODE Sep 29, 2023
@AndrewJakubowicz AndrewJakubowicz self-assigned this Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants