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

types: href missing from SVGAttributes #4574

Closed
1 task
birtles opened this issue Nov 26, 2024 · 3 comments · Fixed by #4575
Closed
1 task

types: href missing from SVGAttributes #4574

birtles opened this issue Nov 26, 2024 · 3 comments · Fixed by #4575
Labels

Comments

@birtles
Copy link

birtles commented Nov 26, 2024

  • Check if updating to the latest Preact version resolves the issue

Describe the bug
10.25.0 adds stricter typing for element attributes (#4546) but it omits href from SVGAttributes.

To Reproduce

Write content such as:

function Hello() {
  return (<use href="#abc" />);
}

Perform type checking.

Expected behavior

Type-checking should not return an error.

In SVG the <use>, <foreignObject>, <image> and <script> elements can have an href attribute.

Many many years ago href needed to be in the xlink namespace but browsers have supported bare href for about a decade or so now.

@rschristian
Copy link
Member

rschristian commented Nov 27, 2024

Thanks!

For what it's worth, no justification is necessary -- it was a mistake, nothing intentional. In the past, SVGAttributes extended from a mega interface of all HTML attributes, which of course included href. Since 10.25, however, it only extends an interface of truly global attributes/props, which href is not included in.

xlinkHref (and xlink:href) are SVG-only (to my knowledge) so they were already in the SVG interface is all.

@birtles
Copy link
Author

birtles commented Nov 27, 2024

Great, thank you so much!

@rschristian
Copy link
Member

No problem! Certainly let us know if you spot anything else out of the ordinary -- it was a big change, hopefully for the better, with a lot of surface area for slip-ups. We did our best to try to minimize these by checking out various repos but there's always the possibility of combinations/attributes we didn't encounter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants