Skyleen77 / next-nprogress-bar

NProgress integration on Next.js compatible with /app and /pages folders
https://next-nprogress-bar.vercel.app
315 stars 24 forks source link

Implement support for links inside `<svg>` #32

Closed MurkyMeow closed 7 months ago

MurkyMeow commented 8 months ago

Turns out, links can be not only HTMLAnchorElement but also SVGAElement if they're rendered inside an svg tag.

If you do SVGAElement.href you won't get a string but rather an instance of SVGAnimatedString object. The library currently doesn't expect that hence navigating via svg links throws an error.

I implemented a check that if a property of a link returns SVGAnimatedString then we return .baseVal of it to get the correct value.

Moreover, svg's href property doesn't convert relative urls to absolute ones so i implemented this conversion as well. (i stole some code from next.js https://github.com/vercel/next.js/blob/24b2ff16abaa973d695247a9c1ac4e229640d4ca/packages/next/src/client/link.tsx#L743)

Skyleen77 commented 7 months ago

Very good MR but with the other changes having taken place, I can't merge it as is. I'm very sorry for that.

I have made the changes and will deploy a new version quickly.

Thanks again for your contribution 🙏