Skip to content

Support de-camelCasing JSX html attributes #55

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blakef
Copy link

@blakef blakef commented Feb 5, 2018

Taken the list of Preact supported attributes and transform these attributes when building the rendered string.

Taken the list of Preact supported attributes[1] and transform these
attributes when building the rendered string.

[1] https://github.com/developit/preact/blob/f717ee8e53248d75ff8c1a46966adeec295d339b/src/preact.d.ts#L547
Copy link
Contributor

@gpoitch gpoitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to double check some of the attrs formatting. Noted a few, but there are some others.

spellCheck: 'spell-check',
srcDoc: 'src-doc',
srcLang: 'src-lang',
srcSet: 'src-set',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'srcset'

srcDoc: 'src-doc',
srcLang: 'src-lang',
srcSet: 'src-set',
tabIndex: 'tab-index',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tabindex'

@developit
Copy link
Member

Hiya! Sorry for the delay in responding to PRs. I'm wondering about the size impact of this, versus using a regular expression transform like name.replace(/([A-Z])/,'-$1').toLowerCase().

@sventschui
Copy link
Member

@developit the RegEx approach would suffer from the issue of transforming tabIndex to tab-index instead of tabindex.

Combining both with a list of html attributes that need the hyphen to be removed might be a way to go.

Any other ideas?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants