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) {
|
2017-09-18 14:13:39 +02:00
|
|
|
if (el.tagName.toLowerCase() === "script") {
|
2018-02-02 09:52:44 -05:00
|
|
|
evalScript(el)
|
2017-09-18 14:13:39 +02:00
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
2018-02-02 09:52:44 -05:00
|
|
|
evalScript(script)
|
2014-05-04 08:44:52 +02:00
|
|
|
}
|
2018-02-02 09:52:44 -05:00
|
|
|
})
|
2014-05-04 08:44:52 +02:00
|
|
|
}
|