Fix external scripts events #118
@@ -1,6 +1,4 @@
|
||||
module.exports = function(el) {
|
||||
// console.log("going to execute script", el)
|
||||
|
||||
var code = (el.text || el.textContent || el.innerHTML || "")
|
||||
var src = (el.src || "");
|
||||
var parent = el.parentNode || document.querySelector("head") || document.documentElement
|
||||
@@ -17,8 +15,7 @@ module.exports = function(el) {
|
||||
|
||||
if (src != "") {
|
||||
script.src = src;
|
||||
script.onload = function() { document.dispatchEvent((new Event("pjax:complete"))); }
|
||||
script.async = false; // force asynchronous loading of peripheral js
|
||||
script.async = false; // force synchronous loading of peripheral js
|
||||
}
|
||||
|
||||
if (code != "") {
|
||||
|
||||
@@ -13,10 +13,11 @@ tape("test evalScript method", function(t) {
|
||||
evalScript(script)
|
||||
t.equal(document.body.className, "executed", "script has been properly executed")
|
||||
|
||||
// script.innerHTML = "document.write('failure')"
|
||||
// var bodyText = document.body.text
|
||||
// evalScript(script)
|
||||
// t.equal(document.body.text, bodyText, "document.write hasn't been executed")
|
||||
script.innerHTML = "document.write('failure')"
|
||||
document.body.text = "document.write hasn't been executed"
|
||||
var bodyText = document.body.text
|
||||
evalScript(script)
|
||||
t.equal(document.body.text, bodyText, "document.write hasn't been executed")
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user