Code cleanup #120

Merged
BehindTheMath merged 13 commits from cleanup/misc-cleanup into master 2018-02-02 09:52:45 -05:00
5 changed files with 6 additions and 10 deletions
Showing only changes of commit d0d308191f - Show all commits

View File

@@ -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,7 +15,7 @@ module.exports = function(el) {
if (src !== "") {
script.src = src
script.async = false // force synchronous loading of peripheral js
script.async = false // force synchronous loading of peripheral JS
}
if (code !== "") {

View File

@@ -4,7 +4,7 @@ module.exports = function(els, events, opts) {
events = (typeof events === "string" ? events.split(" ") : events)
events.forEach(function(e) {
var event // = new CustomEvent(e) // doesn't everywhere yet
var event
event = document.createEvent("HTMLEvents")
event.initEvent(e, true, true)
event.eventName = e
@@ -17,8 +17,8 @@ module.exports = function(els, events, opts) {
forEachEls(els, function(el) {
var domFix = false
if (!el.parentNode && el !== document && el !== window) {
// THANKS YOU IE (9/10//11 concerned)
// dispatchEvent doesn't work if element is not in the dom
// THANK YOU IE (9/10/11)
// dispatchEvent doesn't work if the element is not in the DOM
domFix = true
document.body.appendChild(el)
}

View File

@@ -3,8 +3,6 @@ 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) {
// console.log("going to execute scripts for ", el)
if (el.tagName.toLowerCase() === "script") {
evalScript(el)
}

View File

@@ -4,6 +4,6 @@ module.exports = function(els, fn, context) {
if (els instanceof HTMLCollection || els instanceof NodeList || els instanceof Array) {
return Array.prototype.forEach.call(els, fn, context)
}
// assume simple dom element
// assume simple DOM element
return fn.call(context, els)
}

View File

@@ -3,7 +3,7 @@ module.exports = function() {
if (typeof console.log === "function") {
console.log.apply(console, arguments)
}
// ie is weird
// IE is weird
else if (console.log) {
console.log(arguments)
}