diff --git a/Gruntfile.js b/Gruntfile.js index ae789912..cfbc6246 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,5 @@ module.exports = function(grunt) { - _ = require('lodash'); - + var _ = require("lodash"); var version = "0.2.0"; var inputFolder = "./docs"; @@ -8,7 +7,6 @@ module.exports = function(grunt) { var archiveFolder = "./archive"; var outputFolder = "../mithril"; - var guideLayout = "guide"; var guide = [ "auto-redrawing", "benchmarks", @@ -25,7 +23,6 @@ module.exports = function(grunt) { "tools", "web-services" ]; - var apiLayout = "api"; var api = [ "change-log", "roadmap", @@ -47,8 +44,6 @@ module.exports = function(grunt) { "mithril.xhr" ]; - - var md2htmlTasks = {}; var makeTasks = function(layout, pages) { pages.map(function(name) { @@ -83,7 +78,7 @@ module.exports = function(grunt) { url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'), auth: { user: user, pass: pass }, json: { passed: result.passed } - }, function (error, response, body) { + }, function (error, response) { if (error) { callback(error); } else if (response.statusCode !== 200) { diff --git a/mithril.js b/mithril.js index 015c9a50..a14bf0e1 100644 --- a/mithril.js +++ b/mithril.js @@ -1,6 +1,6 @@ var m = (function app(window, undefined) { - var VERSION = "v0.2.0-next"; - + "use strict"; + var VERSION = "v0.2.0-next"; function isFunction(object) { return typeof object === "function"; } @@ -59,7 +59,7 @@ var m = (function app(window, undefined) { var cell = {tag: "div", attrs: {}}; var match, classes = []; if (!isString(tag)) throw new Error("selector in m(selector, attrs, children) should be a string"); - while (match = parser.exec(tag)) { + while ((match = parser.exec(tag)) != null) { if (match[1] === "" && match[2]) cell.tag = match[2]; else if (match[1] === "#") cell.attrs.id = match[2]; else if (match[1] === ".") classes.push(match[2]); @@ -102,319 +102,451 @@ var m = (function app(window, undefined) { function dataToString(data) { //data.toString() might throw or return null if data is the return value of Console.log in Firefox (behavior depends on version) try { - if (data == null || data.toString() == null) data = ""; + if (data == null || data.toString() == null) return ""; } catch (e) { - data = ""; + return ""; } return data; } // This function was causing deopts in Chrome. function injectTextNode(parentElement, first, index, data) { try { - parentElement.insertBefore(first, parentElement.childNodes[index] || null); + insertNode(parentElement, first, index); first.nodeValue = data; - } - catch (e) {} //IE erroneously throws error when appending an empty text node after a null + } catch (e) {} //IE erroneously throws error when appending an empty text node after a null } + + function flatten(list) { + //recursively flatten array + for (var i = 0; i < list.length; i++) { + if (isArray(list[i])) { + list = list.concat.apply([], list); + //check current index again and flatten until there are no more nested arrays at that index + i--; + } + } + return list; + } + + function insertNode(parentElement, node, index) { + parentElement.insertBefore(node, parentElement.childNodes[index] || null); + } + + var DELETION = 1, INSERTION = 2, MOVE = 3; + + function handleKeysDiffer(data, existing, cached, parentElement) { + forKeys(data, function (key, i) { + existing[key = key.key] = existing[key] ? { + action: MOVE, + index: i, + from: existing[key].index, + element: cached.nodes[existing[key].index] || $document.createElement("div") + } : {action: INSERTION, index: i}; + }); + var actions = []; + for (var prop in existing) actions.push(existing[prop]); + var changes = actions.sort(sortChanges), newCached = new Array(cached.length); + newCached.nodes = cached.nodes.slice(); + + forEach(changes, function (change) { + var index = change.index; + if (change.action === DELETION) { + clear(cached[index].nodes, cached[index]); + newCached.splice(index, 1); + } + if (change.action === INSERTION) { + var dummy = $document.createElement("div"); + dummy.key = data[index].attrs.key; + insertNode(parentElement, dummy, index); + newCached.splice(index, 0, { + attrs: {key: data[index].attrs.key}, + nodes: [dummy] + }); + newCached.nodes[index] = dummy; + } + + if (change.action === MOVE) { + var changeElement = change.element; + var maybeChanged = parentElement.childNodes[index]; + if (maybeChanged !== changeElement && changeElement !== null) { + parentElement.insertBefore(changeElement, maybeChanged || null); + } + newCached[index] = cached[change.from]; + newCached.nodes[index] = changeElement; + } + }); + + return newCached; + } + + function diffKeys(data, cached, existing, parentElement) { + var keysDiffer = data.length !== cached.length; + if (!keysDiffer) { + forKeys(data, function (attrs, i) { + var cachedCell = cached[i]; + return keysDiffer = cachedCell && cachedCell.attrs && cachedCell.attrs.key !== attrs.key; + }); + } + + return keysDiffer ? handleKeysDiffer(data, existing, cached, parentElement) : cached; + } + + function diffArray(data, cached, nodes) { + //diff the array itself + + //update the list of DOM nodes by collecting the nodes from each item + forEach(data, function (_, i) { + if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes); + }) + //remove items from the end of the array if the new array is shorter than the old one. if errors ever happen here, the issue is most likely + //a bug in the construction of the `cached` data structure somewhere earlier in the program + forEach(cached.nodes, function (node, i) { + if (node.parentNode != null && nodes.indexOf(node) < 0) clear([node], [cached[i]]); + }) + if (data.length < cached.length) cached.length = data.length; + cached.nodes = nodes; + } + + function buildArrayKeys(data) { + var guid = 0; + forKeys(data, function () { + forEach(data, function (attrs) { + if ((attrs = attrs && attrs.attrs) && attrs.key == null) attrs.key = "__mithril__" + guid++; + }) + return 1; + }); + } + + function maybeRecreateObject(data, cached, dataAttrKeys) { + //if an element is different enough from the one in cache, recreate it + if (data.tag !== cached.tag || + dataAttrKeys.sort().join() !== Object.keys(cached.attrs).sort().join() || + data.attrs.id !== cached.attrs.id || + data.attrs.key !== cached.attrs.key || + (m.redraw.strategy() === "all" && (!cached.configContext || cached.configContext.retain !== true)) || + (m.redraw.strategy() === "diff" && cached.configContext && cached.configContext.retain === false)) { + if (cached.nodes.length) clear(cached.nodes); + if (cached.configContext && isFunction(cached.configContext.onunload)) cached.configContext.onunload(); + if (cached.controllers) { + forEach(cached.controllers, function (controller) { + if (controller.unload) controller.onunload({preventDefault: noop}); + }); + } + } + } + + function getObjectNamespace(data, namespace) { + return data.attrs.xmlns ? data.attrs.xmlns : + data.tag === "svg" ? "http://www.w3.org/2000/svg" : + data.tag === "math" ? "http://www.w3.org/1998/Math/MathML" : + namespace; + } + + function unloadCachedControllers(cached, views, controllers) { + if (controllers.length) { + cached.views = views; + cached.controllers = controllers; + forEach(controllers, function (controller) { + if (controller.onunload && controller.onunload.$old) controller.onunload = controller.onunload.$old; + if (pendingRequests && controller.onunload) { + var onunload = controller.onunload; + controller.onunload = noop; + controller.onunload.$old = onunload; + } + }); + } + } + + function scheduleConfigsToBeCalled(configs, data, node, isNew, cached) { + //schedule configs to be called. They are called after `build` + //finishes running + if (isFunction(data.attrs.config)) { + var context = cached.configContext = cached.configContext || {}; + + //bind + configs.push(function() { + return data.attrs.config.call(data, node, !isNew, context, cached); + }); + } + } + + function buildUpdatedNode(cached, data, editable, hasKeys, namespace, views, configs, controllers) { + var node = cached.nodes[0]; + if (hasKeys) setAttributes(node, data.tag, data.attrs, cached.attrs, namespace); + cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs); + cached.nodes.intact = true; + + if (controllers.length) { + cached.views = views; + cached.controllers = controllers; + } + + return node; + } + + function handleNonexistentNodes(data, parentElement, index) { + var nodes; + if (data.$trusted) { + nodes = injectHTML(parentElement, index, data); + } + else { + nodes = [$document.createTextNode(data)]; + if (!parentElement.nodeName.match(voidElements)) insertNode(parentElement, nodes[0], index); + } + + var cached = typeof data === "string" || typeof data === "number" || typeof data === "boolean" ? new data.constructor(data) : data; + cached.nodes = nodes; + return cached; + } + + function reattachNodes(data, cached, parentElement, editable, index, parentTag) { + var nodes = cached.nodes; + if (!editable || editable !== $document.activeElement) { + if (data.$trusted) { + clear(nodes, cached); + nodes = injectHTML(parentElement, index, data); + } + //corner case: replacing the nodeValue of a text node that is a child of a textarea/contenteditable doesn't work + //we need to update the value property of the parent textarea or the innerHTML of the contenteditable element instead + else if (parentTag === "textarea") { + parentElement.value = data; + } + else if (editable) { + editable.innerHTML = data; + } + else { + //was a trusted string + if (nodes[0].nodeType === 1 || nodes.length > 1) { + clear(cached.nodes, cached); + nodes = [$document.createTextNode(data)]; + } + injectTextNode(parentElement, nodes[0], index, data); + } + } + cached = new data.constructor(data); + cached.nodes = nodes; + return cached; + } + + function handleText(cached, data, index, parentElement, shouldReattach, editable, parentTag) { + //handle text nodes + return cached.nodes.length === 0 ? handleNonexistentNodes(data, parentElement, index) : + cached.valueOf() !== data.valueOf() || shouldReattach === true ? + reattachNodes(data, cached, parentElement, editable, index, parentTag) : + (cached.nodes.intact = true, cached); + } + + function getSubArrayCount(item) { + if (item.$trusted) { + //fix offset of next element if item was a trusted string w/ more than one html element + //the first clause in the regexp matches elements + //the second clause (after the pipe) matches text nodes + var match = item.match(/<[^\/]|\>\s*[^<]/g); + if (match != null) return match.length; + } + else if (isArray(item)) { + return item.length; + } + return 1; + } + + function buildArray(data, cached, parentElement, index, parentTag, shouldReattach, editable, namespace, configs) { + data = flatten(data); + var nodes = [], intact = cached.length === data.length, subArrayCount = 0; + + //keys algorithm: sort elements without recreating them if keys are present + //1) create a map of all existing keys, and mark all for deletion + //2) add new keys to map and mark them for addition + //3) if key exists in new list, change action from deletion to a move + //4) for each key, handle its corresponding action as marked in previous steps + var existing = {}, shouldMaintainIdentities = false; + forKeys(cached, function (attrs, i) { + shouldMaintainIdentities = true; + existing[cached[i].attrs.key] = {action: DELETION, index: i}; + }); + + buildArrayKeys(data); + if (shouldMaintainIdentities) cached = diffKeys(data, cached, existing, parentElement); + //end key algorithm + + var cacheCount = 0; + //faster explicitly written + for (var i = 0, len = data.length; i < len; i++) { + //diff each item in the array + var item = build(parentElement, parentTag, cached, index, data[i], cached[cacheCount], shouldReattach, index + subArrayCount || subArrayCount, editable, namespace, configs); + + if (item !== undefined) { + intact = intact && item.nodes.intact; + subArrayCount += getSubArrayCount(item); + cached[cacheCount++] = item; + } + } + + if (!intact) diffArray(data, cached, nodes); + return cached + } + + function makeCache(data, cached, index, parentIndex, parentCache) { + if (cached != null) { + if (type.call(cached) === type.call(data)) return cached; + + if (parentCache && parentCache.nodes) { + var offset = index - parentIndex, end = offset + (isArray(data) ? data : cached.nodes).length; + clear(parentCache.nodes.slice(offset, end), parentCache.slice(offset, end)); + } else if (cached.nodes) { + clear(cached.nodes, cached); + } + } + + cached = new data.constructor(); + //if constructor creates a virtual dom element, use a blank object + //as the base cached node instead of copying the virtual el (#277) + if (cached.tag) cached = {}; + cached.nodes = []; + return cached; + } + + function constructNode(data, namespace) { + return namespace === undefined ? + data.attrs.is ? $document.createElement(data.tag, data.attrs.is) : $document.createElement(data.tag) : + data.attrs.is ? $document.createElementNS(namespace, data.tag, data.attrs.is) : $document.createElementNS(namespace, data.tag); + } + + function constructAttrs(data, node, namespace, hasKeys) { + return hasKeys ? setAttributes(node, data.tag, data.attrs, {}, namespace) : data.attrs; + } + + function constructChildren(data, node, cached, editable, namespace, configs) { + return data.children != null && data.children.length > 0 ? + build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : + data.children; + } + + function reconstructCached(data, attrs, children, node, namespace, views, controllers) { + var cached = {tag: data.tag, attrs: attrs, children: children, nodes: [node]}; + unloadCachedControllers(cached, views, controllers); + if (cached.children && !cached.children.nodes) cached.children.nodes = []; + //edge case: setting value on doesn't work before children exist, so set it again after children have been created - if (data.tag === "select" && "value" in data.attrs) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace); - parentElement.insertBefore(node, parentElement.childNodes[index] || null); - } - else { - node = cached.nodes[0]; - if (hasKeys) setAttributes(node, data.tag, data.attrs, cached.attrs, namespace); - cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs); - cached.nodes.intact = true; - if (controllers.length) { - cached.views = views; - cached.controllers = controllers; - } - if (shouldReattach === true && node != null) parentElement.insertBefore(node, parentElement.childNodes[index] || null); - } - //schedule configs to be called. They are called after `build` finishes running - if (isFunction(data.attrs["config"])) { - var context = cached.configContext = cached.configContext || {}; - - // bind - var callback = function(data, args) { - return function() { - return data.attrs["config"].apply(data, args); - }; - }; - configs.push(callback(data, [node, !isNew, context, cached])); - } - } - else if (!isFunction(data)) { - //handle text nodes - var nodes; - if (cached.nodes.length === 0) { - if (data.$trusted) { - nodes = injectHTML(parentElement, index, data); - } - else { - nodes = [$document.createTextNode(data)]; - if (!parentElement.nodeName.match(voidElements)) parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null); - } - cached = "string number boolean".indexOf(typeof data) > -1 ? new data.constructor(data) : data; - cached.nodes = nodes; - } - else if (cached.valueOf() !== data.valueOf() || shouldReattach === true) { - nodes = cached.nodes; - if (!editable || editable !== $document.activeElement) { - if (data.$trusted) { - clear(nodes, cached); - nodes = injectHTML(parentElement, index, data); - } - else { - //corner case: replacing the nodeValue of a text node that is a child of a textarea/contenteditable doesn't work - //we need to update the value property of the parent textarea or the innerHTML of the contenteditable element instead - if (parentTag === "textarea") parentElement.value = data; - else if (editable) editable.innerHTML = data; - else { - if (nodes[0].nodeType === 1 || nodes.length > 1) { //was a trusted string - clear(cached.nodes, cached); - nodes = [$document.createTextNode(data)]; - } - injectTextNode(parentElement, nodes[0], index, data) - } - } - } - cached = new data.constructor(data); - cached.nodes = nodes; - } - else cached.nodes.intact = true; - } - - return cached; + cached = makeCache(data, cached, index, parentIndex, parentCache); + return isArray(data) ? buildArray(data, cached, parentElement, index, parentTag, shouldReattach, editable, namespace, configs) : + data != null && isObject(data) ? buildObject(data, cached, editable, parentElement, index, shouldReattach, namespace, configs) : + !isFunction(data) ? handleText(cached, data, index, parentElement, shouldReattach, editable, parentTag) : + cached; } function sortChanges(a, b) { return a.action - b.action || a.index - b.index; } function setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) { @@ -425,9 +557,9 @@ var m = (function app(window, undefined) { cachedAttrs[attrName] = dataAttr; try { //`config` isn't a real attributes, so ignore it - if (attrName === "config" || attrName == "key") continue; + if (attrName === "config" || attrName === "key") continue; //hook event handlers to the auto-redrawing system - else if (isFunction(dataAttr) && attrName.indexOf("on") === 0) { + else if (isFunction(dataAttr) && attrName.slice(0, 2) === "on") { node[attrName] = autoredraw(dataAttr, node); } //handle `style: {...}` @@ -442,13 +574,12 @@ var m = (function app(window, undefined) { //handle SVG else if (namespace != null) { if (attrName === "href") node.setAttributeNS("http://www.w3.org/1999/xlink", "href", dataAttr); - else if (attrName === "className") node.setAttribute("class", dataAttr); - else node.setAttribute(attrName, dataAttr); + else node.setAttribute(attrName === "className" ? "class" : attrName, dataAttr); } //handle cases that are properties (but ignore cases where we should use setAttribute instead) //- list and form are typically used as strings, but are DOM element references in js //- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js - else if (attrName in node && !(attrName === "list" || attrName === "style" || attrName === "form" || attrName === "type" || attrName === "width" || attrName === "height")) { + else if (attrName in node && attrName !== "list" && attrName !== "style" && attrName !== "form" && attrName !== "type" && attrName !== "width" && attrName !== "height") { //#348 don't set the value if not needed otherwise cursor placement breaks in Chrome if (tag !== "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr; } @@ -475,7 +606,7 @@ var m = (function app(window, undefined) { if (cached[i]) unload(cached[i]); } } - if (nodes.length != 0) nodes.length = 0; + nodes.length = 0; } function unload(cached) { if (cached.configContext && isFunction(cached.configContext.onunload)) { @@ -483,21 +614,19 @@ var m = (function app(window, undefined) { cached.configContext.onunload = null; } if (cached.controllers) { - for (var i = 0, controller; controller = cached.controllers[i]; i++) { + forEach(cached.controllers, function (controller) { if (isFunction(controller.onunload)) controller.onunload({preventDefault: noop}); - } + }); } if (cached.children) { - if (isArray(cached.children)) { - for (var i = 0, child; child = cached.children[i]; i++) unload(child); - } + if (isArray(cached.children)) forEach(cached.children, unload); else if (cached.children.tag) unload(cached.children); } } function injectHTML(parentElement, index, data) { var nextSibling = parentElement.childNodes[index]; if (nextSibling) { - var isElement = nextSibling.nodeType != 1; + var isElement = nextSibling.nodeType !== 1; var placeholder = $document.createElement("span"); if (isElement) { parentElement.insertBefore(placeholder, nextSibling || null); @@ -548,11 +677,11 @@ var m = (function app(window, undefined) { var id = getCellCacheKey(root); var isDocumentRoot = root === $document; var node = isDocumentRoot || root === $document.documentElement ? documentNode : root; - if (isDocumentRoot && cell.tag != "html") cell = {tag: "html", attrs: {}, children: cell}; + if (isDocumentRoot && cell.tag !== "html") cell = {tag: "html", attrs: {}, children: cell}; if (cellCache[id] === undefined) clear(node.childNodes); if (forceRecreation === true) reset(root); cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs); - for (var i = 0, len = configs.length; i < len; i++) configs[i](); + forEach(configs, function (config) { config(); }); }; function getCellCacheKey(element) { var index = nodeCache.indexOf(element); @@ -596,7 +725,7 @@ var m = (function app(window, undefined) { if (component.controller) controller.prototype = component.controller.prototype; var view = function(ctrl) { for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - return component.view.apply(component, args ? [ctrl].concat(args) : [ctrl]); + return component.view.apply(component, [ctrl].concat(args)); }; view.$original = component.view; var output = {controller: controller, view: view}; @@ -604,7 +733,7 @@ var m = (function app(window, undefined) { return output; } m.component = function(component) { - for (var args = [], i = 1; i < arguments.length; i++) args[i - 1] = arguments[i]; + for (var args = [], i = 1; i < arguments.length; i++) args.push(arguments[i]); return parameterize(component, args); }; m.mount = m.module = function(root, component) { @@ -617,12 +746,16 @@ var m = (function app(window, undefined) { isPrevented = true; computePreRedrawHook = computePostRedrawHook = null; }}; - for (var i = 0, unloader; unloader = unloaders[i]; i++) { + + forEach(unloaders, function (unloader) { unloader.handler.call(unloader.controller, event); unloader.controller.onunload = null; - } + }); + if (isPrevented) { - for (var i = 0, unloader; unloader = unloaders[i]; i++) unloader.controller.onunload = unloader.handler; + forEach(unloaders, function (unloader) { + unloader.controller.onunload = unloader.handler; + }); } else unloaders = []; @@ -634,10 +767,8 @@ var m = (function app(window, undefined) { m.redraw.strategy("all"); m.startComputation(); roots[index] = root; - if (arguments.length > 2) component = subcomponent(component, [].slice.call(arguments, 2)); - var currentComponent = topComponent = component = component || {controller: noop}; - var constructor = component.controller || noop; - var controller = new constructor; + var currentComponent = component ? (topComponent = component) : (topComponent = component = {controller: noop}); + var controller = new (component.controller || noop)(); //controllers may call m.mount recursively (via m.route redirects, for example) //this conditional ensures only the last recursive m.mount call is applied if (currentComponent === topComponent) { @@ -679,12 +810,14 @@ var m = (function app(window, undefined) { computePreRedrawHook(); computePreRedrawHook = null; } - for (var i = 0, root; root = roots[i]; i++) { + forEach(roots, function (root, i) { + var component = components[i]; if (controllers[i]) { - var args = components[i].controller && components[i].controller.$$args ? [controllers[i]].concat(components[i].controller.$$args) : [controllers[i]]; - m.render(root, components[i].view ? components[i].view(controllers[i], args) : ""); + var args = [controllers[i]]; + if (component.controller && component.controller.$$args) args = args.concat(component.controller.$$args); + m.render(root, component.view ? component.view(controllers[i], args) : ""); } - } + }); //after rendering within a routed context, we need to scroll back to the top, and fetch the document title for history.pushState if (computePostRedrawHook) { computePostRedrawHook(); @@ -698,16 +831,20 @@ var m = (function app(window, undefined) { var pendingRequests = 0; m.startComputation = function() { pendingRequests++; }; m.endComputation = function() { - pendingRequests = Math.max(pendingRequests - 1, 0); - if (pendingRequests === 0) m.redraw(); - }; - var endFirstComputation = function() { - if (m.redraw.strategy() == "none") { + if (pendingRequests > 1) pendingRequests--; + else { + pendingRequests = 0; + m.redraw(); + } + } + + function endFirstComputation() { + if (m.redraw.strategy() === "none") { pendingRequests--; m.redraw.strategy("diff"); } else m.endComputation(); - }; + } m.withAttr = function(prop, withAttrCallback) { return function(e) { @@ -738,10 +875,9 @@ var m = (function app(window, undefined) { window[listener] = function() { var path = $location[m.route.mode]; if (m.route.mode === "pathname") path += $location.search; - if (currentRoute != normalizeRoute(path)) { - redirect(path); - } + if (currentRoute !== normalizeRoute(path)) redirect(path); }; + computePreRedrawHook = setScroll; window[listener](); } @@ -822,7 +958,9 @@ var m = (function app(window, undefined) { path.replace(matcher, function() { var keys = route.match(/:[^\/]+/g) || []; var values = [].slice.call(arguments, 1, -2); - for (var i = 0, len = keys.length; i < len; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i]); + forEach(keys, function (key, i) { + routeParams[key.replace(/:|\./g, "")] = decodeURIComponent(values[i]); + }) m.mount(root, router[route]); }); return true; @@ -831,16 +969,19 @@ var m = (function app(window, undefined) { } function routeUnobtrusive(e) { e = e || event; + if (e.ctrlKey || e.metaKey || e.which === 2) return; + if (e.preventDefault) e.preventDefault(); else e.returnValue = false; + var currentTarget = e.currentTarget || e.srcElement; var args = m.route.mode === "pathname" && currentTarget.search ? parseQueryString(currentTarget.search.slice(1)) : {}; - while (currentTarget && currentTarget.nodeName.toUpperCase() != "A") currentTarget = currentTarget.parentNode; + while (currentTarget && currentTarget.nodeName.toUpperCase() !== "A") currentTarget = currentTarget.parentNode; m.route(currentTarget[m.route.mode].slice(modes[m.route.mode].length), args); } function setScroll() { - if (m.route.mode != "hash" && $location.hash) $location.hash = $location.hash; + if (m.route.mode !== "hash" && $location.hash) $location.hash = $location.hash; else window.scrollTo(0, 0); } function buildQueryString(object, prefix) { @@ -849,36 +990,42 @@ var m = (function app(window, undefined) { for (var prop in object) { var key = prefix ? prefix + "[" + prop + "]" : prop; var value = object[prop]; - var valueType = type.call(value); - var pair = (value === null) ? encodeURIComponent(key) : - isObject(value) ? buildQueryString(value, key) : - isArray(value) ? value.reduce(function(memo, item) { - if (!duplicates[key]) duplicates[key] = {}; + + if (value === null) { + str.push(encodeURIComponent(key)); + } else if (isObject(value)) { + str.push(buildQueryString(value, key)); + } else if (isArray(value)) { + var keys = []; + duplicates[key] = duplicates[key] || {}; + forEach(value, function (item) { if (!duplicates[key][item]) { duplicates[key][item] = true; - return memo.concat(encodeURIComponent(key) + "=" + encodeURIComponent(item)); + keys.push(encodeURIComponent(key) + "=" + encodeURIComponent(item)); } - return memo; - }, []).join("&") : - encodeURIComponent(key) + "=" + encodeURIComponent(value); - if (value !== undefined) str.push(pair); + }); + str.push(keys.join("&")); + } else if (value !== undefined) { + str.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); + } } return str.join("&"); } function parseQueryString(str) { - if (str.charAt(0) === "?") str = str.substring(1); + if (str.charAt(0) === "?") str = str.slice(1); var pairs = str.split("&"), params = {}; - for (var i = 0, len = pairs.length; i < len; i++) { - var pair = pairs[i].split("="); + forEach(pairs, function (string) { + var pair = string.split("="); var key = decodeURIComponent(pair[0]); - var value = pair.length == 2 ? decodeURIComponent(pair[1]) : null; + var value = pair.length === 2 ? decodeURIComponent(pair[1]) : null; if (params[key] != null) { if (!isArray(params[key])) params[key] = [params[key]]; params[key].push(value); } else params[key] = value; - } + }); + return params; } m.route.buildQueryString = buildQueryString; @@ -912,9 +1059,9 @@ var m = (function app(window, undefined) { var RESOLVING = 1, REJECTING = 2, RESOLVED = 3, REJECTED = 4; var self = this, state = 0, promiseValue = 0, next = []; - self["promise"] = {}; + self.promise = {}; - self["resolve"] = function(value) { + self.resolve = function(value) { if (!state) { promiseValue = value; state = RESOLVING; @@ -924,7 +1071,7 @@ var m = (function app(window, undefined) { return this; }; - self["reject"] = function(value) { + self.reject = function(value) { if (!state) { promiseValue = value; state = REJECTING; @@ -934,8 +1081,8 @@ var m = (function app(window, undefined) { return this; }; - self.promise["then"] = function(successCallback, failureCallback) { - var deferred = new Deferred(successCallback, failureCallback); + self.promise.then = function(successCallback, failureCallback) { + var deferred = new Deferred(successCallback, failureCallback) if (state === RESOLVED) { deferred.resolve(promiseValue); } @@ -945,13 +1092,13 @@ var m = (function app(window, undefined) { else { next.push(deferred); } - return deferred.promise; + return deferred.promise }; function finish(type) { state = type || REJECTED; next.map(function(deferred) { - state === RESOLVED && deferred.resolve(promiseValue) || deferred.reject(promiseValue); + state === RESOLVED ? deferred.resolve(promiseValue) : deferred.reject(promiseValue); }); } @@ -992,6 +1139,7 @@ var m = (function app(window, undefined) { state = REJECTING; return fire(); } + thennable(then, function() { state = RESOLVING; fire(); @@ -1017,8 +1165,7 @@ var m = (function app(window, undefined) { if (promiseValue === self) { promiseValue = TypeError(); finish(); - } - else { + } else { thennable(then, function () { finish(RESOLVED); }, finish, function () { @@ -1037,6 +1184,7 @@ var m = (function app(window, undefined) { m.sync = function(args) { var method = "resolve"; + function synchronizer(pos, resolved) { return function(value) { results[pos] = value; @@ -1053,9 +1201,9 @@ var m = (function app(window, undefined) { var outstanding = args.length; var results = new Array(outstanding); if (args.length > 0) { - for (var i = 0; i < args.length; i++) { - args[i].then(synchronizer(i, true), synchronizer(i, false)); - } + forEach(args, function (arg, i) { + arg.then(synchronizer(i, true), synchronizer(i, false)); + }); } else deferred.resolve([]); @@ -1065,7 +1213,7 @@ var m = (function app(window, undefined) { function ajax(options) { if (options.dataType && options.dataType.toLowerCase() === "jsonp") { - var callbackKey = "mithril_callback_" + new Date().getTime() + "_" + (Math.round(Math.random() * 1e16)).toString(36); + var callbackKey = "mithril_callback_" + new Date().getTime() + "_" + (Math.round(Math.random() * 1e16)).toString(36) var script = $document.createElement("script"); window[callbackKey] = function(resp) { @@ -1079,22 +1227,24 @@ var m = (function app(window, undefined) { window[callbackKey] = undefined; }; - script.onerror = function(e) { + script.onerror = function() { script.parentNode.removeChild(script); options.onerror({ type: "error", target: { status: 500, - responseText: JSON.stringify({error: "Error making jsonp request"}) + responseText: JSON.stringify({ + error: "Error making jsonp request" + }) } }); window[callbackKey] = undefined; return false; - }; + } - script.onload = function(e) { + script.onload = function() { return false; }; @@ -1106,7 +1256,7 @@ var m = (function app(window, undefined) { $document.body.appendChild(script); } else { - var xhr = new window.XMLHttpRequest; + var xhr = new window.XMLHttpRequest(); xhr.open(options.method, options.url, true, options.user, options.password); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { @@ -1126,15 +1276,16 @@ var m = (function app(window, undefined) { } var data = options.method === "GET" || !options.data ? "" : options.data; - if (data && (!isString(data) && data.constructor != window.FormData)) { - throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`"; + if (data && (!isString(data) && data.constructor !== window.FormData)) { + throw new Error("Request data should be either be a string or FormData. Check the `serialize` option in `m.request`"); } xhr.send(data); return xhr; } } + function bindData(xhrOptions, data, serialize) { - if (xhrOptions.method === "GET" && xhrOptions.dataType != "jsonp") { + if (xhrOptions.method === "GET" && xhrOptions.dataType !== "jsonp") { var prefix = xhrOptions.url.indexOf("?") < 0 ? "?" : "&"; var querystring = buildQueryString(data); xhrOptions.url = xhrOptions.url + (querystring ? prefix + querystring : ""); @@ -1142,14 +1293,15 @@ var m = (function app(window, undefined) { else xhrOptions.data = serialize(data); return xhrOptions; } + function parameterizeUrl(url, data) { var tokens = url.match(/:[a-z]\w+/gi); if (tokens && data) { - for (var i = 0; i < tokens.length; i++) { - var key = tokens[i].slice(1); - url = url.replace(tokens[i], data[key]); + forEach(tokens, function (token) { + var key = token.slice(1); + url = url.replace(token, data[key]); delete data[key]; - } + }); } return url; } @@ -1157,13 +1309,17 @@ var m = (function app(window, undefined) { m.request = function(xhrOptions) { if (xhrOptions.background !== true) m.startComputation(); var deferred = new Deferred(); - var isJSONP = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp"; + var isJSONP = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp" var serialize = xhrOptions.serialize = isJSONP ? identity : xhrOptions.serialize || JSON.stringify; var deserialize = xhrOptions.deserialize = isJSONP ? identity : xhrOptions.deserialize || JSON.parse; - var extract = isJSONP ? function(jsonp) { return jsonp.responseText; } : xhrOptions.extract || function(xhr) { - return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText; + var extract = isJSONP ? function(jsonp) { return jsonp.responseText } : xhrOptions.extract || function(xhr) { + if (xhr.responseText.length === 0 && deserialize === JSON.parse) { + return null + } else { + return xhr.responseText + } }; - xhrOptions.method = (xhrOptions.method || 'GET').toUpperCase(); + xhrOptions.method = (xhrOptions.method || "GET").toUpperCase(); xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data); xhrOptions = bindData(xhrOptions, xhrOptions.data, serialize); xhrOptions.onload = xhrOptions.onerror = function(e) { @@ -1176,17 +1332,20 @@ var m = (function app(window, undefined) { forEach(response, function (res, i) { response[i] = new xhrOptions.type(res); }); + } else if (xhrOptions.type) { + response = new xhrOptions.type(response); } - else if (xhrOptions.type) response = new xhrOptions.type(response); } + deferred[e.type === "load" ? "resolve" : "reject"](response); - } - catch (e) { + } catch (e) { m.deferred.onerror(e); deferred.reject(e); } - if (xhrOptions.background !== true) m.endComputation(); - }; + + if (xhrOptions.background !== true) m.endComputation() + } + ajax(xhrOptions); deferred.promise = propify(deferred.promise, xhrOptions.initialValue); return deferred.promise; @@ -1201,7 +1360,7 @@ var m = (function app(window, undefined) { m.deps.factory = app; return m; -})(typeof window != "undefined" ? window : {}); +})(typeof window !== "undefined" ? window : {}); -if (typeof module != "undefined" && module !== null && module.exports) module.exports = m; -else if (typeof define === "function" && define.amd) define(function() { return m; }); +if (typeof module === "object" && module != null && module.exports) module.exports = m; +else if (typeof define === "function" && define.amd) define(function() { return m }); diff --git a/mithril.min.js b/mithril.min.js index d60ff391..59280320 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -4,5 +4,5 @@ http://github.com/lhorie/mithril.js (c) Leo Horie License: MIT */ -var m=function a(b,c){function d(a){return"function"==typeof a}function e(a){return"[object Object]"===P.call(a)}function f(a){return"[object String]"===P.call(a)}function g(a){K=a.document,L=a.location,N=a.cancelAnimationFrame||a.clearTimeout,M=a.requestAnimationFrame||a.setTimeout}function h(a,b){for(var c=[],d=1;d\s*[^<]/g)||[0]).length:O(e)?e.length:1,t[V++]=e)}),D||(i(s,function(a,b){null!=t[b]&&C.push.apply(C,t[b].nodes)}),i(t.nodes,function(a,b){null!=a.parentNode&&C.indexOf(a)<0&&p([a],[t[b]])}),s.length-1?t.controllers[Z]:new(s.controller||T),_=s&&s.attrs&&s.attrs.key;if(s=0==ia||ha||t&&t.controllers&&t.controllers.indexOf($)>-1?s.view($):{tag:"placeholder"},"retain"===s.subtree)return t;null!=_&&(s.attrs||(s.attrs={}),s.attrs.key=_),$.onunload&&ea.push({controller:$,handler:$.onunload}),W.push(Y),X.push($)}if(!s.tag&&X.length)throw new Error("Component template must return a virtual element, not an array, string, etc.");s.attrs||(s.attrs={}),t.attrs||(t.attrs={});var aa=Object.keys(s.attrs),ba=aa.length>("key"in s.attrs?1:0);if((s.tag!=t.tag||aa.sort().join()!=Object.keys(t.attrs).sort().join()||s.attrs.id!=t.attrs.id||s.attrs.key!=t.attrs.key||"all"==h.redraw.strategy()&&(!t.configContext||t.configContext.retain!==!0)||"diff"==h.redraw.strategy()&&t.configContext&&t.configContext.retain===!1)&&(t.nodes.length&&p(t.nodes),t.configContext&&d(t.configContext.onunload)&&t.configContext.onunload(),t.controllers))for(var $,B=0;$=t.controllers[B];B++)d($.onunload)&&$.onunload({preventDefault:T});if(!f(s.tag))return;var ca,da=0===t.nodes.length;if(s.attrs.xmlns?x=s.attrs.xmlns:"svg"===s.tag?x="http://www.w3.org/2000/svg":"math"===s.tag&&(x="http://www.w3.org/1998/Math/MathML"),da){if(ca=s.attrs.is?x===c?K.createElement(s.tag,s.attrs.is):K.createElementNS(x,s.tag,s.attrs.is):x===c?K.createElement(s.tag):K.createElementNS(x,s.tag),t={tag:s.tag,attrs:ba?o(ca,s.tag,s.attrs,{},x):s.attrs,children:null!=s.children&&s.children.length>0?m(ca,s.tag,c,c,s.children,t.children,!0,0,s.attrs.contenteditable?ca:w,x,y):s.children,nodes:[ca]},X.length){t.views=W,t.controllers=X;for(var $,B=0;$=X[B];B++)if($.onunload&&$.onunload.$old&&($.onunload=$.onunload.$old),ia&&$.onunload){var fa=$.onunload;$.onunload=T,$.onunload.$old=fa}}t.children&&!t.children.nodes&&(t.children.nodes=[]),"select"===s.tag&&"value"in s.attrs&&o(ca,s.tag,{value:s.attrs.value},{},x),a.insertBefore(ca,a.childNodes[v]||null)}else ca=t.nodes[0],ba&&o(ca,s.tag,s.attrs,t.attrs,x),t.children=m(ca,s.tag,c,c,s.children,t.children,!1,0,s.attrs.contenteditable?ca:w,x,y),t.nodes.intact=!0,X.length&&(t.views=W,t.controllers=X),u===!0&&null!=ca&&a.insertBefore(ca,a.childNodes[v]||null);if(d(s.attrs.config)){var ga=t.configContext=t.configContext||{},ja=function(a,b){return function(){return a.attrs.config.apply(a,b)}};y.push(ja(s,[ca,!da,ga,t]))}}else if(!d(s)){var C;0===t.nodes.length?(s.$trusted?C=r(a,v,s):(C=[K.createTextNode(s)],a.nodeName.match(S)||a.insertBefore(C[0],a.childNodes[v]||null)),t="string number boolean".indexOf(typeof s)>-1?new s.constructor(s):s,t.nodes=C):t.valueOf()!==s.valueOf()||u===!0?(C=t.nodes,w&&w===K.activeElement||(s.$trusted?(p(C,t),C=r(a,v,s)):"textarea"===b?a.value=s:w?w.innerHTML=s:((1===C[0].nodeType||C.length>1)&&(p(t.nodes,t),C=[K.createTextNode(s)]),l(a,C[0],v,s))),t=new s.constructor(s),t.nodes=C):t.nodes.intact=!0}return t}function n(a,b){return a.action-b.action||a.index-b.index}function o(a,b,c,f,g){for(var h in c){var i=c[h],j=f[h];if(h in f&&j===i)"value"===h&&"input"===b&&a.value!=i&&(a.value=i);else{f[h]=i;try{if("config"===h||"key"==h)continue;if(d(i)&&0===h.indexOf("on"))a[h]=s(i,a);else if("style"===h&&null!=i&&e(i)){for(var k in i)(null==j||j[k]!==i[k])&&(a.style[k]=i[k]);for(var k in j)k in i||(a.style[k]="")}else null!=g?"href"===h?a.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===h?a.setAttribute("class",i):a.setAttribute(h,i):h in a&&"list"!==h&&"style"!==h&&"form"!==h&&"type"!==h&&"width"!==h&&"height"!==h?("input"!==b||a[h]!==i)&&(a[h]=i):a.setAttribute(h,i)}catch(l){if(l.message.indexOf("Invalid argument")<0)throw l}}}return f}function p(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&q(b[c])}0!=a.length&&(a.length=0)}function q(a){if(a.configContext&&d(a.configContext.onunload)&&(a.configContext.onunload(),a.configContext.onunload=null),a.controllers)for(var b,c=0;b=a.controllers[c];c++)d(b.onunload)&&b.onunload({preventDefault:T});if(a.children)if(O(a.children))for(var e,c=0;e=a.children[c];c++)q(e);else a.children.tag&&q(a.children)}function r(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=K.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function s(a,b){return function(c){c=c||event,h.redraw.strategy("diff"),h.startComputation();try{return a.call(b,c)}finally{ja()}}}function t(a){var b=W.indexOf(a);return 0>b?W.push(a)-1:b}function u(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function v(a,b){var c=function(){return(a.controller||T).apply(this,b)||this},d=function(c){for(var d=1;de;e++)ka[c[e].replace(/:|\./g,"")]=decodeURIComponent(d[e]);h.mount(a,b[g])}),!0}}function z(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!==a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;for(var b=a.currentTarget||a.srcElement,c="pathname"===h.route.mode&&b.search?C(b.search.slice(1)):{};b&&"A"!=b.nodeName.toUpperCase();)b=b.parentNode;h.route(b[h.route.mode].slice(ma[h.route.mode].length),c)}}function A(){"hash"!=h.route.mode&&L.hash?L.hash=L.hash:b.scrollTo(0,0)}function B(a,b){var d={},f=[];for(var g in a){var h=b?b+"["+g+"]":g,i=a[g],j=(P.call(i),null===i?encodeURIComponent(h):e(i)?B(i,h):O(i)?i.reduce(function(a,b){return d[h]||(d[h]={}),d[h][b]?a:(d[h][b]=!0,a.concat(encodeURIComponent(h)+"="+encodeURIComponent(b)))},[]).join("&"):encodeURIComponent(h)+"="+encodeURIComponent(i));i!==c&&f.push(j)}return f.join("&")}function C(a){"?"===a.charAt(0)&&(a=a.substring(1));for(var b=a.split("&"),c={},d=0,e=b.length;e>d;d++){var f=b[d].split("="),g=decodeURIComponent(f[0]),h=2==f.length?decodeURIComponent(f[1]):null;null!=c[g]?(O(c[g])||(c[g]=[c[g]]),c[g].push(h)):c[g]=h}return c}function D(a){var b=t(a);p(a.childNodes,X[b]),X[b]=c}function E(a,b){var c=h.prop(b);return a.then(c),c.then=function(c,d){return E(a.then(c,d),b)},c["catch"]=c.then.bind(null,null),c}function F(a,b){function c(a){n=a||l,p.map(function(a){n===k&&a.resolve(o)||a.reject(o)})}function f(a,b,c,f){if((null!=o&&e(o)||d(o))&&d(a))try{var g=0;a.call(o,function(a){g++||(o=a,b())},function(a){g++||(o=a,c())})}catch(i){h.deferred.onerror(i),o=i,c()}else f()}function g(){var e;try{e=o&&o.then}catch(l){return h.deferred.onerror(l),o=l,n=j,g()}f(e,function(){n=i,g()},function(){n=j,g()},function(){try{n===i&&d(a)?o=a(o):n===j&&d(b)&&(o=b(o),n=i)}catch(g){return h.deferred.onerror(g),o=g,c()}o===m?(o=TypeError(),c()):f(e,function(){c(k)},c,function(){c(n===i&&k)})})}var i=1,j=2,k=3,l=4,m=this,n=0,o=0,p=[];m.promise={},m.resolve=function(a){return n||(o=a,n=i,g()),this},m.reject=function(a){return n||(o=a,n=j,g()),this},m.promise.then=function(a,b){var c=new F(a,b);return n===k?c.resolve(o):n===l?c.reject(o):p.push(c),c.promise}}function G(a){return a}function H(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var e=new b.XMLHttpRequest;if(e.open(a.method,a.url,!0,a.user,a.password),e.onreadystatechange=function(){4===e.readyState&&(e.status>=200&&e.status<300?a.onload({type:"load",target:e}):a.onerror({type:"error",target:e}))},a.serialize===JSON.stringify&&a.data&&"GET"!==a.method&&e.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize===JSON.parse&&e.setRequestHeader("Accept","application/json, text/*"),d(a.config)){var g=a.config(e,a);null!=g&&(e=g)}var h="GET"!==a.method&&a.data?a.data:"";if(h&&!f(h)&&h.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return e.send(h),e}var i="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),j=K.createElement("script");b[i]=function(d){j.parentNode.removeChild(j),a.onload({type:"load",target:{responseText:d}}),b[i]=c},j.onerror=function(d){return j.parentNode.removeChild(j),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[i]=c,!1},j.onload=function(a){return!1},j.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+i+"&"+B(a.data||{}),K.body.appendChild(j)}function I(a,b,c){if("GET"===a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=B(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function J(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;di;i++)e[i]()},h.trust=function(a){return a=new String(a),a.$trusted=!0,a},h.prop=function(a){return(null!=a&&e(a)||d(a))&&d(a.then)?E(a):u(a)};var Y,Z=[],$=[],_=[],aa=null,ba=0,ca=null,da=null,ea=[],fa=16;h.component=function(a){for(var b=[],c=1;cc&&(c=Z.length);for(var e,f=!1,g={preventDefault:function(){f=!0,ca=da=null}},i=0;e=ea[i];i++)e.handler.call(e.controller,g),e.controller.onunload=null;if(f)for(var e,i=0;e=ea[i];i++)e.controller.onunload=e.handler;else ea=[];if(_[c]&&d(_[c].onunload)&&_[c].onunload(g),!f){h.redraw.strategy("all"),h.startComputation(),Z[c]=a,arguments.length>2&&(b=subcomponent(b,[].slice.call(arguments,2)));var j=Y=b=b||{controller:T},k=b.controller||T,l=new k;return j===Y&&(_[c]=l,$[c]=b),ja(),_[c]}};var ga=!1,ha=!1;h.redraw=function(a){if(!ga){ga=!0,a&&(ha=!0);try{aa&&!a?(M===b.requestAnimationFrame||new Date-ba>fa)&&(aa>0&&N(aa),aa=M(w,fa)):(w(),aa=M(function(){aa=null},fa))}finally{ga=ha=!1}}},h.redraw.strategy=h.prop();var ia=0;h.startComputation=function(){ia++},h.endComputation=function(){ia=Math.max(ia-1,0),0===ia&&h.redraw()};var ja=function(){"none"==h.redraw.strategy()?(ia--,h.redraw.strategy("diff")):h.endComputation()};h.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var ka,la,ma={pathname:"",hash:"#",search:"?"},na=T,oa=!1;return h.route=function(a,c,d,e){if(0===arguments.length)return la;if(3===arguments.length&&f(c)){na=function(b){var e=la=x(b);if(!y(a,d,e)){if(oa)throw new Error("Ensure the default route matches one of the routes defined in m.route");oa=!0,h.route(c,!0),oa=!1}};var g="hash"===h.route.mode?"onhashchange":"onpopstate";b[g]=function(){var a=L[h.route.mode];"pathname"===h.route.mode&&(a+=L.search),la!=x(a)&&na(a)},ca=A,b[g]()}else if(a.addEventListener||a.attachEvent)a.href=("pathname"!==h.route.mode?L.pathname:"")+ma[h.route.mode]+e.attrs.href,a.addEventListener?(a.removeEventListener("click",z),a.addEventListener("click",z)):(a.detachEvent("onclick",z),a.attachEvent("onclick",z));else if(f(a)){var i=la;la=a;var j=la.indexOf("?"),k=j>-1?C(la.slice(j+1)):{};for(var l in c)k[l]=c[l];var m=B(k),n=j>-1?la.slice(0,j):la;m&&(la=n+(-1===n.indexOf("?")?"?":"&")+m);var o=(3===arguments.length?d:c)===!0||i===a;b.history.pushState?(ca=A,da=function(){b.history[o?"replaceState":"pushState"](null,K.title,ma[h.route.mode]+la)},na(ma[h.route.mode]+la)):(L[h.route.mode]=la,na(ma[h.route.mode]+la))}},h.route.param=function(a){if(!ka)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return ka[a]},h.route.mode="search",h.route.buildQueryString=B,h.route.parseQueryString=C,h.deferred=function(){var a=new F;return a.promise=E(a.promise),a},h.deferred.onerror=function(a){if("[object Error]"===P.call(a)&&!a.constructor.toString().match(/ Error/))throw ia=0,a},h.sync=function(a){function b(a,b){return function(g){return f[a]=g,b||(c="reject"),0===--e&&(d.promise(f),d[c](f)),g}}var c="resolve",d=h.deferred(),e=a.length,f=new Array(e);if(a.length>0)for(var g=0;g1)&&(P(b.nodes,b),g=[ja.createTextNode(a)]),l(c,g[0],e,a))),b=new a.constructor(a),b.nodes=g,b}function z(a,b,c,d,e,f,g){return 0===a.nodes.length?x(b,d,c):a.valueOf()!==b.valueOf()||e===!0?y(b,a,d,f,c,g):(a.nodes.intact=!0,a)}function A(a){if(a.$trusted){var b=a.match(/<[^\/]|\>\s*[^<]/g);if(null!=b)return b.length}else if(oa(a))return a.length;return 1}function B(a,b,d,e,f,g,h,i,k){a=m(a);var l=[],n=b.length===a.length,o=0,s={},t=!1;j(b,function(a,c){t=!0,s[b[c].attrs.key]={action:va,index:c}}),r(a),t&&(b=p(a,b,s,d));for(var u=0,v=0,w=a.length;w>v;v++){var x=M(d,f,b,e,a[v],b[u],g,e+o||o,h,i,k);x!==c&&(n=n&&x.nodes.intact,o+=A(x),b[u++]=x)}return n||q(a,b,l),b}function C(a,b,c,d,e){if(null!=b){if(pa.call(b)===pa.call(a))return b;if(e&&e.nodes){var f=c-d,g=f+(oa(a)?a:b.nodes).length;P(e.nodes.slice(f,g),e.slice(f,g))}else b.nodes&&P(b.nodes,b)}return b=new a.constructor,b.tag&&(b={}),b.nodes=[],b}function D(a,b){return b===c?a.attrs.is?ja.createElement(a.tag,a.attrs.is):ja.createElement(a.tag):a.attrs.is?ja.createElementNS(b,a.tag,a.attrs.is):ja.createElementNS(b,a.tag)}function E(a,b,c,d){return d?O(b,a.tag,a.attrs,{},c):a.attrs}function F(a,b,d,e,f,g){return null!=a.children&&a.children.length>0?M(b,a.tag,c,c,a.children,d.children,!0,0,a.attrs.contenteditable?b:e,f,g):a.children}function G(a,b,c,d,e,f,g){var h={tag:a.tag,attrs:b,children:c,nodes:[d]};return u(h,f,g),h.children&&!h.children.nodes&&(h.children.nodes=[]),"select"===a.tag&&"value"in a.attrs&&O(d,a.tag,{value:a.attrs.value},{},e),h}function H(a,b,c,d){var e="diff"===h.redraw.strategy()&&a?a.indexOf(b):-1;return e>-1?c[e]:"function"==typeof d?new d:{}}function I(a,b,c,d){null!=d.onunload&&Ja.push({controller:d,handler:d.onunload}),a.push(c),b.push(d)}function J(a,b,c,d,e,f){var g=H(c.views,b,d,a.controller),h=+(a&&a.attrs&&a.attrs.key);return a=0===Na||Ma||d&&d.indexOf(g)>-1?a.view(g):{tag:"placeholder"},"retain"===a.subtree?c:(h===h&&((a.attrs=a.attrs||{}).key=h),I(f,e,b,g),a)}function K(a,b,c,d){for(var e=b&&b.controllers;null!=a.view;)a=J(a,a.view.$original||a.view,b,e,d,c);return a}function L(a,b,c,d,e,g,h,i){var j=[],k=[];if(a=K(a,b,j,k),!a.tag&&k.length)throw new Error("Component template must return a virtual element, not an array, string, etc.");a.attrs=a.attrs||{},b.attrs=b.attrs||{};var l=Object.keys(a.attrs),m=l.length>("key"in a.attrs?1:0);if(s(a,b,l),f(a.tag)){var o=0===b.nodes.length;h=t(a,h);var p;if(o){p=D(a,h);var q=E(a,p,h,m),r=F(a,p,b,c,h,i);b=G(a,q,r,p,h,j,k)}else p=w(b,a,c,m,h,j,i,k);return(o||g===!0&&null!=p)&&n(d,p,e),v(i,a,p,o,b),b}}function M(a,b,c,f,g,h,i,j,l,m,n){return g=k(g),"retain"===g.subtree?h:(h=C(g,h,j,f,c),oa(g)?B(g,h,a,j,b,i,l,m,n):null!=g&&e(g)?L(g,h,l,a,j,i,m,n):d(g)?h:z(h,g,j,a,i,l,b))}function N(a,b){return a.action-b.action||a.index-b.index}function O(a,b,c,f,g){for(var h in c){var i=c[h],j=f[h];if(h in f&&j===i)"value"===h&&"input"===b&&a.value!=i&&(a.value=i);else{f[h]=i;try{if("config"===h||"key"===h)continue;if(d(i)&&"on"===h.slice(0,2))a[h]=S(i,a);else if("style"===h&&null!=i&&e(i)){for(var k in i)(null==j||j[k]!==i[k])&&(a.style[k]=i[k]);for(var k in j)k in i||(a.style[k]="")}else null!=g?"href"===h?a.setAttributeNS("http://www.w3.org/1999/xlink","href",i):a.setAttribute("className"===h?"class":h,i):h in a&&"list"!==h&&"style"!==h&&"form"!==h&&"type"!==h&&"width"!==h&&"height"!==h?("input"!==b||a[h]!==i)&&(a[h]=i):a.setAttribute(h,i)}catch(l){if(l.message.indexOf("Invalid argument")<0)throw l}}}return f}function P(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&Q(b[c])}a.length=0}function Q(a){a.configContext&&d(a.configContext.onunload)&&(a.configContext.onunload(),a.configContext.onunload=null),a.controllers&&i(a.controllers,function(a){d(a.onunload)&&a.onunload({preventDefault:ta})}),a.children&&(oa(a.children)?i(a.children,Q):a.children.tag&&Q(a.children))}function R(a,b,c){var d=a.childNodes[b];if(d){var e=1!==d.nodeType,f=ja.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function S(a,b){return function(c){c=c||event,h.redraw.strategy("diff"),h.startComputation();try{return a.call(b,c)}finally{X()}}}function T(a){var b=za.indexOf(a);return 0>b?za.push(a)-1:b}function U(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function V(a,b){var c=function(){return(a.controller||ta).apply(this,b)||this};a.controller&&(c.prototype=a.controller.prototype);var d=function(c){for(var d=1;d=200&&e.status<300?a.onload({type:"load",target:e}):a.onerror({type:"error",target:e}))},a.serialize===JSON.stringify&&a.data&&"GET"!==a.method&&e.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize===JSON.parse&&e.setRequestHeader("Accept","application/json, text/*"),d(a.config)){var g=a.config(e,a);null!=g&&(e=g)}var h="GET"!==a.method&&a.data?a.data:"";if(h&&!f(h)&&h.constructor!==b.FormData)throw new Error("Request data should be either be a string or FormData. Check the `serialize` option in `m.request`");return e.send(h),e}var i="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),j=ja.createElement("script");b[i]=function(d){j.parentNode.removeChild(j),a.onload({type:"load",target:{responseText:d}}),b[i]=c},j.onerror=function(){return j.parentNode.removeChild(j),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[i]=c,!1},j.onload=function(){return!1},j.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+i+"&"+aa(a.data||{}),ja.body.appendChild(j)}function ha(a,b,c){if("GET"===a.method&&"jsonp"!==a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=aa(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function ia(a,b){var c=a.match(/:[a-z]\w+/gi);return c&&b&&i(c,function(c){var d=c.slice(1);a=a.replace(c,b[d]),delete b[d]}),a}var ja,ka,la,ma,na="v0.2.0-next",oa=Array.isArray||function(a){return"[object Array]"===pa.call(a)},pa={}.toString,qa=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,ra=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,sa=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/,ta=function(){};g(b),h.version=function(){return na};var ua,va=1,wa=2,xa=3,ya={appendChild:function(a){ua===c&&(ua=ja.createElement("html")),ja.documentElement&&ja.documentElement!==a?ja.replaceChild(a,ja.documentElement):ja.appendChild(a),this.childNodes=ja.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},za=[],Aa={};h.render=function(a,b,d){var e=[];if(!a)throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var f=T(a),g=a===ja,h=g||a===ja.documentElement?ya:a;g&&"html"!==b.tag&&(b={tag:"html",attrs:{},children:b}),Aa[f]===c&&P(h.childNodes),d===!0&&ca(a),Aa[f]=M(h,null,c,c,b,Aa[f],!1,0,null,c,e),i(e,function(a){a()})},h.trust=function(a){return a=new String(a),a.$trusted=!0,a},h.prop=function(a){return(null!=a&&e(a)||d(a))&&d(a.then)?da(a):U(a)};var Ba,Ca=[],Da=[],Ea=[],Fa=null,Ga=0,Ha=null,Ia=null,Ja=[],Ka=16;h.component=function(a){for(var b=[],c=1;cc&&(c=Ca.length);var e=!1,f={preventDefault:function(){e=!0,Ha=Ia=null}};if(i(Ja,function(a){a.handler.call(a.controller,f),a.controller.onunload=null}),e?i(Ja,function(a){a.controller.onunload=a.handler}):Ja=[],Ea[c]&&d(Ea[c].onunload)&&Ea[c].onunload(f),!e){h.redraw.strategy("all"),h.startComputation(),Ca[c]=a;var g=Ba=b?b:b={controller:ta},j=new(b.controller||ta);return g===Ba&&(Ea[c]=j,Da[c]=b),X(),Ea[c]}};var La=!1,Ma=!1;h.redraw=function(a){if(!La){La=!0,a&&(Ma=!0);try{Fa&&!a?(la===b.requestAnimationFrame||new Date-Ga>Ka)&&(Fa>0&&ma(Fa),Fa=la(W,Ka)):(W(),Fa=la(function(){Fa=null},Ka))}finally{La=Ma=!1}}},h.redraw.strategy=h.prop();var Na=0;h.startComputation=function(){Na++},h.endComputation=function(){Na>1?Na--:(Na=0,h.redraw())},h.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var Oa,Pa,Qa={pathname:"",hash:"#",search:"?"},Ra=ta,Sa=!1;return h.route=function(a,c,d,e){if(0===arguments.length)return Pa;if(3===arguments.length&&f(c)){Ra=function(b){var e=Pa=Y(b);if(!Z(a,d,e)){if(Sa)throw new Error("Ensure the default route matches one of the routes defined in m.route");Sa=!0,h.route(c,!0),Sa=!1}};var g="hash"===h.route.mode?"onhashchange":"onpopstate";b[g]=function(){var a=ka[h.route.mode];"pathname"===h.route.mode&&(a+=ka.search),Pa!==Y(a)&&Ra(a)},Ha=_,b[g]()}else if(a.addEventListener||a.attachEvent)a.href=("pathname"!==h.route.mode?ka.pathname:"")+Qa[h.route.mode]+e.attrs.href,a.addEventListener?(a.removeEventListener("click",$),a.addEventListener("click",$)):(a.detachEvent("onclick",$),a.attachEvent("onclick",$));else if(f(a)){var i=Pa;Pa=a;var j=c||{},k=Pa.indexOf("?"),l=k>-1?ba(Pa.slice(k+1)):{};for(var m in j)l[m]=j[m];var n=aa(l),o=k>-1?Pa.slice(0,k):Pa;n&&(Pa=o+(-1===o.indexOf("?")?"?":"&")+n);var p=(3===arguments.length?d:c)===!0||i===a;b.history.pushState?(Ha=_,Ia=function(){b.history[p?"replaceState":"pushState"](null,ja.title,Qa[h.route.mode]+Pa)},Ra(Qa[h.route.mode]+Pa)):(ka[h.route.mode]=Pa,Ra(Qa[h.route.mode]+Pa))}},h.route.param=function(a){if(!Oa)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return Oa[a]},h.route.mode="search",h.route.buildQueryString=aa,h.route.parseQueryString=ba,h.deferred=function(){var a=new ea;return a.promise=da(a.promise),a},h.deferred.onerror=function(a){if("[object Error]"===pa.call(a)&&!a.constructor.toString().match(/ Error/))throw Na=0,a},h.sync=function(a){function b(a,b){return function(g){return f[a]=g,b||(c="reject"),0===--e&&(d.promise(f),d[c](f)),g}}var c="resolve",d=h.deferred(),e=a.length,f=new Array(e);return a.length>0?i(a,function(a,c){a.then(b(c,!0),b(c,!1))}):d.resolve([]),d.promise},h.request=function(a){a.background!==!0&&h.startComputation();var b=new ea,c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?fa:a.serialize||JSON.stringify,e=a.deserialize=c?fa:a.deserialize||JSON.parse,f=c?function(a){return a.responseText}:a.extract||function(a){return 0===a.responseText.length&&e===JSON.parse?null:a.responseText};return a.method=(a.method||"GET").toUpperCase(),a.url=ia(a.url,a.data),a=ha(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"===c.type?a.unwrapSuccess:a.unwrapError)||fa,g=d(e(f(c.target,a)),c.target);"load"===c.type&&(oa(g)&&a.type?i(g,function(b,c){g[c]=new a.type(b)}):a.type&&(g=new a.type(g))),b["load"===c.type?"resolve":"reject"](g)}catch(c){h.deferred.onerror(c),b.reject(c)}a.background!==!0&&h.endComputation()},ga(a),b.promise=da(b.promise,a.initialValue),b.promise},h.deps=function(a){return g(b=a||b),b},h.deps.factory=a,h}("undefined"!=typeof window?window:{});"object"==typeof module&&null!=module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m}); //# sourceMappingURL=mithril.min.js.map \ No newline at end of file diff --git a/mithril.min.js.map b/mithril.min.js.map index 3fb3ad8e..5643298d 100644 --- a/mithril.min.js.map +++ b/mithril.min.js.map @@ -1 +1 @@ -{"version":3,"file":"mithril.min.js","sources":["mithril.js"],"names":["m","app","window","undefined","isFunction","object","isObject","type","call","isString","initialize","$document","document","$location","location","$cancelAnimationFrame","cancelAnimationFrame","clearTimeout","$requestAnimationFrame","requestAnimationFrame","setTimeout","tag","pairs","args","i","arguments","length","parameterize","match","hasAttrs","attrs","classAttrName","cell","classes","Error","parser","exec","id","push","pair","attrParser","children","slice","isArray","attrName","hasOwnProperty","join","forEach","list","f","forKeys","key","dataToString","data","toString","e","injectTextNode","parentElement","first","index","insertBefore","childNodes","nodeValue","build","parentTag","parentCache","parentIndex","cached","shouldReattach","editable","namespace","configs","subtree","nodes","offset","end","clear","constructor","concat","apply","intact","subArrayCount","DELETION","INSERTION","MOVE","existing","shouldMaintainIdentities","action","guid","keysDiffer","cachedCell","from","element","createElement","actions","prop","changes","sort","sortChanges","newCached","Array","change","splice","dummy","cacheCount","entry","item","$trusted","_","node","parentNode","indexOf","views","controllers","view","$original","controllerIndex","redraw","strategy","controller","noop","pendingRequests","forcing","onunload","unloaders","handler","dataAttrKeys","Object","keys","hasKeys","configContext","retain","preventDefault","isNew","xmlns","is","createElementNS","setAttributes","contenteditable","$old","value","context","callback","injectHTML","createTextNode","nodeName","voidElements","valueOf","activeElement","innerHTML","nodeType","a","b","dataAttrs","cachedAttrs","dataAttr","cachedAttr","autoredraw","rule","style","setAttributeNS","setAttribute","message","removeChild","unload","child","nextSibling","isElement","placeholder","insertAdjacentHTML","event","startComputation","endFirstComputation","getCellCacheKey","nodeCache","gettersetter","store","toJSON","component","this","ctrl","output","computePreRedrawHook","root","roots","components","$$args","render","computePostRedrawHook","lastRedrawId","lastRedrawCallTime","Date","normalizeRoute","route","modes","mode","routeByValue","router","path","routeParams","queryStart","parseQueryString","substr","mount","matcher","RegExp","replace","test","values","len","decodeURIComponent","routeUnobtrusive","ctrlKey","metaKey","which","returnValue","currentTarget","srcElement","search","toUpperCase","setScroll","hash","scrollTo","buildQueryString","prefix","duplicates","str","encodeURIComponent","reduce","memo","charAt","substring","split","params","reset","cacheKey","cellCache","propify","promise","initialValue","then","resolve","reject","bind","Deferred","successCallback","failureCallback","finish","state","REJECTED","next","map","deferred","RESOLVED","promiseValue","thennable","notThennableCallback","count","onerror","fire","REJECTING","RESOLVING","self","TypeError","identity","ajax","options","dataType","toLowerCase","xhr","XMLHttpRequest","open","method","url","user","password","onreadystatechange","readyState","status","onload","target","serialize","JSON","stringify","setRequestHeader","deserialize","parse","config","maybeXhr","FormData","send","callbackKey","getTime","Math","round","random","script","resp","responseText","error","src","body","appendChild","bindData","xhrOptions","querystring","parameterizeUrl","tokens","html","documentNode","documentElement","replaceChild","forceRecreation","isDocumentRoot","trust","String","topComponent","FRAME_BUDGET","module","unloader","isPrevented","subcomponent","currentComponent","redrawing","force","endComputation","max","withAttr","withAttrCallback","getAttribute","currentRoute","pathname","redirect","isDefaultRoute","arg1","arg2","vdom","source","listener","addEventListener","attachEvent","href","removeEventListener","detachEvent","oldRoute","queryIndex","currentPath","shouldReplaceHistoryEntry","history","pushState","title","param","sync","synchronizer","pos","resolved","results","outstanding","request","background","isJSONP","extract","jsonp","unwrap","unwrapSuccess","unwrapError","response","res","deps","mock","factory","exports","define","amd"],"mappings":";;;;;;AAAA,GAAIA,GAAI,QAAUC,GAAIC,EAAQC,GAC7B,QAASC,GAAWC,GACnB,MAAyB,kBAAXA,GAEf,QAASC,GAASD,GACjB,MAA6B,oBAAtBE,EAAKC,KAAKH,GAElB,QAASI,GAASJ,GACjB,MAA6B,oBAAtBE,EAA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"file":"mithril.min.js","sources":["mithril.js"],"names":["m","app","window","undefined","isFunction","object","isObject","type","call","isString","initialize","$document","document","$location","location","$cancelAnimationFrame","cancelAnimationFrame","clearTimeout","$requestAnimationFrame","requestAnimationFrame","setTimeout","tag","pairs","args","i","arguments","length","parameterize","match","hasAttrs","attrs","classAttrName","cell","classes","Error","parser","exec","id","push","pair","attrParser","children","slice","isArray","attrName","hasOwnProperty","join","forEach","list","f","forKeys","key","dataToString","data","toString","e","injectTextNode","parentElement","first","index","insertNode","nodeValue","flatten","concat","apply","node","insertBefore","childNodes","handleKeysDiffer","existing","cached","action","MOVE","from","element","nodes","createElement","INSERTION","actions","prop","changes","sort","sortChanges","newCached","Array","change","DELETION","clear","splice","dummy","changeElement","maybeChanged","diffKeys","keysDiffer","cachedCell","diffArray","_","parentNode","indexOf","buildArrayKeys","guid","maybeRecreateObject","dataAttrKeys","Object","keys","redraw","strategy","configContext","retain","onunload","controllers","controller","unload","preventDefault","noop","getObjectNamespace","namespace","xmlns","unloadCachedControllers","views","$old","pendingRequests","scheduleConfigsToBeCalled","configs","isNew","config","context","buildUpdatedNode","editable","hasKeys","setAttributes","build","contenteditable","intact","handleNonexistentNodes","$trusted","injectHTML","createTextNode","nodeName","voidElements","constructor","reattachNodes","parentTag","activeElement","value","innerHTML","nodeType","handleText","shouldReattach","valueOf","getSubArrayCount","item","buildArray","subArrayCount","shouldMaintainIdentities","cacheCount","len","makeCache","parentIndex","parentCache","offset","end","constructNode","is","createElementNS","constructAttrs","constructChildren","reconstructCached","getController","view","cachedControllers","controllerIndex","updateLists","unloaders","handler","checkView","forcing","subtree","markViews","$original","buildObject","a","b","dataAttrs","cachedAttrs","dataAttr","cachedAttr","autoredraw","rule","style","setAttributeNS","setAttribute","message","removeChild","nextSibling","isElement","placeholder","insertAdjacentHTML","callback","event","startComputation","endFirstComputation","getCellCacheKey","nodeCache","gettersetter","store","toJSON","component","this","prototype","ctrl","output","computePreRedrawHook","roots","root","components","$$args","render","computePostRedrawHook","lastRedrawId","lastRedrawCallTime","Date","endComputation","normalizeRoute","route","modes","mode","routeByValue","router","path","routeParams","queryStart","parseQueryString","substr","mount","matcher","RegExp","replace","test","values","decodeURIComponent","routeUnobtrusive","ctrlKey","metaKey","which","returnValue","currentTarget","srcElement","search","toUpperCase","setScroll","hash","scrollTo","buildQueryString","prefix","duplicates","str","encodeURIComponent","charAt","split","params","string","reset","cacheKey","cellCache","propify","promise","initialValue","then","resolve","reject","bind","Deferred","successCallback","failureCallback","finish","state","REJECTED","next","map","deferred","RESOLVED","promiseValue","thennable","notThennableCallback","count","onerror","fire","REJECTING","RESOLVING","self","TypeError","identity","ajax","options","dataType","toLowerCase","xhr","XMLHttpRequest","open","method","url","user","password","onreadystatechange","readyState","status","onload","target","serialize","JSON","stringify","setRequestHeader","deserialize","parse","maybeXhr","FormData","send","callbackKey","getTime","Math","round","random","script","resp","responseText","error","src","body","appendChild","bindData","xhrOptions","querystring","parameterizeUrl","tokens","token","VERSION","version","html","documentNode","documentElement","replaceChild","forceRecreation","isDocumentRoot","trust","String","topComponent","FRAME_BUDGET","module","isPrevented","unloader","currentComponent","redrawing","force","withAttr","withAttrCallback","getAttribute","currentRoute","pathname","redirect","isDefaultRoute","arg1","arg2","vdom","source","listener","addEventListener","attachEvent","href","removeEventListener","detachEvent","oldRoute","queryIndex","currentPath","shouldReplaceHistoryEntry","history","pushState","title","param","sync","synchronizer","pos","resolved","results","outstanding","arg","request","background","isJSONP","extract","jsonp","unwrap","unwrapSuccess","unwrapError","response","res","deps","mock","factory","exports","define","amd"],"mappings":";;;;;;AAAA,GAAIA,GAAI,QAAUC,GAAIC,EAAQC,GAC7B,YAGA,SAASC,GAAWC,GACnB,MAAyB,kBAAXA,GAEf,QAASC,GAASD,GACjB,MAA6B,oBAAtBE,GAAKC,KAAKH,GAElB,QAASI,GAASJ,GACjB,MAA6B,oBAAtBE,GAAKC,KAAKH,GAclB,QAASK,GAAWR,GACnBS,GAAYT,EAAOU,SACnBC,GAA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,EAAY4E,EAAQ9U,EAAE6P,OAAQuB,IAAcpR,EAAE6P,OACrD,UAAX7P,EAAEhD,OACDoC,GAAQ+V,IAAa/D,EAAWpU,KACnCwC,EAAQ2V,EAAU,SAAUC,EAAKnX,GAChCkX,EAASlX,GAAK,GAAImT,GAAWpU,KAAKoY,KAEzBhE,EAAWpU,OACrBmY,EAAW,GAAI/D,GAAWpU,KAAKmY,KAIjClH,EAAoB,SAAXjO,EAAEhD,KAAkB,UAAY,UAAUmY,GAClD,MAAOnV,GACRvD,EAAEwR,SAASM,QAAQvO,GACnBiO,EAASV,OAAOvN,GAGboR,EAAWwD,cAAe,GAAMnY,EAAE8N,kBAGvCuE,GAAKsC,GACLnD,EAASd,QAAUD,GAAQe,EAASd,QAASiE,EAAWhE,cACjDa,EAASd,SAIjB1Q,EAAE4Y,KAAO,SAASC,GAEjB,MADAnY,GAAWR,EAAS2Y,GAAQ3Y,GACrBA,GAGRF,EAAE4Y,KAAKE,QAAU7Y,EAEVD,GACa,mBAAXE,QAAyBA,UAEb,iBAAX0V,SAAiC,MAAVA,QAAkBA,OAAOmD,QAASnD,OAAOmD,QAAU/Y,EAC1D,kBAAXgZ,SAAyBA,OAAOC,KAAKD,OAAO,WAAa,MAAOhZ"} \ No newline at end of file diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index 1dd8de03..078ba122 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -1,6 +1,6 @@ //saucelabs reporting; see https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit + var log = [] -var testName QUnit.done(function (test_results) { var tests = [] @@ -85,7 +85,7 @@ test('array item removal', function() { m('div', {}, '2') ]) - var view2= m('div', {}, [ + var view2 = m('div', {}, [ m('div', {}, '0') ]) @@ -105,7 +105,7 @@ test('issue99 regression', function() { m('div', {}, '2') ]) - var view2= m('div', {}, [ + var view2 = m('div', {}, [ m('span', {}, '0') ]) @@ -124,7 +124,7 @@ test('config handler context', function() { }}) m.render(dummyEl, view) - var view = m('div', {config: function(evt, isInitialized, context) { + view = m('div', {config: function(evt, isInitialized, context) { equal(context instanceof Object, true) equal(context.data, 1) }}) diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index cfad62d5..146ab7df 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.version().constructor === String}) test(function() {return m("div").tag === "div"}) @@ -27,13 +27,13 @@ function testMithril(mock) { test(function() {return m("div", [{foo: "bar"}])}) //as long as it doesn't throw errors, it's fine test(function() {return m("svg", [m("g")])}) test(function() {return m("svg", [m("a[href='http://google.com']")])}) - test(function() {return m(".foo", {"class": "bar"}).attrs["class"] == "foo bar"}) - test(function() {return m(".foo", {className: "bar"}).attrs.className == "foo bar"}) - test(function() {return m(".foo", {className: ""}).attrs.className == "foo"}) + test(function() {return m(".foo", {"class": "bar"}).attrs["class"] === "foo bar"}) + test(function() {return m(".foo", {className: "bar"}).attrs.className === "foo bar"}) + test(function() {return m(".foo", {className: ""}).attrs.className === "foo"}) test(function() {return m("div", {className: ""}).attrs.className === ""}) //https://github.com/lhorie/mithril.js/issues/382 and 512 - test(function() {return m("div", {class: ""}).attrs.className === undefined}) - test(function() {return m("div", {className: ""}).attrs.class === undefined}) - test(function() {return m("div", {class: ""}).attrs.class === ""}) + test(function() {return m("div", {"class": ""}).attrs.className === undefined}) + test(function() {return m("div", {className: ""}).attrs["class"] === undefined}) + test(function() {return m("div", {"class": ""}).attrs["class"] === ""}) test(function() {return m("div", [1, 2, 3], 4).children.length === 2}) test(function() {return m("div", [1, 2, 3], 4).children[0].length === 3}) test(function() {return m("div", [1, 2, 3], 4).children[1] === 4}) @@ -44,8 +44,8 @@ function testMithril(mock) { test(function() {return m("div", [1], [2], [3]).children.length === 3}) test(function() { //class changes shouldn't trigger dom recreation - var v1 = m(".foo", {class: "", onclick: function() {}}) - var v2 = m(".foo", {class: "bar", onclick: function() {}}) + var v1 = m(".foo", {"class": "", onclick: function() {}}) + var v2 = m(".foo", {"class": "bar", onclick: function() {}}) return Object.keys(v1.attrs).join() === Object.keys(v2.attrs).join() }) test(function() { @@ -54,7 +54,7 @@ function testMithril(mock) { controller: function(args) { this.args = args }, - view: function(ctrl) { + view: function () { return m("div", "testing") } } @@ -62,7 +62,7 @@ function testMithril(mock) { var c1 = m(component, args).controller() var c2 = m.component(component, args).controller() - return c1.args === args && c1.args == c2.args + return c1.args === args && c1.args === c2.args }) //m.mount @@ -74,21 +74,21 @@ function testMithril(mock) { return [ whatever % 2 ? m('span', '% 2') : undefined, m('div', 'bugs'), - m('a'), + m('a') ] } } m.mount(root, app) mock.requestAnimationFrame.$resolve() - + whatever++ m.redraw() mock.requestAnimationFrame.$resolve() - + whatever++ m.redraw() mock.requestAnimationFrame.$resolve() - + return root.childNodes.length }) test(function() { @@ -116,7 +116,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") var unloaded = false - var mod = m.mount(root, { + m.mount(root, { controller: function() { this.value = "test1" this.onunload = function() { @@ -129,9 +129,9 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.mount(root, null) - + mock.requestAnimationFrame.$resolve() - + return unloaded }) test(function() { @@ -148,14 +148,14 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() - return slot1 == 1 && slot2 == 1 + return slot1 === 1 && slot2 === 1 }) test(function() { //component should work without controller mock.requestAnimationFrame.$resolve() var root = mock.document.createElement("div") - var slot1, slot2 + var slot2 var component = { view: function(ctrl, options) {slot2 = options.a} } @@ -163,7 +163,7 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() - return slot2 == 1 + return slot2 === 1 }) test(function() { //component controller should only run once @@ -172,7 +172,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") var count1 = 0, count2 = 0 var component = { - view: function(ctrl) { + view: function() { return sub } } @@ -180,7 +180,7 @@ function testMithril(mock) { controller: function() { count1++ }, - view: function(ctrl) { + view: function() { count2++ return m("div", "test") } @@ -188,12 +188,12 @@ function testMithril(mock) { m.mount(root, component) mock.requestAnimationFrame.$resolve() - + m.redraw(true) mock.requestAnimationFrame.$resolve() - - return count1 == 1 && count2 == 2 + + return count1 === 1 && count2 === 2 }) test(function() { //sub component controller should only run once @@ -202,7 +202,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") var count1 = 0, count2 = 0, count3 = 0, count4 = 0 var component = { - view: function(ctrl) { + view: function() { return sub } } @@ -210,7 +210,7 @@ function testMithril(mock) { controller: function() { count1++ }, - view: function(ctrl) { + view: function() { count2++ return subsub } @@ -219,7 +219,7 @@ function testMithril(mock) { controller: function() { count3++ }, - view: function(ctrl) { + view: function() { count4++ return m("div", "test") } @@ -227,12 +227,12 @@ function testMithril(mock) { m.mount(root, component) mock.requestAnimationFrame.$resolve() - + m.redraw(true) mock.requestAnimationFrame.$resolve() - - return count1 == 1 && count2 == 2 && count3 == 1 && count4 == 2 + + return count1 === 1 && count2 === 2 && count3 === 1 && count4 === 2 }) test(function() { //keys in components should work @@ -242,7 +242,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -255,18 +255,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2] - + return firstBefore === firstAfter }) test(function() { @@ -277,7 +277,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -295,18 +295,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2] - + return firstBefore === firstAfter }) test(function() { @@ -317,7 +317,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -330,18 +330,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2] - + return firstBefore === firstAfter }) test(function() { @@ -352,7 +352,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -371,18 +371,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2] - + return firstBefore === firstAfter }) test(function() { @@ -393,7 +393,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m("div", {key: i}, sub) }) @@ -406,18 +406,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0].childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2].childNodes[0] - + return firstBefore === firstAfter }) test(function() { @@ -428,7 +428,7 @@ function testMithril(mock) { var list = [1, 2, 3] var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m("div", {key: i}, sub) }) @@ -447,18 +447,18 @@ function testMithril(mock) { } } m.mount(root, component) - + var firstBefore = root.childNodes[0].childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.reverse() m.redraw(true) mock.requestAnimationFrame.$resolve() - + var firstAfter = root.childNodes[2].childNodes[0] - + return firstBefore === firstAfter }) test(function() { @@ -470,7 +470,7 @@ function testMithril(mock) { var unloaded var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -487,16 +487,14 @@ function testMithril(mock) { } } m.mount(root, component) - - var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.pop() m.redraw(true) mock.requestAnimationFrame.$resolve() - + return unloaded === 3 }) test(function() { @@ -508,7 +506,7 @@ function testMithril(mock) { var unloaded1, unloaded2 var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return list.map(function(i) { return m.component(sub, {key: i}) }) @@ -535,16 +533,14 @@ function testMithril(mock) { } } m.mount(root, component) - - var firstBefore = root.childNodes[0] - + mock.requestAnimationFrame.$resolve() - + list.pop() m.redraw(true) mock.requestAnimationFrame.$resolve() - + return unloaded1 === 3 && unloaded2 === 3 }) test(function() { @@ -555,12 +551,12 @@ function testMithril(mock) { var count = 0 var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return sub } } var sub = { - controller: function(opts) { + controller: function() { m.redraw() }, view: function() { @@ -569,9 +565,9 @@ function testMithril(mock) { } } m.mount(root, component) - + mock.requestAnimationFrame.$resolve() - + return count === 1 }) test(function() { @@ -582,18 +578,18 @@ function testMithril(mock) { var count = 0 var component = { controller: function() {}, - view: function(ctrl) { + view: function() { return sub } } var sub = { - controller: function(opts) {}, + controller: function() {}, view: function() { return subsub } } var subsub = { - controller: function(opts) { + controller: function() { m.redraw() }, view: function() { @@ -602,9 +598,9 @@ function testMithril(mock) { } } m.mount(root, component) - + mock.requestAnimationFrame.$resolve() - + return count === 1 }) test(function() { @@ -622,8 +618,7 @@ function testMithril(mock) { } } var sub = { - controller: function(opts) { - controller = this + controller: function() { this.onunload = function(e) {if (testEnabled) e.preventDefault()} }, view: function() { @@ -634,14 +629,14 @@ function testMithril(mock) { "/a": component, "/b": {controller: function() {loaded = true}, view: function() {}} }) - + mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() testEnabled = false - + return loaded === false }) test(function() { @@ -659,15 +654,13 @@ function testMithril(mock) { } } var sub = { - controller: function(opts) { - }, + controller: function() {}, view: function() { return subsub } } var subsub = { - controller: function(opts) { - controller = this + controller: function() { this.onunload = function(e) {if (testEnabled) e.preventDefault()} }, view: function() { @@ -678,14 +671,14 @@ function testMithril(mock) { "/a": component, "/b": {controller: function() {loaded = true}, view: function() {}} }) - + mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() testEnabled = false - + return loaded === false }) test(function() { @@ -703,8 +696,7 @@ function testMithril(mock) { } } var sub = { - controller: function(opts) { - controller = this + controller: function() { this.onunload = function(e) {if (testEnabled) e.preventDefault()} }, view: function() { @@ -715,14 +707,14 @@ function testMithril(mock) { "/a": component, "/b": {controller: function() {loaded = true}, view: function() {}} }) - + mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() testEnabled = false - + return loaded === false }) test(function() { @@ -740,14 +732,13 @@ function testMithril(mock) { } } var sub = { - controller: function(opts) {}, + controller: function() {}, view: function() { return subsub } } var subsub = { - controller: function(opts) { - controller = this + controller: function() { this.onunload = function(e) {if (testEnabled) e.preventDefault()} }, view: function() { @@ -758,14 +749,14 @@ function testMithril(mock) { "/a": component, "/b": {controller: function() {loaded = true}, view: function() {}} }) - + mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() testEnabled = false - + return loaded === false }) test(function() { @@ -776,8 +767,8 @@ function testMithril(mock) { var count = 0 var App = { controller: function() {}, - view: function(ctrl) { - return m('.outer', [ + view: function() { + return m('.outer', [ m('.inner', m.component(CommentList, { list: [1, 2, 3] })) ]) } @@ -859,12 +850,12 @@ function testMithril(mock) { component.view = function() {} m.mount(root, component) m.mount(root, {controller: function() {}, view: function() {}}) - + return unloaded === true }) test(function() { mock.requestAnimationFrame.$resolve() - + var root = mock.document.createElement("div") var initCount = 0 var component = {} @@ -874,20 +865,20 @@ function testMithril(mock) { }}) } m.mount(root, component) - + mock.requestAnimationFrame.$resolve() - + m.redraw() - + mock.requestAnimationFrame.$resolve() - - return initCount == 1 + + return initCount === 1 }) test(function() { var root = mock.document.createElement("div") - + var dom = mock.document.createElement("div") - + var show = true var component = { @@ -906,20 +897,20 @@ function testMithril(mock) { } m.mount(root, component) - + mock.requestAnimationFrame.$resolve() - + show = false m.redraw() - + mock.requestAnimationFrame.$resolve() - + show = true m.redraw() - + mock.requestAnimationFrame.$resolve() - - return root.childNodes.length == 3 + + return root.childNodes.length === 3 }) test(function() { var root = mock.document.createElement("div") @@ -929,34 +920,34 @@ function testMithril(mock) { view: function() { return m('div', 'component'); } - }; + } var app = { - view: function(scope) { + view: function() { return show ? [ m('h1', '1'), testcomponent ] : [ - m('h1', '2'), + m('h1', '2') ]; } }; m.mount(root, app); - + mock.requestAnimationFrame.$resolve() - + show = false m.redraw() - + mock.requestAnimationFrame.$resolve() - + show = true m.redraw() - + mock.requestAnimationFrame.$resolve() - - return root.childNodes.length == 2 + + return root.childNodes.length === 2 }) test(function() { // Components should not require a view @@ -965,7 +956,7 @@ function testMithril(mock) { var Component = { view: function () { - return m('.comp') + return m('.comp') } } @@ -981,7 +972,7 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() - return root.childNodes[0].nodeName == "DIV" + return root.childNodes[0].nodeName === "DIV" }) test(function() { //https://github.com/lhorie/mithril.js/issues/551 @@ -1012,13 +1003,13 @@ function testMithril(mock) { } } m.mount(root, Root) - + var target = root.childNodes[0].childNodes[0] target.onclick({currentTarget: target}) - + mock.requestAnimationFrame.$resolve() - return !unloaded && found.id === "a" && redraws == 3 + return !unloaded && found.id === "a" && redraws === 3 }) test(function() { //https://github.com/lhorie/mithril.js/issues/551 @@ -1050,13 +1041,13 @@ function testMithril(mock) { } } m.mount(root, Root) - + var target = root.childNodes[0].childNodes[0] target.onclick({currentTarget: target}) - + mock.requestAnimationFrame.$resolve() - return !unloaded && found.id === "a" && redraws == 2 + return !unloaded && found.id === "a" && redraws === 2 }) test(function() { var root = mock.document.createElement("div") @@ -1067,15 +1058,15 @@ function testMithril(mock) { return m("div", {onclick: function() {m.redraw(true)}}) } } - + m.mount(root, Root) - + var target = root.childNodes[0] target.onclick({currentTarget: target}) - + mock.requestAnimationFrame.$resolve() - - return redraws == 3 + + return redraws === 3 }) test(function() { //https://github.com/lhorie/mithril.js/issues/555 @@ -1110,14 +1101,14 @@ function testMithril(mock) { '/': FooPage, '/bar': BarPage }) - + mock.requestAnimationFrame.$resolve() - + m.route("/bar") - + mock.requestAnimationFrame.$resolve() - - return root.childNodes[0].childNodes[2].childNodes[0].nodeValue == "Bob" + + return root.childNodes[0].childNodes[2].childNodes[0].nodeValue === "Bob" }) test(function() { var root = mock.document.createElement("div") @@ -1127,7 +1118,7 @@ function testMithril(mock) { return Comp } } - + var Comp = { controller: function() { this.foo = m.request({method: "GET", url: "/foo"}) @@ -1138,17 +1129,17 @@ function testMithril(mock) { return m("div") } } - + m.mount(root, Root) - + mock.requestAnimationFrame.$resolve() mock.XMLHttpRequest.$instances.pop().onreadystatechange() - + mock.requestAnimationFrame.$resolve() m.mount(root, null) mock.requestAnimationFrame.$resolve() - - return redraws == 1 && data.url == "/foo" + + return redraws === 1 && data.url === "/foo" }) test(function() { mock.requestAnimationFrame.$resolve() @@ -1164,12 +1155,11 @@ function testMithril(mock) { ]) } } - var Comp1 = { controller: function() { this.foo = m.request({method: "GET", url: "/foo"}) }, - view: function(ctrl) { + view: function() { redraws1++ return m("div") } @@ -1178,25 +1168,25 @@ function testMithril(mock) { controller: function() { this.bar = m.request({method: "GET", url: "/bar"}) }, - view: function(ctrl) { + view: function() { redraws2++ return m("div") } } - + m.mount(root, Root) - + mock.requestAnimationFrame.$resolve() mock.XMLHttpRequest.$instances.pop().onreadystatechange() - + mock.requestAnimationFrame.$resolve() mock.XMLHttpRequest.$instances.pop().onreadystatechange() - + mock.requestAnimationFrame.$resolve() m.mount(root, null) mock.requestAnimationFrame.$resolve() - - return redraws1 == 1 && redraws2 == 1 + + return redraws1 === 1 && redraws2 === 1 }) test(function() { var root = mock.document.createElement("div") @@ -1211,12 +1201,11 @@ function testMithril(mock) { return Comp2 } } - var Comp1 = { controller: function() { this.foo = m.request({method: "GET", url: "/foo"}) }, - view: function(ctrl) { + view: function() { redraws1++ return m("div") } @@ -1225,35 +1214,36 @@ function testMithril(mock) { controller: function() { this.bar = m.request({method: "GET", url: "/bar"}) }, - view: function(ctrl) { + view: function() { redraws2++ return m("div") } } - + + m.route(root, "/", { "/": Root1, "/root2": Root2 }) - + mock.requestAnimationFrame.$resolve() mock.XMLHttpRequest.$instances.pop().onreadystatechange() - + m.route("/root2") - - + + mock.requestAnimationFrame.$resolve() mock.XMLHttpRequest.$instances.pop().onreadystatechange() - + mock.requestAnimationFrame.$resolve() m.mount(root, null) mock.requestAnimationFrame.$resolve() - - return redraws1 == 1 && redraws2 == 1 + + return redraws1 === 1 && redraws2 === 1 }) test(function() { var root = mock.document.createElement("div") - + var cond = true var controller1 = null, controller2 = null var Root = { @@ -1261,7 +1251,7 @@ function testMithril(mock) { return cond ? Comp1 : Comp2 } } - + var Comp1 = { view: function(ctrl) { controller1 = ctrl @@ -1274,21 +1264,21 @@ function testMithril(mock) { return m("div") } } - + m.mount(root, Root) - + mock.requestAnimationFrame.$resolve() - + cond = false m.redraw(true) - + mock.requestAnimationFrame.$resolve() - + return controller1 !== controller2 }) test(function() { var root = mock.document.createElement("div") - + var cond = true var unloaded = false var Root = { @@ -1296,34 +1286,34 @@ function testMithril(mock) { return cond ? Comp1 : Comp2 } } - + var Comp1 = { - view: function(ctrl) { + view: function() { return m("div", {config: function(el, init, ctx) { ctx.onunload = function() {unloaded = true} }}) } } var Comp2 = { - view: function(ctrl) { + view: function() { return m("div") } } - + m.mount(root, Root) - + mock.requestAnimationFrame.$resolve() - + cond = false m.redraw(true) - + mock.requestAnimationFrame.$resolve() - + return unloaded }) test(function() { var root = mock.document.createElement("div") - + var cond = true var initialized = null var Root = { @@ -1331,29 +1321,29 @@ function testMithril(mock) { return cond ? Comp1 : Comp2 } } - + var Comp1 = { - view: function(ctrl) { + view: function() { return m("div") } } var Comp2 = { - view: function(ctrl) { + view: function() { return m("div", {config: function(el, init) { initialized = init }}) } } - + m.mount(root, Root) - + mock.requestAnimationFrame.$resolve() - + cond = false m.redraw(true) - + mock.requestAnimationFrame.$resolve() - + return initialized === false }) test(function() { @@ -1377,12 +1367,12 @@ function testMithril(mock) { } }; m.mount(root, FooPage); - + root.childNodes[0].childNodes[0].onclick({}) - - return el.id == "bar" + + return el.id === "bar" }) - + //m.withAttr test(function() { var value @@ -1443,13 +1433,13 @@ function testMithril(mock) { test(function() { var root = mock.document.createElement("div") m.render(root, m("div", [undefined])) - return root.childNodes[0].childNodes[0].nodeValue == "" + return root.childNodes[0].childNodes[0].nodeValue === "" }) test(function() { var root = mock.document.createElement("div") m.render(root, m("svg", [m("g")])) var g = root.childNodes[0].childNodes[0] - return g.nodeName === "G" && g.namespaceURI == "http://www.w3.org/2000/svg" + return g.nodeName === "G" && g.namespaceURI === "http://www.w3.org/2000/svg" }) test(function() { var root = mock.document.createElement("div") @@ -1460,25 +1450,25 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, m("div.classname", [m("a", {href: "/first"})])) m.render(root, m("div", [m("a", {href: "/second"})])) - return root.childNodes[0].childNodes.length == 1 + return root.childNodes[0].childNodes.length === 1 }) test(function() { var root = mock.document.createElement("div") m.render(root, m("ul", [m("li")])) m.render(root, m("ul", [m("li"), undefined])) - return root.childNodes[0].childNodes[1].nodeValue == "" + return root.childNodes[0].childNodes[1].nodeValue === "" }) test(function() { var root = mock.document.createElement("div") m.render(root, m("ul", [m("li"), m("li")])) m.render(root, m("ul", [m("li"), undefined])) - return root.childNodes[0].childNodes[1].nodeValue == "" + return root.childNodes[0].childNodes[1].nodeValue === "" }) test(function() { var root = mock.document.createElement("div") m.render(root, m("ul", [m("li")])) m.render(root, m("ul", [undefined])) - return root.childNodes[0].childNodes[0].nodeValue == "" + return root.childNodes[0].childNodes[0].nodeValue === "" }) test(function() { var root = mock.document.createElement("div") @@ -1490,13 +1480,13 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, m("ul", [m("li")])) m.render(root, m("ul", [{tag: "b", attrs: {}}])) - return root.childNodes[0].childNodes[0].nodeName == "B" + return root.childNodes[0].childNodes[0].nodeName === "B" }) test(function() { var root = mock.document.createElement("div") m.render(root, m("ul", [m("li")])) m.render(root, m("ul", [{tag: new String("b"), attrs: {}}])) - return root.childNodes[0].childNodes[0].nodeName == "B" + return root.childNodes[0].childNodes[0].nodeName === "B" }) test(function() { var root = mock.document.createElement("div") @@ -1648,13 +1638,13 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, [null, "foo"]) m.render(root, ["bar"]) - return root.childNodes.length == 1 + return root.childNodes.length === 1 }) test(function() { //https://github.com/lhorie/mithril.js/issues/56 var root = mock.document.createElement("div") m.render(root, m("div", "foo")) - return root.childNodes.length == 1 + return root.childNodes.length === 1 }) test(function() { var root = mock.document.createElement("div") @@ -1701,21 +1691,21 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, m("div", [[m("a"), m("a")], m("button")])) m.render(root, m("div", [[m("a")], m("button")])) - return root.childNodes[0].childNodes.length == 2 && root.childNodes[0].childNodes[1].nodeName == "BUTTON" + return root.childNodes[0].childNodes.length === 2 && root.childNodes[0].childNodes[1].nodeName === "BUTTON" }) test(function() { //https://github.com/lhorie/mithril.js/issues/87 var root = mock.document.createElement("div") m.render(root, m("div", [m("a"), m("b"), m("button")])) m.render(root, m("div", [m("a"), m("button")])) - return root.childNodes[0].childNodes.length == 2 && root.childNodes[0].childNodes[1].nodeName == "BUTTON" + return root.childNodes[0].childNodes.length === 2 && root.childNodes[0].childNodes[1].nodeName === "BUTTON" }) test(function() { //https://github.com/lhorie/mithril.js/issues/99 var root = mock.document.createElement("div") m.render(root, m("div", [m("img"), m("h1")])) m.render(root, m("div", [m("a")])) - return root.childNodes[0].childNodes.length == 1 && root.childNodes[0].childNodes[0].nodeName == "A" + return root.childNodes[0].childNodes.length === 1 && root.childNodes[0].childNodes[0].nodeName === "A" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1723,7 +1713,7 @@ function testMithril(mock) { m.render(root, m("div", ["a", "b", "c", "d"])) m.render(root, m("div", [["d", "e"]])) var children = root.childNodes[0].childNodes - return children.length == 2 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 2 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1731,7 +1721,7 @@ function testMithril(mock) { m.render(root, m("div", [["a", "b", "c", "d"]])) m.render(root, m("div", ["d", "e"])) var children = root.childNodes[0].childNodes - return children.length == 2 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 2 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1739,7 +1729,7 @@ function testMithril(mock) { m.render(root, m("div", ["x", [["a"], "b", "c", "d"]])) m.render(root, m("div", ["d", ["e"]])) var children = root.childNodes[0].childNodes - return children.length == 2 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 2 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1747,7 +1737,7 @@ function testMithril(mock) { m.render(root, m("div", ["b"])) m.render(root, m("div", [["e"]])) var children = root.childNodes[0].childNodes - return children.length == 1 && children[0].nodeValue == "e" + return children.length === 1 && children[0].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1755,7 +1745,7 @@ function testMithril(mock) { m.render(root, m("div", ["a", ["b"]])) m.render(root, m("div", ["d", [["e"]]])) var children = root.childNodes[0].childNodes - return children.length == 2 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 2 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1763,7 +1753,7 @@ function testMithril(mock) { m.render(root, m("div", ["a", [["b"]]])) m.render(root, m("div", ["d", ["e"]])) var children = root.childNodes[0].childNodes - return children.length == 2 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 2 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { //https://github.com/lhorie/mithril.js/issues/120 @@ -1771,11 +1761,11 @@ function testMithril(mock) { m.render(root, m("div", ["a", [["b"], "c"]])) m.render(root, m("div", ["d", [[["e"]], "x"]])) var children = root.childNodes[0].childNodes - return children.length == 3 && children[0].nodeValue == "d" && children[1].nodeValue == "e" + return children.length === 3 && children[0].nodeValue === "d" && children[1].nodeValue === "e" }) test(function() { var root = mock.document.createElement("div") - + var success = false m.render(root, m("div", {config: function(elem, isInitialized, ctx) {ctx.data = 1}})) m.render(root, m("div", {config: function(elem, isInitialized, ctx) {success = ctx.data === 1}})) @@ -1810,14 +1800,14 @@ function testMithril(mock) { var root = mock.document.createElement("div") var count = 0 m.render(root, m("div", m("a", { - config: function(el) { + config: function() { var island = mock.document.createElement("div") count++ - if (count > 2) throw "too much recursion..." + if (count > 2) throw new Error("too much recursion...") m.render(island, m("div")) } }))); - return count == 1 + return count === 1 }) test(function() { //https://github.com/lhorie/mithril.js/issues/129 @@ -1834,7 +1824,7 @@ function testMithril(mock) { var firstBefore = root.childNodes[0] m.render(root, [m("a", {key: 4}, 4), m("a", {key: 1}, 1), m("a", {key: 2}, 2), m("a", {key: 3}, 3)]) var firstAfter = root.childNodes[1] - return firstBefore == firstAfter && root.childNodes[0].childNodes[0].nodeValue == "4" && root.childNodes.length == 4 + return firstBefore === firstAfter && root.childNodes[0].childNodes[0].nodeValue === "4" && root.childNodes.length === 4 }) test(function() { //https://github.com/lhorie/mithril.js/issues/98 @@ -1843,7 +1833,7 @@ function testMithril(mock) { var firstBefore = root.childNodes[0] m.render(root, [m("a", {key: 4}, 4), m("a", {key: 1}, 1), m("a", {key: 2}, 2)]) var firstAfter = root.childNodes[1] - return firstBefore == firstAfter && root.childNodes[0].childNodes[0].nodeValue == 4 && root.childNodes.length == 3 + return firstBefore === firstAfter && root.childNodes[0].childNodes[0].nodeValue === "4" && root.childNodes.length === 3 }) test(function() { //https://github.com/lhorie/mithril.js/issues/98 @@ -1852,7 +1842,7 @@ function testMithril(mock) { var firstBefore = root.childNodes[1] m.render(root, [m("a", {key: 2}, 2), m("a", {key: 3}, 3), m("a", {key: 4}, 4)]) var firstAfter = root.childNodes[0] - return firstBefore == firstAfter && root.childNodes[0].childNodes[0].nodeValue === "2" && root.childNodes.length === 3 + return firstBefore === firstAfter && root.childNodes[0].childNodes[0].nodeValue === "2" && root.childNodes.length === 3 }) test(function() { //https://github.com/lhorie/mithril.js/issues/98 @@ -1865,7 +1855,7 @@ function testMithril(mock) { var firstAfter = root.childNodes[2] var secondAfter = root.childNodes[3] var fourthAfter = root.childNodes[0] - return firstBefore === firstAfter && secondBefore === secondAfter && fourthBefore === fourthAfter && root.childNodes[1].childNodes[0].nodeValue == "10" && root.childNodes.length === 4 + return firstBefore === firstAfter && secondBefore === secondAfter && fourthBefore === fourthAfter && root.childNodes[1].childNodes[0].nodeValue === "10" && root.childNodes.length === 4 }) test(function() { //https://github.com/lhorie/mithril.js/issues/98 @@ -1878,7 +1868,7 @@ function testMithril(mock) { var firstAfter = root.childNodes[3] var secondAfter = root.childNodes[2] var fourthAfter = root.childNodes[0] - return firstBefore === firstAfter && secondBefore === secondAfter && fourthBefore === fourthAfter && root.childNodes[1].childNodes[0].nodeValue == "10" && root.childNodes[4].childNodes[0].nodeValue == "6" && root.childNodes[5].childNodes[0].nodeValue == "7" && root.childNodes.length === 6 + return firstBefore === firstAfter && secondBefore === secondAfter && fourthBefore === fourthAfter && root.childNodes[1].childNodes[0].nodeValue === "10" && root.childNodes[4].childNodes[0].nodeValue === "6" && root.childNodes[5].childNodes[0].nodeValue === "7" && root.childNodes.length === 6 }) test(function() { //https://github.com/lhorie/mithril.js/issues/149 @@ -1905,7 +1895,7 @@ function testMithril(mock) { var firstBefore = root.childNodes[0] m.render(root, [m("a", {key: 2}, 2), m("br"), m("a", {key: 1}, 1)]) var firstAfter = root.childNodes[2] - return firstBefore == firstAfter && root.childNodes[0].childNodes[0].nodeValue == 2 && root.childNodes.length == 3 + return firstBefore === firstAfter && root.childNodes[0].childNodes[0].nodeValue === "2" && root.childNodes.length === 3 }) test(function() { //https://github.com/lhorie/mithril.js/issues/134 @@ -1947,7 +1937,7 @@ function testMithril(mock) { } }) ]) - return unloaded == 0 + return unloaded === 0 }) test(function() { var root = mock.document.createElement("div") @@ -1963,7 +1953,6 @@ function testMithril(mock) { unloadedChild++ } } - var unloaded = 0 m.render(root, m("div", {config: configParent}, m("a", {config: configChild}))) m.render(root, m("main", {config: configParent}, m("a", {config: configChild}))) return unloadedParent === 1 && unloadedChild === 0 @@ -1982,7 +1971,6 @@ function testMithril(mock) { unloadedChild++ } } - var unloaded = 0 m.render(root, m("div", {config: configParent}, m("a", {config: configChild}))) m.render(root, m("main", {config: configParent}, m("b", {config: configChild}))) return unloadedParent === 1 && unloadedChild === 1 @@ -1992,7 +1980,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, [m("a"), m("div")]) m.render(root, [[], m("div")]) - return root.childNodes.length == 1 && root.childNodes[0].nodeName == "DIV" + return root.childNodes.length === 1 && root.childNodes[0].nodeName === "DIV" }) test(function() { //https://github.com/lhorie/mithril.js/issues/156 @@ -2003,35 +1991,35 @@ function testMithril(mock) { }), m("span") ])) - return root.childNodes[0].childNodes[8].nodeName == "SPAN" + return root.childNodes[0].childNodes[8].nodeName === "SPAN" }) test(function() { //https://github.com/lhorie/mithril.js/issues/157 var root = mock.document.createElement("div") m.render(root, m("ul", [m("li", {key: 0}, 0), m("li", {key: 2}, 2), m("li", {key: 4}, 4)])) m.render(root, m("ul", [m("li", {key: 0}, 0), m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), m("li", {key: 5}, 5)])) - return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join("") == "012345" + return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join("") === "012345" }) test(function() { //https://github.com/lhorie/mithril.js/issues/157 var root = mock.document.createElement("div") m.render(root, m("input", {value: "a"})) m.render(root, m("input", {value: "aa"})) - return root.childNodes[0].childNodes.length == 0 + return root.childNodes[0].childNodes.length === 0 }) test(function() { //https://github.com/lhorie/mithril.js/issues/157 var root = mock.document.createElement("div") m.render(root, m("br", {"class": "a"})) m.render(root, m("br", {"class": "aa"})) - return root.childNodes[0].childNodes.length == 0 + return root.childNodes[0].childNodes.length === 0 }) test(function() { //https://github.com/lhorie/mithril.js/issues/194 var root = mock.document.createElement("div") m.render(root, m("ul", [m("li", {key: 0}, 0), m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), m("li", {key: 5}, 5)])) m.render(root, m("ul", [m("li", {key: 0}, 0), m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 4}, 4), m("li", {key: 5}, 5)])) - return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join("") == "01245" + return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join("") === "01245" }) test(function() { //https://github.com/lhorie/mithril.js/issues/194 @@ -2039,21 +2027,21 @@ function testMithril(mock) { m.render(root, m("ul", [m("li", {key: 0}, 0), m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), m("li", {key: 5}, 5)])) m.render(root, m("ul", [m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), m("li", {key: 5}, 5), m("li", {key: 6}, 6)])) m.render(root, m("ul", [m("li", {key: 12}, 12), m("li", {key: 13}, 13), m("li", {key: 14}, 14), m("li", {key: 15}, 15), m("li", {key: 16}, 16), m("li", {key: 17}, 17)])) - return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join(",") == "12,13,14,15,16,17" + return root.childNodes[0].childNodes.map(function(n) {return n.childNodes[0].nodeValue}).join(",") === "12,13,14,15,16,17" }) test(function() { //https://github.com/lhorie/mithril.js/issues/206 var root = mock.document.createElement("div") m.render(root, m("div", undefined)) m.render(root, m("div", [m("div")])) - return root.childNodes[0].childNodes.length == 1 + return root.childNodes[0].childNodes.length === 1 }) test(function() { - //https://github.com/lhorie/mithril.js/issues/206 + // https://github.com/lhorie/mithril.js/issues/206 var root = mock.document.createElement("div") m.render(root, m("div", null)) m.render(root, m("div", [m("div")])) - return root.childNodes[0].childNodes.length == 1 + return root.childNodes[0].childNodes.length === 1 }) test(function() { //https://github.com/lhorie/mithril.js/issues/200 @@ -2083,7 +2071,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.render(root, [m("div.blue")]) m.render(root, [m("div.green", [m("div")]), m("div.blue")]) - return root.childNodes.length == 2 + return root.childNodes.length === 2 }) test(function() { //https://github.com/lhorie/mithril.js/issues/277 @@ -2094,12 +2082,12 @@ function testMithril(mock) { this.children = "hello"; } m.render(root, new Field()) - return root.childNodes.length == 1 + return root.childNodes.length === 1 }) test(function() { var root = mock.document.createElement("div") m.render(root, {foo: 123}) - return root.childNodes.length == 0 + return root.childNodes.length === 0 }) test(function() { //https://github.com/lhorie/mithril.js/issues/299 @@ -2107,18 +2095,18 @@ function testMithril(mock) { m.render(root, m("div", [m("div", {key: 1}, 1), m("div", {key: 2}, 2), m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key: 5}, 5), null, null, null, null, null, null, null, null, null, null])) m.render(root, m("div", [null, null, m("div", {key: 3}, 3), null, null, m("div", {key: 6}, 6), null, null, m("div", {key: 9}, 9), null, null, m("div", {key: 12}, 12), null, null, m("div", {key: 15}, 15)])) m.render(root, m("div", [m("div", {key: 1}, 1), m("div", {key: 2}, 2), m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key: 5}, 5), null, null, null, null, null, null, null, null, null, null])) - return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue: c.nodeValue}).slice(0, 5).join("") == "12345" + return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue : c.nodeValue}).slice(0, 5).join("") === "12345" }) test(function() { //https://github.com/lhorie/mithril.js/issues/377 var root = mock.document.createElement("div") m.render(root, m("div", [m("div", 1), m("div", 2), [m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key:5}, 5)], [m("div", {key: 6}, 6)]])) m.render(root, m("div", [m("div", 1), null, [m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key:5}, 5)], [m("div", {key: 6}, 6)]])) - return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue: c.nodeValue}).join("") == "13456" + return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue : c.nodeValue}).join("") === "13456" }) test(function() { var root = mock.document.createElement("div") - m.render(root, m("div", [console.log()])) //don't throw in Firefox + m.render(root, m("div", [console.log()])) // don't throw in Firefox return true }) test(function() { @@ -2134,18 +2122,18 @@ function testMithril(mock) { m("#div-3", {key: 3}), m("#div-2", {key: 2}) ]) - return root.childNodes.map(function(node) {return node.id}).join() == "div-1,div-3,div-2" + return root.childNodes.map(function(node) {return node.id}).join() === "div-1,div-3,div-2" }) test(function() { var root = mock.document.createElement("div") m.render(root, m("div", function() {})) - return root.childNodes[0].childNodes.length == 0 + return root.childNodes[0].childNodes.length === 0 }) test(function() { var root = mock.document.createElement("div") m.render(root, m("div", "foo", m("a"))) m.render(root, m("div", "test")) - return root.childNodes[0].childNodes.length == 1 + return root.childNodes[0].childNodes.length === 1 }) test(function() { //if an element is preceded by a conditional, it should not lose its identity @@ -2200,15 +2188,15 @@ function testMithril(mock) { }) test(function() { var root = mock.document.createElement("div") - var vdom = m("div.a", {class: undefined}) + var vdom = m("div.a", {"class": undefined}) m.render(root, vdom) - return root.childNodes[0].class == "a" + return root.childNodes[0]["class"] === "a" }) test(function() { var root = mock.document.createElement("div") m.render(root, m(".a", [1])) m.render(root, m(".a", [])) - return root.childNodes[0].childNodes.length == 0 + return root.childNodes[0].childNodes.length === 0 }) //end m.render @@ -2234,7 +2222,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.mount(root, { controller: function() {}, - view: function(ctrl) { + view: function() { count++ } }) @@ -2245,7 +2233,7 @@ function testMithril(mock) { m.redraw() m.redraw() mock.requestAnimationFrame.$resolve() //teardown - + return count === 3 }) test(function() { @@ -2254,7 +2242,7 @@ function testMithril(mock) { var root = mock.document.createElement("div") m.mount(root, { controller: function() {}, - view: function(ctrl) { + view: function() { count++ } }) @@ -2279,11 +2267,11 @@ function testMithril(mock) { "/test1": {controller: function() {}, view: function() {return "foo"}} }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test1" && root.childNodes[0].nodeValue === "foo" - + + var result = mock.location.search === "?/test1" && root.childNodes[0].nodeValue === "foo" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2304,11 +2292,11 @@ function testMithril(mock) { } }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.pathname == "/test2" && root.childNodes[0].nodeValue === "foo" && root.childNodes[1].href == "/test2" - + + var result = mock.location.pathname === "/test2" && root.childNodes[0].nodeValue === "foo" && root.childNodes[1].href === "/test2" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2321,11 +2309,11 @@ function testMithril(mock) { "/test3": {controller: function() {}, view: function() {return "foo"}} }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.hash == "#/test3" && root.childNodes[0].nodeValue === "foo" - + + var result = mock.location.hash === "#/test3" && root.childNodes[0].nodeValue === "foo" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2338,11 +2326,11 @@ function testMithril(mock) { "/test4/:test": {controller: function() {}, view: function() {return m.route.param("test")}} }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test4/foo" && root.childNodes[0].nodeValue === "foo" - + + var result = mock.location.search === "?/test4/foo" && root.childNodes[0].nodeValue === "foo" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2362,11 +2350,11 @@ function testMithril(mock) { m.route("/") var paramValueAfter = m.route.param("test") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/" && paramValueBefore === "foo" && paramValueAfter === undefined - + + var result = mock.location.search === "?/" && paramValueBefore === "foo" && paramValueAfter === undefined + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2386,11 +2374,11 @@ function testMithril(mock) { m.route("/") var paramValueAfter = m.route.param("a1") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/" && paramValueBefore === "foo" && paramValueAfter === undefined - + + var result = mock.location.search === "?/" && paramValueBefore === "foo" && paramValueAfter === undefined + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2411,11 +2399,11 @@ function testMithril(mock) { m.route("/") var routeValueAfter = m.route() mock.requestAnimationFrame.$resolve() - + var result = routeValueBefore === "/test7/foo" && routeValueAfter === "/" - + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2433,11 +2421,11 @@ function testMithril(mock) { } }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test8/foo/SEP/bar/baz" && root.childNodes[0].nodeValue === "foo_bar/baz" - + + var result = mock.location.search === "?/test8/foo/SEP/bar/baz" && root.childNodes[0].nodeValue === "foo_bar/baz" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2455,11 +2443,11 @@ function testMithril(mock) { } }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test9/foo/bar/SEP/baz" && root.childNodes[0].nodeValue === "foo/bar_baz" - + + var result = mock.location.search === "?/test9/foo/bar/SEP/baz" && root.childNodes[0].nodeValue === "foo/bar_baz" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2477,11 +2465,11 @@ function testMithril(mock) { } }) mock.requestAnimationFrame.$resolve() - + var result = root.childNodes[0].nodeValue === "foo bar" - + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2497,11 +2485,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test11/") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test11/" && root.childNodes[0].nodeValue === "bar" - + + var result = mock.location.search === "?/test11/" && root.childNodes[0].nodeValue === "bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2517,11 +2505,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test12?a=foo&b=bar") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test12?a=foo&b=bar" && m.route.param("a") == "foo" && m.route.param("b") == "bar" - + + var result = mock.location.search === "?/test12?a=foo&b=bar" && m.route.param("a") === "foo" && m.route.param("b") === "bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2537,11 +2525,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test13/foo?test=bar") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test13/foo?test=bar" && root.childNodes[0].nodeValue === "foo" - + + var result = mock.location.search === "?/test13/foo?test=bar" && root.childNodes[0].nodeValue === "foo" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2557,11 +2545,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test14?test&test2=") mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test14?test&test2=" && m.route.param("test") === null && m.route.param("test2") === "" - + + var result = mock.location.search === "?/test14?test&test2=" && m.route.param("test") == null && m.route.param("test2") === "" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2577,11 +2565,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test12", {a: "foo", b: "bar"}) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test12?a=foo&b=bar" && m.route.param("a") == "foo" && m.route.param("b") == "bar" - + + var result = mock.location.search === "?/test12?a=foo&b=bar" && m.route.param("a") === "foo" && m.route.param("b") === "bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2598,11 +2586,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test13") mock.requestAnimationFrame.$resolve() - - var result = route1 == "/" && route2 == "/test13" - + + var result = route1 === "/" && route2 === "/test13" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2630,11 +2618,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test14") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2670,11 +2658,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test15") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2707,11 +2695,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test16") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2746,11 +2734,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test17") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2783,11 +2771,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test18") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2832,17 +2820,17 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test20") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() //setup mock.location.search = "?" - + var root = mock.document.createElement("div") var unloaded = 0 m.route.mode = "search" @@ -2880,11 +2868,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route("/test21") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2905,18 +2893,18 @@ function testMithril(mock) { view: function() { return m("div", "bar"); } - }, + } }) mock.requestAnimationFrame.$resolve() var foo = root.childNodes[0].childNodes[0].nodeValue; m.route("/bar") mock.requestAnimationFrame.$resolve() var bar = root.childNodes[0].childNodes[0].nodeValue; - + var result = (foo === "foo" && bar === "bar") - + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2943,16 +2931,16 @@ function testMithril(mock) { view: function() { return m("main", m("a", {config: config}, "foo")); } - }, + } }) mock.requestAnimationFrame.$resolve() m.route("/bar1") mock.requestAnimationFrame.$resolve() - - var result = unloaded == 1 - + + var result = unloaded === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -2974,11 +2962,11 @@ function testMithril(mock) { } }) mock.requestAnimationFrame.$resolve() - - var result = strategy == "all" && root.childNodes.length == 0 - + + var result = strategy === "all" && root.childNodes.length === 0 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3004,16 +2992,16 @@ function testMithril(mock) { view: function() { return m("div", {config: config}); } - }, + } }) mock.requestAnimationFrame.$resolve() m.route("/bar1") mock.requestAnimationFrame.$resolve() - - var result = strategy == "all" && count == 1 - + + var result = strategy === "all" && count === 1 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3037,11 +3025,11 @@ function testMithril(mock) { }) root.childNodes[0].onclick({}) mock.requestAnimationFrame.$resolve() - - var result = strategy == "diff" && root.childNodes[0].childNodes[0].nodeValue == "1" - + + var result = strategy === "diff" && root.childNodes[0].childNodes[0].nodeValue === "1" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3055,7 +3043,7 @@ function testMithril(mock) { m.route(root, "/foo1", { "/foo1": { controller: function() {}, - view: function(ctrl) { + view: function() { return m("div", {config: config, onclick: function() { m.redraw.strategy("all") }}); @@ -3064,11 +3052,11 @@ function testMithril(mock) { }) root.childNodes[0].onclick({}) mock.requestAnimationFrame.$resolve() - - var result = count == 2 - + + var result = count === 2 + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3080,15 +3068,15 @@ function testMithril(mock) { m.route(root, "/foo+bar", { "/:arg": { controller: function() {value = m.route.param("arg")}, - view: function(ctrl) { + view: function() { return "" } } }) - var result = value == "foo+bar" - + var result = value === "foo+bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3104,11 +3092,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route(String("/test22/")) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test22/" && root.childNodes[0].nodeValue === "bar" - + + var result = mock.location.search === "?/test22/" && root.childNodes[0].nodeValue === "bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3124,11 +3112,11 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() m.route(new String("/test23/")) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/test23/" && root.childNodes[0].nodeValue === "bar" - + + var result = mock.location.search === "?/test23/" && root.childNodes[0].nodeValue === "bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3140,15 +3128,15 @@ function testMithril(mock) { m.route(root, String("/foo+bar"), { "/:arg": { controller: function() {value = m.route.param("arg")}, - view: function(ctrl) { + view: function() { return "" } } }) - var result = value == "foo+bar" - + var result = value === "foo+bar" + m.mount(root, null) //teardown - + return result }) test(function() { @@ -3160,69 +3148,69 @@ function testMithril(mock) { m.route(root, new String("/foo+bar"), { "/:arg": { controller: function() {value = m.route.param("arg")}, - view: function(ctrl) { + view: function() { return "" } } }) - var result = value == "foo+bar" - + var result = value === "foo+bar" + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") - + var a = {} a.controller = function() {m.route("/b")} a.view = function() {return "a"} var b = {} b.controller = function() {} - b.view = function(ctrl) {return "b"} + b.view = function() {return "b"} m.route(root, "/a", { "/a": a, "/b": b }) mock.requestAnimationFrame.$resolve() - - var result = root.childNodes[0].nodeValue == "b" - + + var result = root.childNodes[0].nodeValue === "b" + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") - + var a = {} a.controller = function() { m.route("/b?foo=1", {foo: 2}) } a.view = function() {return "a"} - + var b = {} b.controller = function() {} b.view = function() {return "b"} m.route(root, "/", { "/": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - - var result = mock.location.search == "?/b?foo=2" - + + var result = mock.location.search === "?/b?foo=2" + m.mount(root, null) //teardown - + return result }) @@ -3230,31 +3218,31 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() mock.location.search = "?" mock.history.$$length = 0 - + var root = mock.document.createElement("div") - + var a = {} a.controller = function() {} a.view = function() {return "a"} - + var b = {} b.controller = function() {} b.view = function() {return "b"} m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = mock.history.$$length == 1 - + + var result = mock.history.$$length === 1 + m.mount(root, null) //teardown - + return result }) @@ -3262,75 +3250,75 @@ function testMithril(mock) { mock.requestAnimationFrame.$resolve() mock.location.search = "?" mock.history.$$length = 0 - + var root = mock.document.createElement("div") - + var a = {} a.controller = function() {} a.view = function() {return "a"} - + var b = {} b.controller = function() {} b.view = function() {return "b"} m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/a") - + mock.requestAnimationFrame.$resolve() - - var result = mock.history.$$length == 0 - + + var result = mock.history.$$length === 0 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { - return m("a", {config: function(el, init, ctx) { + return m("a", {config: function(el, init) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { @@ -3339,34 +3327,34 @@ function testMithril(mock) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { @@ -3375,69 +3363,69 @@ function testMithril(mock) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { - return m("a", {config: function(el, init, ctx) { + return m("a", {config: function(el, init) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { @@ -3446,34 +3434,34 @@ function testMithril(mock) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { @@ -3482,34 +3470,34 @@ function testMithril(mock) { if (!init) initCount++ }}) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = a.view m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { @@ -3518,7 +3506,7 @@ function testMithril(mock) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {} b.view = function() { @@ -3530,27 +3518,27 @@ function testMithril(mock) { m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { @@ -3559,7 +3547,7 @@ function testMithril(mock) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {} b.view = function() { @@ -3571,66 +3559,66 @@ function testMithril(mock) { m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { - return m("div", m("a", {config: function(el, init, ctx) { + return m("div", m("a", {config: function(el, init) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {} b.view = function() { - return m("section", m("a", {config: function(el, init, ctx) { + return m("section", m("a", {config: function(el, init) { if (!init) initCount++ }})) } m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { @@ -3639,7 +3627,7 @@ function testMithril(mock) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = function() { @@ -3651,27 +3639,27 @@ function testMithril(mock) { m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { @@ -3680,7 +3668,7 @@ function testMithril(mock) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = function() { @@ -3692,67 +3680,67 @@ function testMithril(mock) { m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 2 - + + var result = initCount === 2 + m.mount(root, null) //teardown - + return result }) test(function() { mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {m.redraw.strategy("diff")} a.view = function() { - return m("div", m("a", {config: function(el, init, ctx) { + return m("div", m("a", {config: function(el, init) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = function() { - return m("section", m("a", {config: function(el, init, ctx) { + return m("section", m("a", {config: function(el, init) { if (!init) initCount++ }})) } m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - - var result = initCount == 1 - + + var result = initCount === 1 + m.mount(root, null) //teardown - + return result }) test(function() { //retain flag should work inside component mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") var initCount = 0 - + var a = {} a.controller = function() {} a.view = function() { @@ -3761,7 +3749,7 @@ function testMithril(mock) { if (!init) initCount++ }})) } - + var b = {} b.controller = function() {m.redraw.strategy("diff")} b.view = function() { @@ -3773,34 +3761,34 @@ function testMithril(mock) { m.route(root, "/a", { "/a": {view: function() {return m("div", a)}}, - "/b": {view: function() {return m("div", b)}}, + "/b": {view: function() {return m("div", b)}} }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() - var result = initCount == 1 + var result = initCount === 1 m.mount(root, null) //teardown - + return result }) test(function() { // https://github.com/lhorie/mithril.js/pull/571 mock.requestAnimationFrame.$resolve() mock.location.search = "?" - + var root = mock.document.createElement("div") - + var a = {} a.controller = function() {} a.view = function() { - return m("div", {config: function(elm, init, ctx) { + return m("div", {config: function(elm) { elm.childNodes[0].modified = true }}, m("div")) } - + var b = {} b.controller = function() {} b.view = function() { @@ -3809,17 +3797,17 @@ function testMithril(mock) { m.route(root, "/a", { "/a": a, - "/b": b, + "/b": b }) mock.requestAnimationFrame.$resolve() - + m.route("/b") - + mock.requestAnimationFrame.$resolve() var result = !root.childNodes[0].childNodes[0].modified; m.mount(root, null) //teardown - + return result }); //end m.route @@ -3831,16 +3819,16 @@ function testMithril(mock) { }) test(function() { var args = m.route.parseQueryString("foo=bar&hello=world&hello=mars&bam=&yup") - return args.foo === "bar" && args.hello[0] === "world" && args.hello[1] === "mars" && args.bam === "" && args.yup === null + return args.foo === "bar" && args.hello[0] === "world" && args.hello[1] === "mars" && args.bam === "" && args.yup == null }) - + //m.route.buildQueryString test(function() { var string = m.route.buildQueryString({ foo: "bar", hello: ["world", "mars", "mars"], world: { - test:3 + test: 3 }, bam: "", yup: null, @@ -3848,7 +3836,7 @@ function testMithril(mock) { }) return string === "foo=bar&hello=world&hello=mars&world%5Btest%5D=3&bam=&yup" }) - + //m.prop test(function() { var prop = m.prop("test") @@ -3895,7 +3883,7 @@ function testMithril(mock) { return prop().method === "GET" && prop().url === "test" }) test(function() { - var prop = m.request({method: "GET", url: "test"}).then(function(value) {return "foo"}) + var prop = m.request({method: "GET", url: "test"}).then(function() {return "foo"}) mock.XMLHttpRequest.$instances.pop().onreadystatechange() return prop() === "foo" }) @@ -3917,7 +3905,7 @@ function testMithril(mock) { }) test(function() { var error = m.prop("no error") - var prop = m.request({method: "GET", url: "test", deserialize: function() {throw new Error("error occurred")}}).catch(error) + var prop = m.request({method: "GET", url: "test", deserialize: function() {throw new Error("error occurred")}})["catch"](error) mock.XMLHttpRequest.$instances.pop().onreadystatechange() return prop().message === "error occurred" && error().message === "error occurred" }) @@ -3926,18 +3914,18 @@ function testMithril(mock) { var prop = m.request({method: "GET", url: "test", deserialize: function() {throw new TypeError("error occurred")}}).then(null, error) try {mock.XMLHttpRequest.$instances.pop().onreadystatechange()} catch (e) {exception = e} - return prop() === undefined && error() === "no error" && exception.message == "error occurred" + return prop() === undefined && error() === "no error" && exception.message === "error occurred" }) test(function() { var error = m.prop("no error") - var prop = m.request({method: "POST", url: "test", data: {foo: 1}}).then(null, error) + m.request({method: "POST", url: "test", data: {foo: 1}}).then(null, error) var xhr = mock.XMLHttpRequest.$instances.pop() xhr.onreadystatechange() - return xhr.$headers["Content-Type"] == "application/json; charset=utf-8" + return xhr.$headers["Content-Type"] === "application/json; charset=utf-8" }) test(function() { var error = m.prop("no error") - var prop = m.request({method: "POST", url: "test"}).then(null, error) + m.request({method: "POST", url: "test"}).then(null, error) var xhr = mock.XMLHttpRequest.$instances.pop() xhr.onreadystatechange() return xhr.$headers["Content-Type"] === undefined @@ -3957,7 +3945,7 @@ function testMithril(mock) { return initialValue === "foo" }) test(function() { - var prop = m.request({method: "POST", url: "test", initialValue: "foo"}).then(function(value) {return "bar"}) + var prop = m.request({method: "POST", url: "test", initialValue: "foo"}).then(function() {return "bar"}) mock.XMLHttpRequest.$instances.pop().onreadystatechange() return prop() === "bar" }) @@ -3997,7 +3985,7 @@ function testMithril(mock) { var error = m.prop("no error") var data - var req = m.request({url: "/test", dataType: "jsonp"}).then(function(received) {data = received}, error) + m.request({url: "/test", dataType: "jsonp"}).then(function(received) {data = received}, error) var callbackKey = Object.keys(mock).filter(function(globalKey){ return globalKey.indexOf("mithril_callback") > -1 }).pop() @@ -4006,7 +3994,7 @@ function testMithril(mock) { }).pop() mock[callbackKey]({foo: "bar"}) mock.document.removeChild(body) - return scriptTag.src.indexOf("/test?callback=mithril_callback") > -1 && data.foo == "bar" + return scriptTag.src.indexOf("/test?callback=mithril_callback") > -1 && data.foo === "bar" }) test(function(){ // script tags cannot be appended directly on the document @@ -4016,16 +4004,16 @@ function testMithril(mock) { var error = m.prop("no error") var data - var req = m.request({url: "/test", dataType: "jsonp", callbackKey: "jsonpCallback"}).then(function(received) {data = received}, error); + m.request({url: "/test", dataType: "jsonp", callbackKey: "jsonpCallback"}).then(function(received) {data = received}, error) var callbackKey = Object.keys(mock).filter(function(globalKey){ return globalKey.indexOf("mithril_callback") > -1 }).pop() var scriptTag = [].slice.call(mock.document.getElementsByTagName("script")).filter(function(script){ return script.src.indexOf(callbackKey) > -1 - }).pop() + }).pop(); mock[callbackKey]({foo: "bar1"}) mock.document.removeChild(body) - return scriptTag.src.indexOf("/test?jsonpCallback=mithril_callback") > -1 && data.foo == "bar1" + return scriptTag.src.indexOf("/test?jsonpCallback=mithril_callback") > -1 && data.foo === "bar1" }) test(function(){ var body = mock.document.createElement("body") @@ -4036,7 +4024,7 @@ function testMithril(mock) { var callbackKey = Object.keys(mock).filter(function(globalKey){ return globalKey.indexOf("mithril_callback") > -1 }).pop() - var scriptTag = [].slice.call(mock.document.getElementsByTagName("script")).filter(function(script){ + ;[].slice.call(mock.document.getElementsByTagName("script")).filter(function(script){ return script.src.indexOf(callbackKey) > -1 }).pop(); mock[callbackKey]({foo: "bar1"}) @@ -4049,7 +4037,7 @@ function testMithril(mock) { mock.document.body = body mock.document.appendChild(body) - var req = m.request({url: "/test", dataType: "jsonp", data: {foo: "bar"}}) + m.request({url: "/test", dataType: "jsonp", data: {foo: "bar"}}) var callbackKey = Object.keys(mock).filter(function(globalKey){ return globalKey.indexOf("mithril_callback") > -1 }).pop() @@ -4064,9 +4052,7 @@ function testMithril(mock) { mock.document.body = body; mock.document.appendChild(body); - var _window = mock; - var error = m.prop(false); - var req = m.request({url: "/test", dataType: "jsonp", method: "GET", data: {foo: "bar"}}); + m.request({url: "/test", dataType: "jsonp", method: "GET", data: {foo: "bar"}}); var callbackKey = Object.keys(mock).filter(function(globalKey){ return globalKey.indexOf("mithril_callback") > -1 }).pop() @@ -4075,7 +4061,7 @@ function testMithril(mock) { }).pop(); mock[callbackKey]({foo: "bar"}) mock.document.removeChild(body); - return scriptTag.src.match(/foo=bar/g).length == 1; + return scriptTag.src.match(/foo=bar/g).length === 1; }) //m.deferred @@ -4089,7 +4075,7 @@ function testMithril(mock) { test(function() { var value var deferred = m.deferred() - deferred.promise.then(function(data) {return "foo"}).then(function(data) {value = data}) + deferred.promise.then(function() {return "foo"}).then(function(data) {value = data}) deferred.resolve("test") return value === "foo" }) @@ -4103,28 +4089,28 @@ function testMithril(mock) { test(function() { var value var deferred = m.deferred() - deferred.promise.catch(function(data) {value = data}) + deferred.promise["catch"](function(data) {value = data}) deferred.reject("test") return value === "test" }) test(function() { var value var deferred = m.deferred() - deferred.promise.then(null, function(data) {return "foo"}).then(function(data) {value = data}) + deferred.promise.then(null, function() {return "foo"}).then(function(data) {value = data}) deferred.reject("test") return value === "foo" }) test(function() { var value var deferred = m.deferred() - deferred.promise.catch(function(data) {return "foo"}).then(function(data) {value = data}) + deferred.promise["catch"](function() {return "foo"}).then(function(data) {value = data}) deferred.reject("test") return value === "foo" }) test(function() { var value1, value2 var deferred = m.deferred() - deferred.promise.then(function(data) {throw new Error}).then(function(data) {value1 = 1}, function(data) {value2 = data}) + deferred.promise.then(function() {throw new Error()}).then(function() {value1 = 1}, function(data) {value2 = data}) deferred.resolve("test") return value1 === undefined && value2 instanceof Error }) @@ -4139,8 +4125,8 @@ function testMithril(mock) { var deferred = m.deferred() try { deferred.promise - .then(function(data) {foo.bar.baz}) //throws ReferenceError - .then(function(data) {value1 = 1}, function(data) {value2 = data}) + .then(function() {foo.bar.baz}) //throws ReferenceError + .then(function() {value1 = 1}, function(data) {value2 = data}) deferred.resolve("test") } catch (e) {value3 = e} @@ -4213,7 +4199,7 @@ function testMithril(mock) { test(function() { //https://github.com/lhorie/mithril.js/issues/80 var deferred = m.deferred(), value1, value2 - deferred.promise.then(function() { + deferred.promise.then(function(data) { value1 = data }, function(data) { value2 = data @@ -4236,7 +4222,7 @@ function testMithril(mock) { //https://github.com/lhorie/mithril.js/issues/85 var deferred = m.deferred(), value deferred.resolve() - deferred.promise.then(function(data) { + deferred.promise.then(function() { value = 1 }) return value === 1 @@ -4245,24 +4231,24 @@ function testMithril(mock) { //https://github.com/lhorie/mithril.js/issues/85 var deferred = m.deferred(), value deferred.reject() - deferred.promise.then(null, function(data) { + deferred.promise.then(null, function() { value = 1 }) return value === 1 }) test(function() { - var deferred = m.deferred(), value + var deferred = m.deferred() deferred.resolve(1) return deferred.promise() === 1 }) test(function() { - var deferred = m.deferred(), value + var deferred = m.deferred() var promise = deferred.promise.then(function(data) {return data + 1}) deferred.resolve(1) return promise() === 2 }) test(function() { - var deferred = m.deferred(), value + var deferred = m.deferred() deferred.reject(1) return deferred.promise() === undefined }) @@ -4289,14 +4275,14 @@ function testMithril(mock) { test(function() { var value var deferred = m.deferred() - m.sync([deferred.promise]).catch(function(data) {value = data}) + m.sync([deferred.promise])["catch"](function(data) {value = data}) deferred.reject("fail") return value[0] === "fail" }) test(function() { var value = 1 m.sync([]).then(function() {value = 2}) - return value == 2 + return value === 2 }) test(function() { var success diff --git a/tests/mock.js b/tests/mock.js index 30c8712c..fb97f6d5 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -55,11 +55,11 @@ mock.window = (function() { else this.childNodes.splice(referenceIndex, 0, node) }, insertAdjacentHTML: function(position, html) { - //todo: accept markup - if (position == "beforebegin") { + // todo: accept markup + if (position === "beforebegin") { this.parentNode.insertBefore(window.document.createTextNode(html), this) } - else if (position == "beforeend") { + else if (position === "beforeend") { this.appendChild(window.document.createTextNode(html)) } }, @@ -104,7 +104,8 @@ mock.window = (function() { this.childNodes.splice(index, 1) child.parentNode = null } - //getElementsByTagName is only used by JSONP tests, it's not required by Mithril + // getElementsByTagName is only used by JSONP tests, it's not required by + // Mithril window.document.getElementsByTagName = function(name){ name = name.toLowerCase(); var out = []; @@ -112,12 +113,13 @@ mock.window = (function() { var traverse = function(node){ if(node.childNodes && node.childNodes.length > 0){ node.childNodes.map(function(curr){ - if(curr.nodeName.toLowerCase() === name) + if (curr.nodeName.toLowerCase() === name) { out.push(curr); + } traverse(curr); }); } - }; + } traverse(window.document); return out; @@ -156,15 +158,15 @@ mock.window = (function() { request.$instances = [] return request }()) - window.location = {search: "", pathname: "", hash: ""}, + window.location = {search: "", pathname: "", hash: ""} window.history = {} window.history.$$length = 0 window.history.pushState = function(data, title, url) { window.history.$$length++ window.location.pathname = window.location.search = window.location.hash = url - }, + } window.history.replaceState = function(data, title, url) { window.location.pathname = window.location.search = window.location.hash = url } return window -}()) \ No newline at end of file +}())