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

TypeError: i is null / TypeError: Cannot read property 'split' of null #25

Open
rotsee opened this issue Nov 21, 2017 · 5 comments
Open

Comments

@rotsee
Copy link

rotsee commented Nov 21, 2017

I get an error Uncaught TypeError: Cannot read property 'split' of null in Chrome, and TypeError: i is null [Learn More] in Firefox, given the following code:

<svg data-src="/images/test.svg" id="test"></svg>

document.addEventListener('DOMContentLoaded', function() {
  var elementsToInject = document.querySelectorAll('svg[data-src]');
  console.log(elementsToInject);
  # [svg#test]
  var injector = new SVGInjector();
  console.log(injector);
  # [svg#test]
  # n {}
  # XHR finished loading: GET "http://localhost:3000/images/test.svg".

  injector.inject(elementsToInject);
});

Any ideas how to trobleshoot this?

@flobacher
Copy link
Owner

Did you try with the latest version.. without investigation, this looks like a bug that has been fixed with 2.1.2.
If the error persists, would you mind to share a gist with me, so I can debug this?
Thank you!

@rotsee
Copy link
Author

rotsee commented Dec 5, 2017

I used 2.1.3. Will try and reproduce!

@twitwi
Copy link

twitwi commented Jun 16, 2019

If anyone falls on this like me, it seems to be due to a wrong handling of the cases where the viewBox attribute is not present on the svg element.

@theRealPadster
Copy link

If anyone falls on this like me, it seems to be due to a wrong handling of the cases where the viewBox attribute is not present on the svg element.

Ha, I just had this issue today. Talk about good timing ^^ Thanks!

@brianteeman
Copy link

yeah - just hit this problem. if you are using svgomg then it will strip the viewbox

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

No branches or pull requests

5 participants