Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about executeScripts #208

Open
stevenjoezhang opened this issue Aug 3, 2019 · 0 comments
Open

A question about executeScripts #208

stevenjoezhang opened this issue Aug 3, 2019 · 0 comments

Comments

@stevenjoezhang
Copy link

pjax/index.js

Lines 208 to 213 in c26c223

// execute scripts when DOM have been completely updated
this.options.selectors.forEach(function(selector) {
forEachEls(document.querySelectorAll(selector), function(el) {
executeScripts(el);
});
});

forEachEls(el.querySelectorAll("script"), function(script) {
if (!script.type || script.type.toLowerCase() === "text/javascript") {
if (script.parentNode) {
script.parentNode.removeChild(script);
}
evalScript(script);
}
});

After script.parentNode.removeChild(script); is executed, script.parentNode will be null

var parent =
el.parentNode || document.querySelector("head") || document.documentElement;

This means that the return value of the short-circuit evaluation here is document.querySelector("head")

In other words, all the scripts that are refreshed by pjax will be placed in the <head>. Is this expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant