Added support do do a push-state ajax request with forms

This commit is contained in:
markusfluer
2017-09-18 14:13:39 +02:00
parent 109e78347f
commit 86e5a2281a
10 changed files with 214 additions and 14 deletions

View File

@@ -2,7 +2,7 @@ module.exports = function(el) {
// console.log("going to execute script", el)
var code = (el.text || el.textContent || el.innerHTML || "")
var head = document.querySelector("head") || document.documentElement
var parent = el.parentNode || document.querySelector("head") || document.documentElement
var script = document.createElement("script")
if (code.match("document.write")) {
@@ -22,8 +22,11 @@ module.exports = function(el) {
}
// execute
head.insertBefore(script, head.firstChild)
head.removeChild(script) // avoid pollution
parent.appendChild(script);
// avoid pollution only in head or body tags
if (["head","body"].indexOf(parent.tagName.toLowerCase()) > 0) {
parent.removeChild(script)
}
return true
}