From 3df5578e7b728a2071516700c685fd1d91208556 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 25 May 2014 23:19:52 +0200 Subject: [PATCH] Removed trailing spaces --- Gruntfile.js | 14 +++++------ mithril.js | 34 +++++++++++++------------- tests/mithril-tests.js | 54 +++++++++++++++++++++--------------------- tests/svg.html | 2 +- tests/test.js | 2 +- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ffb7af48..1abb9258 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,12 +1,12 @@ module.exports = function(grunt) { var version = "0.1.14" - + var inputFolder = "./docs" var tempFolder = "./temp" var archiveFolder = "./archive" var outputFolder = "../mithril" - + var guideLayout = "guide" var guide = [ "auto-redrawing", @@ -43,9 +43,9 @@ module.exports = function(grunt) { "mithril.withAttr", "mithril.xhr" ] - - - + + + var md2htmlTasks = {} var makeTasks = function(layout, pages) { pages.map(function(name) { @@ -57,7 +57,7 @@ module.exports = function(grunt) { } makeTasks("guide", guide) makeTasks("api", api) - + var currentVersionArchiveFolder = archiveFolder + "/v" + version grunt.initConfig({ md2html: md2htmlTasks, @@ -111,7 +111,7 @@ module.exports = function(grunt) { tasks: ["build"] } }); - + grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks("grunt-contrib-copy"); diff --git a/mithril.js b/mithril.js index d7d299c3..74a8cf0e 100644 --- a/mithril.js +++ b/mithril.js @@ -2,7 +2,7 @@ Mithril = m = new function app(window) { var selectorCache = {} var type = {}.toString var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.+?)\2)?\]/ - + function m() { var args = arguments var hasAttrs = type.call(args[1]) == "[object Object]" && !("tag" in args[1]) && !("subtree" in args[1]) @@ -35,14 +35,14 @@ Mithril = m = new function app(window) { function build(parentElement, parentTag, data, cached, shouldReattach, index, editable, namespace) { if (data === null || data === undefined) data = "" if (data.subtree === "retain") return - + var cachedType = type.call(cached), dataType = type.call(data) if (cachedType != dataType) { if (cached !== null && cached !== undefined) clear(cached.nodes) cached = new data.constructor cached.nodes = [] } - + if (dataType == "[object Array]") { var nodes = [], intact = cached.length === data.length, subArrayCount = 0 for (var i = 0, cacheCount = 0; i < data.length; i++) { @@ -64,7 +64,7 @@ Mithril = m = new function app(window) { else if (dataType == "[object Object]") { if (data.tag != cached.tag || Object.keys(data.attrs).join() != Object.keys(cached.attrs).join() || data.attrs.id != cached.attrs.id) clear(cached.nodes) if (typeof data.tag != "string") return - + var node, isNew = cached.nodes.length === 0 if (data.attrs.xmlns) namespace = data.attrs.xmlns else if (data.tag === "svg") namespace = "http://www.w3.org/2000/svg" @@ -126,7 +126,7 @@ Mithril = m = new function app(window) { } else cached.nodes.intact = true } - + return cached } function setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) { @@ -184,7 +184,7 @@ Mithril = m = new function app(window) { finally {m.endComputation()} } } - + var html var documentNode = { insertAdjacentHTML: function(_, data) { @@ -211,13 +211,13 @@ Mithril = m = new function app(window) { var node = root == window.document || root == window.document.documentElement ? documentNode : root cellCache[id] = build(node, null, cell, cellCache[id], false, 0, null, undefined) } - + m.trust = function(value) { value = new String(value) value.$trusted = true return value } - + var roots = [], modules = [], controllers = [], now = 0, lastRedraw = 0, lastRedrawId = 0, computePostRedrawHook = null m.module = function(root, module) { m.startComputation() @@ -249,21 +249,21 @@ Mithril = m = new function app(window) { } lastRedraw = now } - + var pendingRequests = 0 m.startComputation = function() {pendingRequests++} m.endComputation = function() { pendingRequests = Math.max(pendingRequests - 1, 0) if (pendingRequests == 0) m.redraw() } - + m.withAttr = function(prop, withAttrCallback) { return function(e) { e = e || event withAttrCallback(prop in e.currentTarget ? e.currentTarget[prop] : e.currentTarget.getAttribute(prop)) } } - + //routing var modes = {pathname: "", hash: "#", search: "?"} var redirect = function() {}, routeParams = {}, currentRoute @@ -325,9 +325,9 @@ Mithril = m = new function app(window) { for (var route in router) { if (route == path) return !void m.module(root, router[route]) - + var matcher = new RegExp("^" + route.replace(/:[^\/]+?\.{3}/g, "(.*?)").replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$") - + if (matcher.test(path)) { return !void path.replace(matcher, function() { var keys = route.match(/:[^\/]+/g) || [] @@ -377,7 +377,7 @@ Mithril = m = new function app(window) { function decodeSpace(string) { return decodeURIComponent(string.replace(/\+/g, " ")) } - + //model m.prop = function(store) { var prop = function() { @@ -447,7 +447,7 @@ Mithril = m = new function app(window) { return value } } - + var deferred = m.deferred() var results = [] for (var i = 0; i < args.length; i++) { @@ -522,12 +522,12 @@ Mithril = m = new function app(window) { ajax(xhrOptions) return deferred.promise } - + //testing API m.deps = function(mock) {return window = mock} //for internal testing only, do not use `m.deps.factory` m.deps.factory = app - + return m }(this) diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index ced6cf2a..245ae5f5 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -1,6 +1,6 @@ function testMithril(mock) { m.deps(mock) - + //m test(function() {return m("div").tag === "div"}) test(function() {return m(".foo").tag === "div"}) @@ -27,21 +27,21 @@ function testMithril(mock) { //m.module test(function() { mock.performance.$elapse(50) - + var root1 = mock.document.createElement("div") m.module(root1, { controller: function() {this.value = "test1"}, view: function(ctrl) {return ctrl.value} }) - + var root2 = mock.document.createElement("div") m.module(root2, { controller: function() {this.value = "test2"}, view: function(ctrl) {return ctrl.value} }) - + mock.requestAnimationFrame.$resolve() - + return root1.childNodes[0].nodeValue === "test1" && root2.childNodes[0].nodeValue === "test2" }) @@ -168,17 +168,17 @@ function testMithril(mock) { m.render(root, list.reverse().map(function(flag, index) { return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag}) })) - + mock.document.activeElement = root.childNodes[0] root.childNodes[0].checked = true root.childNodes[0].onclick({currentTarget: {checked: true}}) - + m.render(root, list.reverse().map(function(flag, index) { return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag}) })) - + mock.document.activeElement = null - + return root.childNodes[0].checked === false && root.childNodes[1].checked === true }) test(function() { @@ -384,7 +384,7 @@ function testMithril(mock) { return root.childNodes[0].childNodes.length == 2 }) //end m.render - + //m.redraw test(function() { mock.performance.$elapse(50) //setup @@ -425,7 +425,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test1", { @@ -437,7 +437,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.pathname = "/" - + var root = mock.document.createElement("div") m.route.mode = "pathname" m.route(root, "/test2", { @@ -449,7 +449,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.hash = "#" - + var root = mock.document.createElement("div") m.route.mode = "hash" m.route(root, "/test3", { @@ -461,7 +461,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test4/foo", { @@ -473,9 +473,9 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var module = {controller: function() {}, view: function() {return m.route.param("test")}} - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test5/foo", { @@ -492,9 +492,9 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var module = {controller: function() {}, view: function() {return m.route.param("a1")}} - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test6/foo", { @@ -512,9 +512,9 @@ function testMithril(mock) { //https://github.com/lhorie/mithril.js/issues/61 mock.performance.$elapse(50) //setup mock.location.search = "?" - + var module = {controller: function() {}, view: function() {return m.route.param("a1")}} - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test7/foo", { @@ -531,7 +531,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test8/foo/SEP/bar/baz", { @@ -548,7 +548,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test9/foo/bar/SEP/baz", { @@ -565,7 +565,7 @@ function testMithril(mock) { test(function() { mock.performance.$elapse(50) //setup mock.location.search = "?" - + var root = mock.document.createElement("div") m.route.mode = "search" m.route(root, "/test10/foo%20bar", { @@ -911,22 +911,22 @@ function testMithril(mock) { //m.startComputation/m.endComputation test(function() { mock.performance.$elapse(50) - + var controller var root = mock.document.createElement("div") m.module(root, { controller: function() {controller = this}, view: function(ctrl) {return ctrl.value} }) - + mock.performance.$elapse(50) - + m.startComputation() controller.value = "foo" m.endComputation() return root.childNodes[0].nodeValue === "foo" }) - + //console.log presence test(function() { return m.deps.factory.toString().indexOf("console") < 0 diff --git a/tests/svg.html b/tests/svg.html index 8b5254b7..6b8c08f4 100644 --- a/tests/svg.html +++ b/tests/svg.html @@ -31,7 +31,7 @@
  • a clock with the current time
  • The links should open in a new tab. All items should display title tooltips when hovered over.

    - +