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

Rule for enumerated boolean attribute #144

Open
SarguelUnda opened this issue Jun 20, 2024 · 0 comments · May be fixed by #145
Open

Rule for enumerated boolean attribute #144

SarguelUnda opened this issue Jun 20, 2024 · 0 comments · May be fixed by #145
Assignees
Labels
enhancement New feature or request

Comments

@SarguelUnda
Copy link

Describe the need
Some html attribute are enumerated boolean meaning they only allow 'true' or 'false' c.f. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable

Typescript for JSX attribute like dragable is boolean | 'true' | 'false' which allow to easily turn on and off such attributes with pattern like <img draggable={condition()} /> instead of having to write <img draggable={condition() ? 'true': 'false'} />. The downside is that it is legal to write <img draggable />. See solidjs/solid#1101 and solidjs/solid#383 as to why the current behavior is not considered a bug in solidjs.

Suggested Solution
Adding a new rule that would error on lonely draggable attribute and proposing to fix it by explicitly marking it draggable="true"

Possible Alternatives
For fix both draggable="true" and draggable={true} are possible the former get inlined in the template while the latter emit a _$setAttribute(_el$2, "draggable", true); cf https://playground.solidjs.com/anonymous/70183b03-2a82-4c1f-a048-b171b049be31

Additional context
From https://gist.github.com/samme/82133b9849a8d6851104e070b56e0ed3 it seems that contenteditable and spellcheck also follow the enumerated rules but from testing they do not lead to the same buggy behavior as draggable so I don't know if the rule should check it too.

  • [X ] I would be willing to contribute a PR to implement this feature
@SarguelUnda SarguelUnda added the enhancement New feature or request label Jun 20, 2024
@SarguelUnda SarguelUnda linked a pull request Jun 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants