Check for presence of script node before post eval cleanup
rungta opened this issue · 1 comments
Line 37 in 52fb3bf
Sometimes a script tag can contain code that, on execution, cleans up after itself by removing the original script node. For example, an obfuscation snippet that uses document.currentScript.parentNode.removeChild(document.currentScript)
to remove the script node and replace it with the decoded content.
In such a case, Pjax results in a DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
while attempting to cleanup. It would be great if there was a condition that checked for the presence of the script node post eval before attempting to remove it.
Suggestion: a parent.contains(script)
check before parent.removeChild(script)
might do the trick.