content-loader icon indicating copy to clipboard operation
content-loader copied to clipboard

Issue with window.location.pathname

Open timminss opened this issue 5 years ago • 8 comments

Thanks for the fantastic library! I came across an issue with it, and hopefully the below provides a solution too:

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When using queryParams in an Angular project, window.location.pathname is not sufficient to determine the URL. SVGs appear black in Safari as a result.

Expected behavior

SVGs should display as normal in Safari, even when using queryParams.

Minimal reproduction of the problem with instructions

A new Angular project, with content-loader installed, and a single route. Add a queryParameter to the end of the URL, and the SVG will no longer load.

What is the motivation / use case for changing the behavior?

Fix a bug

Environment


Angular version: Any

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [x] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
Others:
The following fork includes a commit which appears to fix this issue:

https://github.com/timminss/content-loader

timminss avatar Mar 19 '20 11:03 timminss

Thanks. You're welcome to submit a PR.

NetanelBasal avatar Mar 19 '20 12:03 NetanelBasal

+1

jobejas avatar Apr 01 '20 17:04 jobejas

@NetanelBasal, I could be wrong but it doesn't look like baseUrl is needed in the fill and clip path. Removing seems to work the same and it fixes the bug. I tested in safari too, since @timminss mentioned that.

Steven-Harris avatar Jul 16 '20 04:07 Steven-Harris

Try to check in previous issues why we added it.

NetanelBasal avatar Jul 16 '20 04:07 NetanelBasal

Oh! My mistake

Steven-Harris avatar Jul 16 '20 05:07 Steven-Harris

@Steven-Harris try to see if the React version made some updates we can use here.

NetanelBasal avatar Jul 23 '20 06:07 NetanelBasal

Dang... They are doing something similar. The default is empty instead of window.location.pathname. However they do recommend passing windows.location.pathname if you are using a base tag

baseUrl?: string - Web only

Required if you're using <base url="/" /> document <head/>.  Defaults to an empty string. This prop is common used as: <ContentLoader baseUrl={window.location.pathname} /> which will fill the SVG attribute with the relative path. Related #93.

Source Code

Steven-Harris avatar Jul 26 '20 18:07 Steven-Harris

I've updated the library to the same code as the original React one. It should work now.

NetanelBasal avatar Oct 31 '20 17:10 NetanelBasal