From 2639bf40967aebc20b17c6325a4fdda4a83507bf Mon Sep 17 00:00:00 2001 From: Sean Roberts Date: Thu, 3 Sep 2015 14:23:45 -0400 Subject: [PATCH 1/2] Fixing parentNode missing issue -- adding it as a prereq check --- svg-injector.js | 6 ++++++ tests/race-condition/index.html | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) 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..fe6feef 100755 --- a/tests/race-condition/index.html +++ b/tests/race-condition/index.html @@ -23,10 +23,21 @@ thumb up thumb up + js errors + From 70c7476309be44d0406d795eb6becfe005b21acd Mon Sep 17 00:00:00 2001 From: Sean Roberts Date: Thu, 3 Sep 2015 16:00:36 -0400 Subject: [PATCH 2/2] Updating stale reference post injection --- tests/race-condition/index.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/race-condition/index.html b/tests/race-condition/index.html index fe6feef..8baaa9f 100755 --- a/tests/race-condition/index.html +++ b/tests/race-condition/index.html @@ -29,13 +29,12 @@