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

Broken SVG Links #279

Merged
merged 3 commits into from
Nov 17, 2018
Merged

Broken SVG Links #279

merged 3 commits into from
Nov 17, 2018

Conversation

derappelt
Copy link
Contributor

Svg anchor tags return an object( {baseVal:string, animVal:string} ) instead of an string.
This causes react-snap to throw an error

Svg anchor tags return an object( {baseVal:string, animVal:string} ) instead of an string. 
This causes react-snap to throw an error
@stereobooster
Copy link
Owner

Hi. Thank you for contribution. Can you please add test-case for this?

@derappelt
Copy link
Contributor Author

Does this test cover enough for you?

@derappelt
Copy link
Contributor Author

Any feedback on this?
Even a simple:
(anchor => (typeof anchor.href === 'string') ? anchor.href : '')
Would be a better solution.
Me and my team really like react-snap. But this bug keeps us away from using it.

@stereobooster
Copy link
Owner

Oh yes, sorry. I was distracted. Everything looks fine, I just want to run some tests, to make sure I understand what is happening.

@derappelt
Copy link
Contributor Author

Thanks no problem!
I'm not quite sure if my submitted code covers all SVG Link cases. But it works in all projects I tried so far.
Like I mentioned in my comment above, I think the first priority should be that Inline SVG Links don't crash snap.

Array.from(document.querySelectorAll("a")).map(anchor => anchor.href)
Array.from(document.querySelectorAll("a")).map(anchor => {
if(anchor.href.baseVal){
return location.origin + anchor.href.baseVal;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
return location.origin + anchor.href.baseVal;
const a = document.createElement("a");
a.href = anchor.href.baseVal;
return a.href;

@stereobooster stereobooster merged commit 5ab5ade into stereobooster:master Nov 17, 2018
@stereobooster
Copy link
Owner

There is small thing to change, but I can do it. Thanks

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

Successfully merging this pull request may close these issues.

2 participants