Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Make sure parentNode is not document in unit conversion

Julian Garnier6abcffd6cefc
diff --git a/src/index.js b/src/index.js
index 734f6bc5..bd010934 100644
--- a/src/index.js
+++ b/src/index.js
@@ -425,7 +425,7 @@ function convertPxToUnit(el, value, unit) {
if (!is.und(cached)) return cached;
const baseline = 100;
const tempEl = document.createElement(el.tagName);
- const parentEl = el.parentNode || document.body;
+ const parentEl = (el.parentNode && (el.parentNode !== document)) ? el.parentNode : document.body;
parentEl.appendChild(tempEl);
tempEl.style.position = 'absolute';
tempEl.style.width = baseline + unit;