Code cleanup (#120)
* Lots of code cleanup * Cleanup parse-options tests - Rename objects for clarity and inline unneeded objects - Remove unneeded tests - Use Object.keys().length instead of a custom function - Use typeof === "object" instead of a custom function that checks the prototype tree as well, since we don't expect anything but an object literal. * Remove old switchFallback code * Remove polyfill for Function.prototype.bind * Inline small functions * Add more documentation and tests for options.currentUrlFullReload Closes #17 * Update package.json
This commit was merged in pull request #120.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module.exports = function(el) {
|
||||
var code = (el.text || el.textContent || el.innerHTML || "")
|
||||
var src = (el.src || "");
|
||||
var src = (el.src || "")
|
||||
var parent = el.parentNode || document.querySelector("head") || document.documentElement
|
||||
var script = document.createElement("script")
|
||||
|
||||
@@ -13,12 +13,12 @@ module.exports = function(el) {
|
||||
|
||||
script.type = "text/javascript"
|
||||
|
||||
if (src != "") {
|
||||
script.src = src;
|
||||
script.async = false; // force synchronous loading of peripheral js
|
||||
if (src !== "") {
|
||||
script.src = src
|
||||
script.async = false // force synchronous loading of peripheral JS
|
||||
}
|
||||
|
||||
if (code != "") {
|
||||
if (code !== "") {
|
||||
try {
|
||||
script.appendChild(document.createTextNode(code))
|
||||
}
|
||||
@@ -29,11 +29,11 @@ module.exports = function(el) {
|
||||
}
|
||||
|
||||
// execute
|
||||
parent.appendChild(script);
|
||||
parent.appendChild(script)
|
||||
// avoid pollution only in head or body tags
|
||||
if (["head","body"].indexOf(parent.tagName.toLowerCase()) > 0) {
|
||||
if (["head", "body"].indexOf(parent.tagName.toLowerCase()) > 0) {
|
||||
parent.removeChild(script)
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user