diff --git a/svg-injector.js b/svg-injector.js index 08de011..c886e98 100644 --- a/svg-injector.js +++ b/svg-injector.js @@ -224,6 +224,12 @@ return; } + // If we don't have a parentNode we can not replace the node inline + if (!el.parentNode) { + callback('Attempted to process an image that is not in the DOM. SVG to load:' + imgUrl); + return; + } + // Remember the request to inject this element, in case other injection // calls are also trying to replace this element before we finish injectedElements.push(el); diff --git a/tests/race-condition/index.html b/tests/race-condition/index.html index 620524f..8baaa9f 100755 --- a/tests/race-condition/index.html +++ b/tests/race-condition/index.html @@ -23,10 +23,20 @@ thumb up thumb up + js errors +