Gitako/packages/pjax/lib/execute-scripts.js
EnixCoda 7e6feb621c
revert: use old pjax for Firefox compatibility
This reverts commit 8aaf55be59 and 0a4ee27
2020-04-06 19:16:36 +08:00

18 lines
557 B
JavaScript

var forEachEls = require("./foreach-els")
var evalScript = require("./eval-script")
// Finds and executes scripts (used for newly added elements)
// Needed since innerHTML does not run scripts
module.exports = function(el) {
if (el.tagName.toLowerCase() === "script") {
evalScript(el)
}
forEachEls(el.querySelectorAll("script"), function(script) {
if (!script.type || script.type.toLowerCase() === "text/javascript") {
if (script.parentNode) {
script.parentNode.removeChild(script)
}
evalScript(script)
}
})
}