SVGInjector2
SVGInjector2 copied to clipboard
TypeError: i is null / TypeError: Cannot read property 'split' of null
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?
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!
I used 2.1.3
. Will try and reproduce!
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.
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 thesvg
element.
Ha, I just had this issue today. Talk about good timing ^^ Thanks!
yeah - just hit this problem. if you are using svgomg then it will strip the viewbox