Files
pjax/lib/execute-scripts.js

19 lines
557 B
JavaScript
Raw Normal View History

2014-05-04 08:44:52 +02:00
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)
}
2014-05-04 08:44:52 +02:00
forEachEls(el.querySelectorAll("script"), function(script) {
if (!script.type || script.type.toLowerCase() === "text/javascript") {
if (script.parentNode) {
script.parentNode.removeChild(script)
}
evalScript(script)
2014-05-04 08:44:52 +02:00
}
})
2014-05-04 08:44:52 +02:00
}