@@ -281,7 +281,10 @@ export function useLinkProps<
281281 // The click handler
282282 const handleClick = ( e : MouseEvent ) => {
283283 // Check actual element's target attribute as fallback
284- const elementTarget = ( e . currentTarget as HTMLAnchorElement ) . target
284+ const elementTarget = (
285+ e . currentTarget as HTMLAnchorElement | SVGAElement
286+ ) . getAttribute ( 'target' )
287+
285288 const effectiveTarget =
286289 local . target !== undefined ? local . target : elementTarget
287290
@@ -470,6 +473,12 @@ export interface ActiveLinkOptionProps<TComp = 'a'> {
470473 * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)
471474 */
472475 inactiveProps ?: ActiveLinkProps < TComp > | ( ( ) => ActiveLinkProps < TComp > )
476+ /**
477+ * When true, the Link will not render its own wrapper element.
478+ * Instead, it will pass its props to its single child element.
479+ * Useful for custom components or SVG elements where you need precise control over the rendered element.
480+ */
481+ _asChild ?: boolean | Solid . ValidComponent
473482}
474483
475484export type LinkProps <
@@ -579,10 +588,22 @@ export const Link: LinkComponent<'a'> = (props) => {
579588 return ch satisfies Solid . JSX . Element
580589 } )
581590
591+ // For _asChild, use Dynamic to render the custom component
592+ if ( local . _asChild ) {
593+ return (
594+ < Dynamic component = { local . _asChild } { ...( linkProps as any) } >
595+ { children ( ) }
596+ </Dynamic >
597+ )
598+ }
599+
600+ // Default rendering - just use regular anchor element
601+ // This works for HTML contexts; SVG links inside SVGs won't work properly
602+ // due to Solid's compile-time namespace determination
582603 return (
583- < Dynamic component = { local . _asChild ? local . _asChild : 'a' } { ...linkProps } >
604+ < a { ...( linkProps as any ) } >
584605 { children ( ) }
585- </ Dynamic >
606+ </ a >
586607 )
587608}
588609
0 commit comments