Fix evalScripts()

* Set the id of the insert <script>.
* Check if the <script> still exists before trying to remove it.
This commit is contained in:
Behind The Math committed 2018-11-21 21:33:41 -05:00
1 parent fefb63ae87
commit 33519f01ae
2 files changed
+20 -1

No files matched your search

+2 -1
View File
@@ -12,6 +12,7 @@ module.exports = function(el) {
}
script.type = "text/javascript"
script.id = el.id;
/* istanbul ignore if */
if (src !== "") {
@@ -33,7 +34,7 @@ module.exports = function(el) {
// execute
parent.appendChild(script)
// avoid pollution only in head or body tags
if (parent instanceof HTMLHeadElement || parent instanceof HTMLBodyElement) {
if ((parent instanceof HTMLHeadElement || parent instanceof HTMLBodyElement) && parent.contains(script)) {
parent.removeChild(script)
}