2019-02-13 22:26:57 -05:00
|
|
|
var forEachEls = require("./foreach-els");
|
|
|
|
|
var evalScript = require("./eval-script");
|
2014-05-04 08:44:52 +02:00
|
|
|
// 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") {
|
2019-02-13 22:26:57 -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) {
|
2019-02-13 22:26:57 -05:00
|
|
|
script.parentNode.removeChild(script);
|
2014-05-04 08:44:52 +02:00
|
|
|
}
|
2019-02-13 22:26:57 -05:00
|
|
|
evalScript(script);
|
2014-05-04 08:44:52 +02:00
|
|
|
}
|
2019-02-13 22:26:57 -05:00
|
|
|
});
|
|
|
|
|
};
|