From da6b697d19e0bbf1eabdb0b29234a0d1c9bd56c3 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 19 May 2016 11:57:41 -0700 Subject: [PATCH] spaces -> tabs --- api/tests/test-mount.js | 198 ++++++++++++++++++++-------------------- bundler/bundler.js | 4 +- 2 files changed, 101 insertions(+), 101 deletions(-) diff --git a/api/tests/test-mount.js b/api/tests/test-mount.js index 4a5665f2..a9474761 100644 --- a/api/tests/test-mount.js +++ b/api/tests/test-mount.js @@ -8,107 +8,107 @@ var m = require("../../render/hyperscript") var createMounter = require("../mount") o.spec("m.mount", function() { - var $window, root - - o.beforeEach(function() { + var $window, root + + o.beforeEach(function() { $window = domMock() - async.setTimeout($window) + async.setTimeout($window) root = $window.document.body - }) - + }) + o("is a function", function() { - o(typeof createMounter).equals("function") - }) - - o("returns a function after invocation", function() { - o(typeof createMounter()).equals("function") - }) - - o("updates passed in redraw object", function() { - var redraw = {} - var mount = createMounter($window, redraw) - - mount(root, { - view : function() { - return m("div") - } - }) - - o(typeof redraw.run).equals("function") - }) - - o("renders into `root`", function() { - var mount = createMounter($window, {}) - - mount(root, { - view : function() { - return m("div") - } - }) - - o(root.firstChild.nodeName).equals("DIV") - }) - - o("redraws on redraw.run()", function(done) { - var onupdate = o.spy() - var oninit = o.spy() - var redraw = {} - var mount = createMounter($window, redraw) - - mount(root, { - view : function() { - return m("div", { - oninit : oninit, - onupdate : onupdate - }) - } - }) - - o(oninit.callCount).equals(1) - - redraw.run() - - // Wrapped to give time for the rate-limited redraw to fire - setTimeout(function() { - o(onupdate.callCount).equals(1) - - done() - }, 20) - }) - - o("redraws on events", function(done, timeout) { - var onupdate = o.spy() - var oninit = o.spy() - var onclick = o.spy() - var mount = createMounter($window, {}) - var e = $window.document.createEvent("MouseEvents") - + o(typeof createMounter).equals("function") + }) + + o("returns a function after invocation", function() { + o(typeof createMounter()).equals("function") + }) + + o("updates passed in redraw object", function() { + var redraw = {} + var mount = createMounter($window, redraw) + + mount(root, { + view : function() { + return m("div") + } + }) + + o(typeof redraw.run).equals("function") + }) + + o("renders into `root`", function() { + var mount = createMounter($window, {}) + + mount(root, { + view : function() { + return m("div") + } + }) + + o(root.firstChild.nodeName).equals("DIV") + }) + + o("redraws on redraw.run()", function(done) { + var onupdate = o.spy() + var oninit = o.spy() + var redraw = {} + var mount = createMounter($window, redraw) + + mount(root, { + view : function() { + return m("div", { + oninit : oninit, + onupdate : onupdate + }) + } + }) + + o(oninit.callCount).equals(1) + + redraw.run() + + // Wrapped to give time for the rate-limited redraw to fire + setTimeout(function() { + o(onupdate.callCount).equals(1) + + done() + }, 20) + }) + + o("redraws on events", function(done, timeout) { + var onupdate = o.spy() + var oninit = o.spy() + var onclick = o.spy() + var mount = createMounter($window, {}) + var e = $window.document.createEvent("MouseEvents") + e.initEvent("click", true, true) - - mount(root, { - view : function() { - return m("div", { - oninit : oninit, - onupdate : onupdate, - onclick : onclick, - }) - } - }) - - root.firstChild.dispatchEvent(e) - - o(oninit.callCount).equals(1) - - o(onclick.callCount).equals(1) - o(onclick.this).equals(root.firstChild) - o(onclick.args[0].type).equals("click") - o(onclick.args[0].target).equals(root.firstChild) - - // Wrapped to give time for the rate-limited redraw to fire - setTimeout(function() { - o(onupdate.callCount).equals(1) - - done() - }, 20) - }) + + mount(root, { + view : function() { + return m("div", { + oninit : oninit, + onupdate : onupdate, + onclick : onclick, + }) + } + }) + + root.firstChild.dispatchEvent(e) + + o(oninit.callCount).equals(1) + + o(onclick.callCount).equals(1) + o(onclick.this).equals(root.firstChild) + o(onclick.args[0].type).equals("click") + o(onclick.args[0].target).equals(root.firstChild) + + // Wrapped to give time for the rate-limited redraw to fire + setTimeout(function() { + o(onupdate.callCount).equals(1) + + done() + }, 20) + }) }) diff --git a/bundler/bundler.js b/bundler/bundler.js index 5656a305..46787186 100644 --- a/bundler/bundler.js +++ b/bundler/bundler.js @@ -8,12 +8,12 @@ var modules = {} function resolve(dir, data) { var replacements = [] data = data.replace(/((?:var|let|const|)\s*)([\w_$]+)(\s*=\s*)require\(([^\)]+)\)/g, function(match, def, variable, eq, dep) { - var filename = new Function("return " + dep).call() + var filename = new Function("return " + dep).call() var pathname = path.dirname(path.resolve(dir, filename)) var normalized = path.normalize(dir + "/" + filename) if (modules[normalized] === undefined) { modules[normalized] = variable - return resolve(pathname, + return resolve(pathname, fs.readFileSync(dir + "/" + filename + ".js", "utf8") .replace(/"use strict"\s*/gm, "") .replace(/module\.exports\s*=\s*/gm, def + variable + eq)