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

Use html-element-attributes and svg-element-attributes #3019

Open
nolanlawson opened this issue Aug 23, 2022 · 1 comment
Open

Use html-element-attributes and svg-element-attributes #3019

nolanlawson opened this issue Aug 23, 2022 · 1 comment
Labels
enhancement Up for grabs Issues that are relatively small, self-contained, and ready for implementation

Comments

@nolanlawson
Copy link
Collaborator

This affects attribute validation in @lwc/template-compiler, which currently surfaces as warnings.

The libraries html-element-attributes and svg-element-attributes contain mappings of valid HTML tag/attribute pairs. They each have ~70-80k weekly npm downloads and seem fairly up-to-date.

Currently we are using a vendor'ed copy of the first:

const HTML_ELEMENT_ATTRIBUTE_MAP = {
'*': [
'accesskey',
'autocapitalize',
'class',
'contenteditable',
'dir',
'draggable',
'enterkeyhint',
'hidden',

... and for the second, we are just assuming that all known SVG elements are good, regardless of what attributes they have:

SUPPORTED_SVG_TAGS.has(tagName) ||

export const SUPPORTED_SVG_TAGS = new Set([
'svg',
'a',
'altGlyph',

Rather than maintaining our own list of valid html tag/attribute mappings (which can get out-of-date or be inaccurate), we should pool efforts with a reliable third-party package like these ones.

Unfortunately these two packages both switched to ESM recently, so we would need to solve #3017 first.

@nolanlawson nolanlawson added the Up for grabs Issues that are relatively small, self-contained, and ready for implementation label Aug 11, 2023
@nolanlawson
Copy link
Collaborator Author

We have a solution for ESM now; we can inline things. However, this might be an observable change, so worth validating that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Up for grabs Issues that are relatively small, self-contained, and ready for implementation
Projects
None yet
Development

No branches or pull requests

1 participant