diff --git a/.eslintrc b/.eslintrc index f77243f3..3417ee64 100644 --- a/.eslintrc +++ b/.eslintrc @@ -53,6 +53,7 @@ "block-spacing": 2, "brace-style": [2, "1tbs", {"allowSingleLine": true}], "camelcase": 2, + "comma-dangle": [2, "always-multiline"], "comma-spacing": 2, "comma-style": 2, "consistent-this": [2, "self"], diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..e4864595 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,856 @@ +# Bug reports + +Use the [issue tracker](https://github.com/lhorie/mithril.js/issues). Do check to make sure your bug hasn't already been filed. Please give the following information, where possible: + +1. The version of Mithril you're using, whether it's the dev version or [the version on npm](http://npm.im/mithril.js). The version on npm may not have all the latest bug fixes, so your bug might very well be fixed in the dev version. +2. A detailed explanation of the bug. +3. A test case. The simpler, the better. + +# Feature requests + +Use the [issue tracker](https://github.com/lhorie/mithril.js/issues). Please do the following, where possible: + +1. Check to make sure your suggestion hasn't already been filed. There's a nice collection of some of these feature requests [here](https://github.com/lhorie/mithril.js/issues/802). +2. Clearly denote your issue as a feature request. It helps make the intent clearer. Even better is to denote it in the title. +3. Describe your idea. This is the most important part. +4. Submit, and wait for feedback. Don't forget to drop by the [Gitter room](https://gitter.im/lhorie/mithril.js) to get some publicity. It gets traffic daily. :smile: + +# Contributing + +We welcome any and all contributions. This is a community-driven project. Although we don't have a lot, we do have a few guidelines for contributions. + +1. Please adhere to the style guide. It's pretty lengthy, but most everything is checked by ESLint, and if anything fails to check, the build will fail, and you will know about it. Most of it is common practice and common sense. ESLint is also set up to check for other common errors, such as undeclared variables and invalid `typeof` values. +2. Please make sure there are no regressions with your patch. Please don't disable existing tests, and please don't send a PR with new, disabled tests. + - There are a few known failing tests currently (PRs welcome): [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.deferred.js#L121-L125) [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.render.js#L1321-L1343) [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.route.js#L106-L131) [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.route.js#L134-L162) [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.route.js#L165-L191) [*](https://github.com/lhorie/mithril.js/blob/next/test/mithril.route.js#L194-L222) +3. For any new features introduced, be sure to write new unit tests for it. Maximum coverage is what we want. +4. Try to not leave any extra `TODO`s, `FIXME`s, etc. in your code. ESLint will nag at you until you fix whatever problem it is. + - Note that it's only a warning, not an error. It won't fail the CI tests, and there's a few outstanding ones inside Mithril right now. + +It is assumed that all contributions you make you have the appropriate rights to and that it may be made available under the MIT License, the license used for this project. + +# Style Guide + +The style is checked with ESLint. This style guide is here for one reason only: consistency. This should work for most code here, but this shouldn't be considered absolute &endash; consistency with the surrounding code is higher priority than following this guide. Also, if some sort of hack is impossible without violating this guide (e.g. if Mithril ever needs [Bluebird's infamous hack](https://stackoverflow.com/q/24987896)), just make sure the code is consistent with what's around it. + +### Line length + +Keep lines down to a maximum of 80 characters. Minifiers are very good at compressing whitespace, so don't be afraid to use it. + +The only exception to this rule is with long regexes. Append `// eslint-disable-line max-len` to the end of those lines. + +### Function length + +Keep function length to no more than 20 statements, including those in nested blocks. + +The only exceptions are for revealing module wrappers and Mocha `describe` and `context` blocks. + +This isn't checked for the tests, but still, keep it reasonable. + +### Line endings + +Use Windows-style line endings (i.e. CRLF). + +End each file with a line break. + +### Semicolons + +Avoid semicolons. (A few resources to help you understand this: [*](http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding) [*](http://inimino.org/~inimino/blog/javascript_semicolons) [*](http://jamesallardice.com/understanding-automatic-semi-colon-insertion-in-javascript/)) + +### Redundant expressions + +Don't use redundant parentheses, curly braces, `undefined`s, labels, ternaries, etc. Examples: + +- `var foo = value === 1 ? true : false` is better written as `var foo = value === 1`. +- `var foo = (value === 1) ? bar : baz` is better written as `var foo = value === 1 ? bar : baz`. +- `var foo = undefined` is better written as `var foo`. +- `return undefined` is better written as `return`. +- `delete(obj.foo)` is better written as `delete obj.foo`. +- `return` at the end of a function if you're returning `undefined` should just be omitted. +- If you're returning `null`, there's usually little reason to not just return `undefined`. +- Unused variables should be removed. +- An exception is detailed below for assignment in conditions. + +### Equality testing + +Use strict equality (`===`/`!==`), not loose equality (`==`/`!=`). The only exception is if you're testing for `null` or `undefined`, in which loose equality, `value == null` and `value != null` is preferred. The reason is for type safety with primitives. + +### `eval` and friends + +Never use `eval`, the `Function` constructor, and friends. Those will fail when running under CSP restrictions, and this library should work in those environments. + +### Quotes + +Prefer double quotes to single quotes, but using single quotes to avoid escaping is okay. + +### Strict mode + +All code must be in strict mode, preferably wrapped in an IIFE. + +## Comments + +Comments are helpful. Use descriptive comments where needed, so others can read it and understand it. If a non-obvious hack is used, explain it with a comment. But don't repeat yourself with a redundant comment when the code adequately describes itself. + +```js +// Good, code is self-descriptive +var CARD_DECK_SIZE = 52 + +// Shuffle the deck of cards. +for (var i = 0; i < CARD_DECK_SIZE; i++) { + var j = i + (Math.random() * CARD_DECK_SIZE - i)|0 + + var tmp = deck[i] + deck[i] = deck[j] + deck[j] = tmp +} + +// Also good, requires a descriptive comment. +function toFastProperties(obj) { + // Bluebird's toFastProperties hack. Forces V8 to optimize object as prototype, + // significantly speeding up property access. + + /* eslint-disable no-eval */ + function C() {} + C.prototype = obj + new C() + return + eval(obj) + /* eslint-enable no-eval */ +} + +// Bad, redundant comments +var CARD_DECK_SIZE = 52 + +// Shuffle the deck of cards. +function shuffle(deck) { + for (var i = 0; i < CARD_DECK_SIZE; i++) { + // Generate a random card index to swap at. + var j = i + (Math.random() * CARD_DECK_SIZE - i)|0 + + // Swap the cards at each index. + var tmp = deck[i] + deck[i] = deck[j] + deck[j] = tmp + } +} +``` + +### Magic values + +Prefer constant variables to magic values where it helps with code readability. Also, don't use comments in place of a constant. + +```js +// Good +var CARD_DECK_SIZE = 52 +for (var i = 0; i < CARD_DECK_SIZE; i++) { + var j = i + (Math.random() * CARD_DECK_SIZE - i)|0 + var tmp = a[i] + a[i] = a[j] + a[j] = tmp +} + +// Bad, what's 52 for? +for (var i = 0; i < 52; i++) { + var j = i + (Math.random() * 52 - i)|0 + var tmp = a[i] + a[i] = a[j] + a[j] = tmp +} + +// Also bad, comment not substitute for constant +// 52 cards in a deck +for (var i = 0; i < 52; i++) { + var j = i + (Math.random() * 52 - i)|0 + var tmp = a[i] + a[i] = a[j] + a[j] = tmp +} +``` + +### Distracting comments + +Don't comment *everything*. It's distracting, pointless, and a waste of time. Only comment when you need to. + +```js +// Extremely bad. Don't *ever* do this. + +// This function loops through each item in a list, calling `f` with each item +// and their respective index. If the function `f` returns explicitly with +// `false`, iteration stops. This function returns the original list for +// convenience. +function forEach(list, f) { + // Loop through each entry in the list with the loop index `i` + for (var i = 0; i < list.length; i++) { + // Call the function with the current item and index + if (f(list[i], i) === false) { + // If the function explicitly returns `false`, immediately stop + // iteration. + break + } + } + // Return the list, for convenience. + return list +} +``` + +### Initial whitespace + +Start your comments with a space. It's more readable. + +```js +// Good +// This is a comment. + +// Bad +//This is a comment. +``` + +### Grammar and spelling + +Use proper grammar and spelling in your comments. This shouldn't need explanation. + +## Whitespace + +Use vertical whitespace and indentation to your advantage. It helps with readability, and minifiers are astonishingly great at removing this. :stuck_out_tongue_winking_eye: + +```js +// Good +function iterate() { + var index = 0 + var list = [] + while (hasNext()) { + list.push(next(index)) + index++ + } + + for (var i = 0; i < list.length; i++) { + read(list[i]) + } +} + +// Bad +function iterate() { + var index = 0 + var list = [] + while (hasNext()) list.push(next(index++)) + for (var i = 0; i < list.length; i++) read(list[i]) +} + +// Even worse +function iterate() { + var list = [] + for (var index = 0; hasNext(); list.push(next(index++))) {} + for (var i = 0; i < list.length; i++) read(list[i]) +} +``` + +### Trailing whitespace + +Please don't leave trailing spaces anywhere. It makes diffs harder to read. + +### Indentation and vertical whitespace + +Indent with hard tabs. Each one counts for 4 spaces. + +Never mix tabs and spaces. Don't use smart tabs. + +### Excessive whitespace + +Keep whitespace within reason. Limit vertical whitespace to no more than 2 consecutive blank lines, and don't start or end blocks with plain whitespace. Don't use more than one character of horizontal whitespace beyond indentation. + +```js +// Bad +function iterate() { + var index = 0 + var list = [] + + while (hasNext()) { + list.push(next(index)) + index++ + } + + // Too many empty lines + + + + for (var i = 0; i < list.length; i++) { + read(list[i]) + } +} + +// Also bad +var a = 2 +// ^^ ^^ +``` + +### Control keywords + +Always surround control keywords (e.g. `if`, `else`, `for`) with whitespace. + +## Operators + +### Binary operators + +Always surround binary keyword operators (e.g. `in`, `instanceof`) with whitespace. + +Always surround any other binary operator with whitespace, including assignment operators. Add line breaks after the operator, not before. + +```js +// Good +var a = 1 + 2 +a = 3 +a += 4 + +var a = 1 + 2 + 3 + 4 + 5 + + 6 + 7 + 8 + 9 + 10 + +// Bad +var a = 1+2 +var a = 1 +2 +var a = 1+ 2 +var a=1+2 +var a=1 + 2 +a=3 +a+=4 + +var a = 1 + 2 + 3 + 4 + 5 + + 6 + 7 + 8 + 9 + 10 +``` + +As an exception, casting to a 32-bit integer (i.e. `x|0`) doesn't require whitespace surrounding it. + +```js +// This is okay +var casted = value|0 +``` + +### Unary operators + +Always use whitespace between an unary keyword operator (e.g. `delete`, `new`) with whitespace. + +Do not use spaces between any other unary operator and the value they apply to. + +```js +// Good +!a +!!a +~~a +a++ +++a +-1 +~1 + +// Okay ++!a + +// Bad +! a +!! a +! ! a +++ a +a ++ ++ ! a + +// Even worse +- 1 +~ 1 +``` + +Don't use `new function () {}`. Just use an object literal instead, and an IIFE if needed. + +## Objects + +### Exterior whitespace + +Do not include space between the opening curly brace and the first object key in single line objects. For multi-line objects, don't include any extra preceding whitespace at the beginning or end. + +```js +// Good +var object = {foo: 1} + +var object = { + foo: 1, + bar: 2, + baz: 3, + quux: "string", +} + +// Bad +var object = { foo: 1 } + +var object = { + + foo: 1, + bar: 2, + baz: 3, + quux: "string", + +} +``` + +### Interior whitespace + +Use no space before an object key and the colon, but use a single space between the colon and value. + +```js +// Good +var object = {foo: 1} + +// Bad +var object = {foo:1} +var object = {foo : 1} + +// Very bad +var object = {foo :1} +``` + +### Larger objects + +Non-trivial objects should occupy multiple lines. + +```js +// Good +var object = { + foo: 1, + bar: 2, + baz: 3, + quux: "string", +} + +// Bad +var object = {foo: 1, bar: 2, baz: 3, quux: "string"} +``` + +### Comma placement + +Commas come last. Also, use trailing commas if the object takes multiple lines. + +```js +// Good +var object = { + foo: 1, + bar: 2, +} + +// Bad +var object = { + foo: 1, + bar: 2 // No trailing comma +} + +var object = { + foo: 1 +, bar: 2 // Comma first +} + +// Trailing comma in single-line object +var object = {foo: 1,} +``` + +### Member access + +When chaining methods and/or properties across multiple lines, dots come first. + +```js +// Good +object + .foo() + .bar() + +// Bad +object. + foo(). + bar() +``` + +### Property quoting + +Quote properties when needed. Never quote valid identifiers. This may lead to some inconsistency in whether properties are quoted or not in the object, but that inconsistency is okay, and is the only exception in consistency. + +```js +// Good +var object = { + foo: 1, + bar: 2, +} + +var object = { + foo: 1, + "non-identifier": 2, +} + +// Bad +var object = { + "foo": 1, + "bar": 2, +} + +var object = { + "foo": 1, + "non-identifier": 2, +} +``` + +### Iteration + +When iterating objects with `for-in`, filter it with `Object.prototype.hasOwnProperty` first. This may be on the same line if that's the only condition. If this is used more than once, make a local `hasOwn` alias to use like `hasOwn.call(object, prop)`. + +## Variables and declarations + +Use camel case (e.g. `loopIndex`) for variables, pascal case (e.g. `MyClass`) for classes, and upper case with underscores (e.g. `MAX_VALUE`) for constants. + +Use `self` to capture `this` where needed. (i.e. `var self = this`) + +Prefer short but clear, descriptive, and self-documenting variable names. + +Single letter names are only okay in these contexts: + +- Loop variables: `i`, `j`, etc. +- Function arguments in small, trivial functional utilities: `f`, `g`, etc. +- Standard mathematical algorithms: `x`, `y`, `a`, `b`, etc. + +```js +// Good +function forEach(list, f) { + for (var i = 0; i < list.length; i++) { + f(list[i], i) + } + return list +} + +function ajax(url, callback) { + var xhr = new XMLHttpRequest() + xhr.open("GET", url) + xhr.onreadystatechange = function () { + if (this.readyState === 4) { + callback(this.responseText, this.status) + } + } + xhr.send() +} + +// Bad +function iterateArray(listOfEntries, callback) { + for (var index = 0; index < listOfEntries.length; index++) { + callback(listOfEntries[index], index) + } + return listOfEntries +} + +function getRequestStringFromServer(serverLocation, functionToCall) { + var xmlHttpRequest = new XMLHttpRequest() + xmlHttpRequest.open("GET", serverLocation) + xmlHttpRequest.onreadystatechange = function () { + if (this.readyState === 4) { + functionToCall(this.responseText, this.status) + } + } + xmlHttpRequest.send() +} + +// Even worse +function e(l, c) { + for (var x = 0; x < l.length; x++) { + c(l[x], x) + } + return l +} + +function a(u, f) { + var x = new XMLHttpRequest() + x.open("GET", url) + x.onreadystatechange = function () { + if (this.readyState === 4) { + f(this.responseText,this.status) + } + } + x.send() +} +``` + +### Multiple variable declarations + +If a variable is assigned a value when it's declared, it gets its own line. + +If a variable is not immediately assigned a value, it may be grouped with others that aren't first assigned values. + +Do group related variables. + +Variable declarations in the init block of a for loop are excluded from this rule, but the number of declarations should still be minimized. + +```js +// Good +var a = 1 +var b = 2 +var c, d + +// Also good +var foo, bar, baz, quux +var spam, eggs, ham +var shouldUpdate, initialize + +// Okay, since it's within a for loop +for (var i = 0, test; (test = foo === 1); i++) { + doSomething(i) +} + +// Bad +var a = 1, b = 2, c, d + +// Even worse +var foo, bar, baz, quux, spam, eggs, ham, shouldUpdate, initialize +``` + +## Assignment + +### Native functions + +Don't assign to native functions or prototypes beyond polyfills. Ever. + +### Function declarations + +Don't assign to a function declaration. Declarations look like static values, so they should be treated that way. There is no difference in size, either. + +```js +// Bad +function foo() { return 1 } +foo = function () { return 2 } + +// Even worse +function foo() { return 1 } +foo = 2 +``` + +### Conditions + +Avoid assigning directly in conditions. If you need to assign in a condition, wrap them in a new set of parentheses. + +```js +// Good +var test = foo === 1 +if (test) { + doSomething() +} + +var test = foo === 1 +for (var i = 0; test; i++, test = foo === 1) { + doSomething(i) +} + +if ((test = foo === 1)) { + doSomething() +} + +for (var i = 0, test; (test = foo === 1); i++) { + doSomething(i) +} + +// Bad +if (test = foo === 1) { + doSomething() +} + +for (var i = 0, test; test = foo === 1; i++) { + doSomething(i) +} +``` + +## Functions + +Prefer anonymous functions to named functions in expressions where possible + +Prefer named function declarations to assigning a function to a declared variable where possible. + +```js +// Good +setTimeout(function () { doSomething() }, 0) + +function foo() { + return 1 +} + +// Good, uses recursion +setTimeout(function f() { + doSomething() + if (shouldRepeat()) setTimeout(f, 0) +}, 0) + +// Bad +requestAnimationFrame(function foo() { runNext() }) + +var foo = function () { + return 1 +} +``` + +### Anonymous functions + +Anonymous functions must have a single space between `function` and the arguments and between the arguments and the opening brace. + +### Named functions, function declarations + +Named functions and function declarations must have no space between the function name and the arguments and a single space between the arguments and the opening brace. + +## Blocks and conditionals + +### Curly braces + +Curly braces are required for blocks if the body takes up more than one line. This goes for functions as well. They are optional if it fits within one line, but don't be afraid to use them where you see fit. + +Do put an extra space after the first brace and before the final brace in single-line functions. + +```js +// Good +if (condition) doSomething() + +if (condition) { + doSomething() +} + +if (condition) { + doSomething() +} else { + doSomethingElse() +} + +if (condition) { + doSomething() + doSomethingElse() +} + +setTimeout(function () { doSomething() }, 0) + +setTimeout(function () { + doSomething() +}, 0) + +// Bad +if (condition) { doSomething(); doSomethingElse() } + +if (condition) + doSomething() + +setTimeout(function () { doSomething(); doSomethingElse() }, 0) + +setTimeout(function () {doSomething()}, 0) // Body needs some space +``` + +### Function declarations + +Function declarations should always take more than one line. + +```js +// Good +function foo() { + return bar +} + +// Bad +function foo() { return bar } +``` + +### `if`-`else` + +Be consistent with braces in `if`-`else` statements. + +```js +// Good +if (condition) doSomething() +else doSomethingElse() + +if (condition) { + doSomething() +} else { + doSomethingElse() +} + +if (condition) { + doSomething() +} else if (anotherCondition) { + doSomethingElse() +} else { + doAnotherThing() +} + +// Okay +if (condition) doSomething() +else if (anotherCondition) doSomethingElse() +else doAnotherThing() + +// Bad +if (condition) doSomething() +else { + doSomethingElse() +} + +if (condition) doSomething() +else if (anotherCondition) { + doSomethingElse() +} else doAnotherThing() + + +if (condition) { + doSomething() +} else doSomethingElse() +``` + +### Empty blocks + +Mark empty blocks as intentionally empty via a comment or similar. Don't just leave an empty block and/or semicolon. + +```js +// Good +for (var i = 0; i < list.length && cond(list[i]); i++) { + // empty +} + +// Bad +for (var i = 0; i < list.length && cond(list[i]); i++) {} + +// Also bad +for (var i = 0; i < list.length && cond(list[i]); i++) { + ; +} + +// Even worse +for (var i = 0; i < list.length && cond(list[i]); i++); +``` + +### Nesting + +Don't nest `if` statements in `else` blocks if you don't need to. + +```js +// Good +if (test) { + doSomething() +} else if (otherTest) { + doSomethingElse() +} + +if (test) { + doSomething() +} else { + if (otherTest) { + doSomethingElse() + } + + doThisOtherThing() +} + +// Bad +if (test) { + doSomething() +} else { + if (otherTest) { + doSomethingElse() + } +} +``` + +Don't nest curly braces beyond 4 levels deep. This includes blocks, loops, and functions, as well as IIFE wrappers. This also includes the tests. There's rarely a reason to go farther, as most of the time, it's a signal to refactor and/or re-organize your code. + +### Brace style + +Put the `else`, `catch`, and `finally` on the same line as its closing brace. + +(Obviously, this doesn't apply to `if`-`else` statements that don't use curly braces.) diff --git a/Gruntfile.js b/Gruntfile.js index a22e6198..5e933cb2 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,7 +21,7 @@ module.exports = function (grunt) { // eslint-disable-line "refactoring", "routing", "tools", - "web-services" + "web-services", ] var api = [ @@ -42,7 +42,7 @@ module.exports = function (grunt) { // eslint-disable-line "mithril.sync", "mithril.trust", "mithril.withAttr", - "mithril.xhr" + "mithril.xhr", ] var md2htmlTasks = {} @@ -59,12 +59,12 @@ module.exports = function (grunt) { // eslint-disable-line md2htmlTasks[name] = { options: { layout: inputFolder + "/layout/" + layout + ".html", - templateData: {topic: title} + templateData: {topic: title}, }, files: [{ src: [src], - dest: tempFolder + "/" + name + ".html" - }] + dest: tempFolder + "/" + name + ".html", + }], } }) } @@ -79,7 +79,7 @@ module.exports = function (grunt) { // eslint-disable-line eslint: { options: { extensions: [".js"], - fix: true + fix: true, }, all: [ "**/*.js", @@ -88,17 +88,17 @@ module.exports = function (grunt) { // eslint-disable-line "!archive/**", "!deploy/**", "!mithril.closure-compiler-externs.js", - "!docs/layout/lib/**" - ] + "!docs/layout/lib/**", + ], }, mocha_phantomjs: { // eslint-disable-line camelcase test: { src: ["test/index.html"], options: { - reporter: "dot" - } - } + reporter: "dot", + }, + }, }, md2html: md2htmlTasks, @@ -111,11 +111,11 @@ module.exports = function (grunt) { // eslint-disable-line "http://github.com/lhorie/mithril.js", "(c) Leo Horie", "License: MIT", - "*/" + "*/", ].join("\n"), - sourceMap: true + sourceMap: true, }, - mithril: {src: "mithril.js", dest: "mithril.min.js"} + mithril: {src: "mithril.js", dest: "mithril.min.js"}, }, zip: { @@ -124,10 +124,10 @@ module.exports = function (grunt) { // eslint-disable-line src: [ currentVersionArchiveFolder + "/mithril.min.js", currentVersionArchiveFolder + "/mithril.min.js.map", - currentVersionArchiveFolder + "/mithril.js" + currentVersionArchiveFolder + "/mithril.js", ], - dest: currentVersionArchiveFolder + "/mithril.min.zip" - } + dest: currentVersionArchiveFolder + "/mithril.min.zip", + }, }, replace: { @@ -135,105 +135,105 @@ module.exports = function (grunt) { // eslint-disable-line force: true, patterns: [ {match: /\.md/g, replacement: ".html"}, - {match: /\$version/g, replacement: version} - ] + {match: /\$version/g, replacement: version}, + ], }, links: { expand: true, flatten: true, src: [tempFolder + "/**/*.html"], - dest: currentVersionArchiveFolder + "/" + dest: currentVersionArchiveFolder + "/", }, index: { src: inputFolder + "/layout/index.html", - dest: currentVersionArchiveFolder + "/index.html" + dest: currentVersionArchiveFolder + "/index.html", }, commonjs: { expand: true, flatten: true, src: [inputFolder + "/layout/*.json"], - dest: currentVersionArchiveFolder + dest: currentVersionArchiveFolder, }, cdnjs: { src: "deploy/cdnjs-package.json", - dest: "../cdnjs/ajax/libs/mithril/package.json" - } + dest: "../cdnjs/ajax/libs/mithril/package.json", + }, }, copy: { style: { src: inputFolder + "/layout/style.css", - dest: currentVersionArchiveFolder + "/style.css" + dest: currentVersionArchiveFolder + "/style.css", }, pages: { src: inputFolder + "/layout/pages.json", - dest: currentVersionArchiveFolder + "/pages.json" + dest: currentVersionArchiveFolder + "/pages.json", }, lib: { expand: true, cwd: inputFolder + "/layout/lib/", src: "./**", - dest: currentVersionArchiveFolder + "/lib/" + dest: currentVersionArchiveFolder + "/lib/", }, tools: { expand: true, cwd: inputFolder + "/layout/tools/", src: "./**", - dest: currentVersionArchiveFolder + "/tools/" + dest: currentVersionArchiveFolder + "/tools/", }, comparisons: { expand: true, cwd: inputFolder + "/layout/comparisons/", src: "./**", - dest: currentVersionArchiveFolder + "/comparisons/" + dest: currentVersionArchiveFolder + "/comparisons/", }, unminified: { src: "mithril.js", - dest: currentVersionArchiveFolder + "/mithril.js" + dest: currentVersionArchiveFolder + "/mithril.js", }, minified: { src: "mithril.min.js", - dest: currentVersionArchiveFolder + "/mithril.min.js" + dest: currentVersionArchiveFolder + "/mithril.min.js", }, readme: { src: "README.md", - dest: currentVersionArchiveFolder + "/README.md" + dest: currentVersionArchiveFolder + "/README.md", }, map: { src: "mithril.min.js.map", - dest: currentVersionArchiveFolder + "/mithril.min.js.map" + dest: currentVersionArchiveFolder + "/mithril.min.js.map", }, typescript: { src: "mithril.d.ts", - dest: currentVersionArchiveFolder + "/mithril.d.ts" + dest: currentVersionArchiveFolder + "/mithril.d.ts", }, publish: { expand: true, cwd: currentVersionArchiveFolder, src: "./**", - dest: outputFolder + dest: outputFolder, }, archive: { expand: true, cwd: currentVersionArchiveFolder, src: "./**", - dest: outputFolder + "/archive/v" + version - } + dest: outputFolder + "/archive/v" + version, + }, }, "saucelabs-browsers": { @@ -245,7 +245,7 @@ module.exports = function (grunt) { // eslint-disable-line return version === "dev" || version === "beta" || +version >= 38 // The latest ESR version }) - } + }, }, chrome: { @@ -256,7 +256,7 @@ module.exports = function (grunt) { // eslint-disable-line return version === "dev" || version === "beta" || +version >= 41 }) - } + }, }, ie: { @@ -265,7 +265,7 @@ module.exports = function (grunt) { // eslint-disable-line return browser.browserName === "internet explorer" && !/2003/.test(browser.platform) }) - } + }, }, edge: { @@ -273,7 +273,7 @@ module.exports = function (grunt) { // eslint-disable-line return browsers.filter(function (browser) { return browser.browserName === "microsoftedge" }) - } + }, }, safari: { @@ -281,7 +281,7 @@ module.exports = function (grunt) { // eslint-disable-line return browsers.filter(function (browser) { return browser.browserName === "safari" }) - } + }, }, opera: { @@ -289,8 +289,8 @@ module.exports = function (grunt) { // eslint-disable-line return browsers.filter(function (browser) { return browser.browserName === "opera" }) - } - } + }, + }, }, saucelabs: { @@ -303,7 +303,7 @@ module.exports = function (grunt) { // eslint-disable-line urls: ["http://localhost:8000/test/index.html"], sauceConfig: { "record-video": false, - "record-screenshots": false + "record-screenshots": false, }, build: process.env.TRAVIS_JOB_ID, onTestComplete: function (result, callback) { @@ -312,13 +312,13 @@ module.exports = function (grunt) { // eslint-disable-line var url = [ "https://saucelabs.com/rest/v1", user, "jobs", - result.job_id + result.job_id, ].join("/") require("request").put({ url: url, auth: {user: user, pass: pass}, - json: {passed: result.passed} + json: {passed: result.passed}, }, function (error, response) { if (error) { return callback(error) @@ -331,24 +331,24 @@ module.exports = function (grunt) { // eslint-disable-line } }) }, - tunnelTimeout: 5 - } - } + tunnelTimeout: 5, + }, + }, }, connect: { server: { options: { port: 8888, - base: "." - } - } + base: ".", + }, + }, }, clean: { options: {force: true}, - generated: [tempFolder] - } + generated: [tempFolder], + }, }) grunt.loadNpmTasks("grunt-saucelabs-browsers") @@ -370,7 +370,7 @@ module.exports = function (grunt) { // eslint-disable-line "md2html", "replace", "copy", - "clean" + "clean", ]) grunt.registerTask("test", ["eslint:all", "mocha_phantomjs"]) @@ -379,6 +379,6 @@ module.exports = function (grunt) { // eslint-disable-line grunt.registerTask("sauce", [ "saucelabs-browsers:all", "connect", - "saucelabs" + "saucelabs", ]) } diff --git a/docs/layout/tools/template-converter.js b/docs/layout/tools/template-converter.js index 55217ba3..34323507 100644 --- a/docs/layout/tools/template-converter.js +++ b/docs/layout/tools/template-converter.js @@ -14,7 +14,7 @@ window.templateConverter = (function () { return [ new DOMParser() .parseFromString(markup, "text/html") - .childNodes[1] + .childNodes[1], ] } @@ -39,7 +39,7 @@ window.templateConverter = (function () { list.push({ tag: el.nodeName.toLowerCase(), attrs: attrs, - children: createVirtual(el.childNodes) + children: createVirtual(el.childNodes), }) } }) @@ -115,7 +115,7 @@ window.templateConverter = (function () { var body = this.virtuals.join("," + tab) return "[" + tab + body + tab.slice(0, -1) + "]" } - } + }, } return { @@ -134,12 +134,12 @@ window.templateConverter = (function () { m("textarea", { autofocus: true, style: {width: "100%", height: "40%"}, - onchange: m.withAttr("value", ctrl.source) + onchange: m.withAttr("value", ctrl.source), }, ctrl.source()), m("button", {onclick: ctrl.convert}, "Convert"), m("textarea", {style: {width: "100%", height: "40%"}}, - ctrl.output()) + ctrl.output()), ]) - } + }, } })() diff --git a/mithril.js b/mithril.js index 864565f4..7f1cba65 100644 --- a/mithril.js +++ b/mithril.js @@ -231,7 +231,7 @@ index: i, from: existing[key].index, element: cached.nodes[existing[key].index] || - $document.createElement("div") + $document.createElement("div"), } } else { existing[key] = {action: INSERTION, index: i} @@ -263,7 +263,7 @@ insertNode(parent, dummy, index) newCached.splice(index, 0, { attrs: {key: data[index].attrs.key}, - nodes: [dummy] + nodes: [dummy], }) newCached.nodes[index] = dummy break @@ -691,7 +691,7 @@ tag: data.tag, attrs: attrs, children: children, - nodes: [node] + nodes: [node], } unloadCachedControllers(cached, views, controllers) @@ -729,7 +729,7 @@ if (controller.onunload != null) { unloaders.push({ controller: controller, - handler: controller.onunload + handler: controller.onunload, }) } @@ -1130,7 +1130,7 @@ this.appendChild(node) }, - childNodes: [] + childNodes: [], } var nodeCache = [] @@ -1293,7 +1293,7 @@ preventDefault: function () { isPrevented = true computePreRedrawHook = computePostRedrawHook = null - } + }, } forEach(unloaders, function (unloader) { @@ -1431,7 +1431,7 @@ var modes = { pathname: "", hash: "#", - search: "?" + search: "?", } var redirect = noop @@ -1948,8 +1948,8 @@ options.onload({ type: "load", target: { - responseText: resp - } + responseText: resp, + }, }) window[callbackKey] = undefined @@ -1962,8 +1962,8 @@ type: "error", target: { status: 500, - responseText: '{"error": "Error making jsonp request"}' - } + responseText: '{"error": "Error making jsonp request"}', + }, }) window[callbackKey] = undefined diff --git a/test-deps/mock.js b/test-deps/mock.js index 239af53c..21a0bc9c 100644 --- a/test-deps/mock.js +++ b/test-deps/mock.js @@ -49,7 +49,7 @@ this.mock = (function (global) { // the browser. Still waiting on mocha-phantomjs to update to be // compatible with PhantomJS 2.x. phantom: global.window && global.window.navigator && - /PhantomJS/.test(global.window.navigator.userAgent) + /PhantomJS/.test(global.window.navigator.userAgent), } var document = window.document = { @@ -102,7 +102,7 @@ this.mock = (function (global) { }, addEventListener: function () {}, - removeEventListener: function () {} + removeEventListener: function () {}, } }, @@ -156,7 +156,7 @@ this.mock = (function (global) { traverse(document) return out - } + }, } document.documentElement = document.createElement("html") @@ -182,7 +182,7 @@ this.mock = (function (global) { indices[id] = callbacks.length callbacks.push({ callback: callback, - id: id + id: id, }) return id } @@ -258,7 +258,7 @@ this.mock = (function (global) { replaceState: function (data, title, url) { location.pathname = location.search = location.hash = url - } + }, } return window diff --git a/test/input-cursor.html b/test/input-cursor.html index 8ee57964..71ee843e 100644 --- a/test/input-cursor.html +++ b/test/input-cursor.html @@ -20,13 +20,13 @@ function test(sel) { return m("li", [ m("p", m("code", "m(" + JSON.stringify(sel) + ")")), - m.apply(null, arguments) + m.apply(null, arguments), ]) } m.module(document.getElementById("test"), { controller: function() { - this.title = m.prop("hello world"); + this.title = m.prop("hello world") }, view: function (ctrl) { @@ -35,18 +35,18 @@ m.module(document.getElementById("test"), { m("ul", [ test("input[list=data]", { onkeyup: m.withAttr("value", ctrl.title), - value: ctrl.title() + value: ctrl.title(), }), test("datalist#data", [ m("option", "John"), m("option", "Bob"), - m("option", "Mary") + m("option", "Mary"), ]), test("textarea", { onkeyup: m.withAttr("value", ctrl.title), - value: ctrl.title() + value: ctrl.title(), }), m("li", [ @@ -63,11 +63,11 @@ m.module(document.getElementById("test"), { m("code", "m(\"div[contenteditable]\")")), m("div[contenteditable]", { style: {border: "1px solid #888"}, - onkeyup: m.withAttr("innerHTML", ctrl.title) + onkeyup: m.withAttr("innerHTML", ctrl.title), }, m.trust(ctrl.title())), - ]) - ]) - ]); - } -}); + ]), + ]), + ]) + }, +}) diff --git a/test/mithril.js b/test/mithril.js index bf86f972..37b618d6 100644 --- a/test/mithril.js +++ b/test/mithril.js @@ -202,7 +202,7 @@ describe("m()", function () { controller: spy, view: function () { return m("div", "testing") - } + }, } var args = {age: 12} diff --git a/test/mithril.mount.js b/test/mithril.mount.js index f76de2eb..a5ae6e61 100644 --- a/test/mithril.mount.js +++ b/test/mithril.mount.js @@ -22,7 +22,7 @@ describe("m.mount()", function () { function pure(view) { return { controller: function () {}, - view: view + view: view, } } @@ -38,7 +38,7 @@ describe("m.mount()", function () { return [ whatever % 2 ? m("span", "% 2") : undefined, m("div", "bugs"), - m("a") + m("a"), ] }) @@ -64,7 +64,7 @@ describe("m.mount()", function () { var mod1 = m.mount(root1, { controller: controller1, - view: view1 + view: view1, }) var controller2 = sinon.spy(function () { this.value = "test2" }) // eslint-disable-line @@ -73,7 +73,7 @@ describe("m.mount()", function () { var mod2 = mount(root2, { controller: controller2, - view: view2 + view: view2, }) expect(controller1).to.have.been.called @@ -97,7 +97,7 @@ describe("m.mount()", function () { controller: function () { this.onunload = spy }, - view: function () {} + view: function () {}, }) clear(root) @@ -114,7 +114,7 @@ describe("m.mount()", function () { var component = { controller: ctrlSpy, - view: viewSpy + view: viewSpy, } var arg = {} @@ -148,7 +148,7 @@ describe("m.mount()", function () { var sub = { controller: ctrlSpy, - view: viewSpy + view: viewSpy, } mount(root, pure(function () { return sub })) @@ -168,7 +168,7 @@ describe("m.mount()", function () { var subsub = { controller: ctrl1, - view: view1 + view: view1, } var ctrl2 = sinon.spy() @@ -176,7 +176,7 @@ describe("m.mount()", function () { var sub = { controller: ctrl2, - view: view2 + view: view2, } mount(root, pure(function () { return sub })) @@ -326,7 +326,7 @@ describe("m.mount()", function () { }, view: function () { return m("div") - } + }, } mount(root, pure(function () { @@ -358,7 +358,7 @@ describe("m.mount()", function () { }, view: function () { return m("div") - } + }, } var sub = { @@ -367,7 +367,7 @@ describe("m.mount()", function () { }, view: function (ctrl, opts) { return m.component(subsub, {key: opts.key}) - } + }, } mount(root, pure(function () { @@ -400,7 +400,7 @@ describe("m.mount()", function () { controller: function () { m.redraw() }, - view: spy + view: spy, } mount(root, pure(function () { return sub })) @@ -418,7 +418,7 @@ describe("m.mount()", function () { controller: function () { m.redraw() }, - view: spy + view: spy, } var sub = pure(function () { return subsub }) @@ -439,14 +439,14 @@ describe("m.mount()", function () { var CommentList = pure(function (ctrl, props) { return m(".list", props.list.map(function (i) { return m(".comment", [ - m.component(Reply, {key: i}) + m.component(Reply, {key: i}), ]) })) }) mount(root, pure(function () { return m(".outer", [ - m(".inner", m.component(CommentList, {list: [1, 2, 3]})) + m(".inner", m.component(CommentList, {list: [1, 2, 3]})), ]) })) @@ -461,7 +461,7 @@ describe("m.mount()", function () { controller: function () { this.onunload = spy }, - view: function () {} + view: function () {}, }) m.mount(root, pure(function () {})) @@ -480,7 +480,7 @@ describe("m.mount()", function () { return m("div", { config: function (el, init) { if (init) count += 1 - } + }, }) })) @@ -506,9 +506,9 @@ describe("m.mount()", function () { m(".foo", { key: 1, config: test, - onclick: function () { show = !show } + onclick: function () { show = !show }, }), - show ? m(".bar", {key: 2}) : null + show ? m(".bar", {key: 2}) : null, ] })) @@ -530,9 +530,9 @@ describe("m.mount()", function () { mount(root, pure(function () { return show ? [ m("h1", "1"), - sub + sub, ] : [ - m("h1", "2") + m("h1", "2"), ] })) @@ -561,10 +561,10 @@ describe("m.mount()", function () { a = !a m.redraw(true) found = root.childNodes[0].childNodes[1] - } + }, }, "asd"), a ? m("#a", "aaa") : null, - "test" + "test", ]) }) @@ -573,7 +573,7 @@ describe("m.mount()", function () { config: function (el, init, ctx) { if (!init) ctx.onunload = onunload - } + }, } m.mount(root, pure(function () { return Comp })) @@ -603,10 +603,10 @@ describe("m.mount()", function () { m.redraw(true) found = root.childNodes[0].childNodes[1] m.redraw.strategy("none") - } + }, }, "asd"), a ? m("#a", "aaa") : null, - "test" + "test", ]) }) @@ -615,7 +615,7 @@ describe("m.mount()", function () { config: function (el, init, ctx) { if (!init) ctx.onunload = onunload - } + }, } m.mount(root, pure(function () { return Comp })) @@ -635,7 +635,7 @@ describe("m.mount()", function () { var root = mock.document.createElement("div") var view = sinon.stub().returns(m("div", { - onclick: function () { m.redraw(true) } + onclick: function () { m.redraw(true) }, })) m.mount(root, pure(view)) @@ -667,7 +667,7 @@ describe("m.mount()", function () { this.foo = m.request({method: "GET", url: "/foo"}) }, - view: view + view: view, } mount(root, pure(function () { return Comp })) @@ -692,20 +692,20 @@ describe("m.mount()", function () { controller: function () { this.foo = m.request({method: "GET", url: "/foo"}) }, - view: view1 + view: view1, } var Comp2 = { controller: function () { this.bar = m.request({method: "GET", url: "/bar"}) }, - view: view2 + view: view2, } mount(root, pure(function () { return m("div", [ Comp1, - Comp2 + Comp2, ]) })) @@ -752,7 +752,7 @@ describe("m.mount()", function () { return m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } + }, }) }) @@ -795,9 +795,9 @@ describe("m.mount()", function () { ctrl.bar = true m.redraw(true) el = root.childNodes[0].childNodes[1] - } + }, }, "click me"), - ctrl.bar ? m.component(sub) : "" + ctrl.bar ? m.component(sub) : "", ]) })) diff --git a/test/mithril.redraw.js b/test/mithril.redraw.js index ada5b196..a6efe643 100644 --- a/test/mithril.redraw.js +++ b/test/mithril.redraw.js @@ -15,7 +15,7 @@ describe("m.redraw()", function () { m.mount(root, { controller: function () { ctx = this }, // eslint-disable-line - view: function (ctrl) { return ctrl.value } + view: function (ctrl) { return ctrl.value }, }) mock.requestAnimationFrame.$resolve() @@ -38,7 +38,7 @@ describe("m.redraw()", function () { m.mount(root, { controller: function () {}, - view: view + view: view, }) mock.requestAnimationFrame.$resolve() // teardown m.redraw() @@ -57,7 +57,7 @@ describe("m.redraw()", function () { var view = sinon.spy() m.mount(root, { controller: function () {}, - view: view + view: view, }) mock.requestAnimationFrame.$resolve() // teardown m.redraw(true) @@ -88,7 +88,7 @@ describe("m.redraw()", function () { function pure(view) { return { controller: noop, - view: view + view: view, } } @@ -138,8 +138,8 @@ describe("m.redraw()", function () { }, view: function () { return m("div") - } - } + }, + }, }) expect(strategy).to.equal("all") @@ -164,8 +164,8 @@ describe("m.redraw()", function () { }, view: function () { return m("div", {config: config}) - } - } + }, + }, }) route("/bar1") @@ -185,10 +185,10 @@ describe("m.redraw()", function () { strategy = m.redraw.strategy() ctrl.number++ m.redraw.strategy("none") - } + }, }, ctrl.number) - } - } + }, + }, }) root.childNodes[0].onclick({}) mock.requestAnimationFrame.$resolve() @@ -211,9 +211,9 @@ describe("m.redraw()", function () { config: config, onclick: function () { m.redraw.strategy("all") - } + }, }) - }) + }), }) root.childNodes[0].onclick({}) mock.requestAnimationFrame.$resolve() diff --git a/test/mithril.render.js b/test/mithril.render.js index 34faa178..7b00ccc3 100644 --- a/test/mithril.render.js +++ b/test/mithril.render.js @@ -62,7 +62,7 @@ describe("m.render()", function () { m.render(root, m("svg", [m("g")])) expect(root.childNodes[0].childNodes[0]).to.contain.all.keys({ nodeName: "G", - namespaceURI: "http://www.w3.org/2000/svg" + namespaceURI: "http://www.w3.org/2000/svg", }) }) @@ -237,7 +237,7 @@ describe("m.render()", function () { m.render(root, m("#foo", [ [m("div", "a"), m("div", "b")], [m("div", "c"), m("div", "d")], - m("#bar") + m("#bar"), ])) expect(root.childNodes[0].childNodes[3].childNodes[0].nodeValue) @@ -269,7 +269,7 @@ describe("m.render()", function () { ["a", "b", "c", "d"].map(function () { return [m("div"), " "] }), - m("span") + m("span"), ])) expect(root.childNodes[0].childNodes[8].nodeName).to.equal("SPAN") }) @@ -282,7 +282,7 @@ describe("m.render()", function () { m.render(root, m("#foo", [ [m("div", "a"), m("div", "b"), m("div", "c")], - m("#bar") + m("#bar"), ])) expect(root.childNodes[0].childNodes[2].childNodes[0].nodeValue) @@ -295,12 +295,12 @@ describe("m.render()", function () { m.render(root, m("main", [ m("button"), - m("article", [m("section"), m("nav")]) + m("article", [m("section"), m("nav")]), ])) m.render(root, m("main", [ m("button"), - m("article", [m("span"), m("nav")]) + m("article", [m("span"), m("nav")]), ])) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeName) @@ -313,12 +313,12 @@ describe("m.render()", function () { m.render(root, m("main", [ m("button"), - m("article", [m("section"), m("nav")]) + m("article", [m("section"), m("nav")]), ])) m.render(root, m("main", [ m("button"), - m("article", ["test", m("nav")]) + m("article", ["test", m("nav")]), ])) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue) @@ -331,12 +331,12 @@ describe("m.render()", function () { m.render(root, m("main", [ m("button"), - m("article", [m("section"), m("nav")]) + m("article", [m("section"), m("nav")]), ])) m.render(root, m("main", [ m("button"), - m("article", [m.trust("test"), m("nav")]) + m("article", [m.trust("test"), m("nav")]), ])) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue) @@ -550,7 +550,7 @@ describe("m.render()", function () { var config = sinon.spy() m.render(root, m("div", { - config: function (el, init, ctx) { ctx.data = 1 } + config: function (el, init, ctx) { ctx.data = 1 }, })) m.render(root, m("div", {config: config})) @@ -564,7 +564,7 @@ describe("m.render()", function () { var index = 0 var node = m("div", { - config: function (el, init, ctx) { ctx.data = index++ } + config: function (el, init, ctx) { ctx.data = index++ }, }) m.render(root, [node, node]) @@ -604,7 +604,7 @@ describe("m.render()", function () { m.render(root, m("div", [ ["foo", "bar"], ["foo", "bar"], - ["foo", "bar"] + ["foo", "bar"], ])) m.render(root, m("div", ["asdf", "asdf2", "asdf3"])) @@ -619,7 +619,7 @@ describe("m.render()", function () { m.render(root, [ m("a", {key: 1}, 1), m("a", {key: 2}, 2), - m("a", {key: 3}, 3) + m("a", {key: 3}, 3), ]) var firstBefore = root.childNodes[0] @@ -628,7 +628,7 @@ describe("m.render()", function () { m("a", {key: 4}, 4), m("a", {key: 1}, 1), m("a", {key: 2}, 2), - m("a", {key: 3}, 3) + m("a", {key: 3}, 3), ]) var firstAfter = root.childNodes[1] @@ -648,7 +648,7 @@ describe("m.render()", function () { m.render(root, [ m("a", {key: 1}, 1), m("a", {key: 2}, 2), - m("a", {key: 3}, 3) + m("a", {key: 3}, 3), ]) var firstBefore = root.childNodes[0] @@ -656,7 +656,7 @@ describe("m.render()", function () { m.render(root, [ m("a", {key: 4}, 4), m("a", {key: 1}, 1), - m("a", {key: 2}, 2) + m("a", {key: 2}, 2), ]) var firstAfter = root.childNodes[1] @@ -676,7 +676,7 @@ describe("m.render()", function () { m.render(root, [ m("a", {key: 1}, 1), m("a", {key: 2}, 2), - m("a", {key: 3}, 3) + m("a", {key: 3}, 3), ]) var firstBefore = root.childNodes[1] @@ -684,7 +684,7 @@ describe("m.render()", function () { m.render(root, [ m("a", {key: 2}, 2), m("a", {key: 3}, 3), - m("a", {key: 4}, 4) + m("a", {key: 4}, 4), ]) var firstAfter = root.childNodes[0] @@ -706,7 +706,7 @@ describe("m.render()", function () { m("a", {key: 2}, 2), m("a", {key: 3}, 3), m("a", {key: 4}, 4), - m("a", {key: 5}, 5) + m("a", {key: 5}, 5), ]) var firstBefore = root.childNodes[0] @@ -717,7 +717,7 @@ describe("m.render()", function () { m("a", {key: 4}, 4), m("a", {key: 10}, 10), m("a", {key: 1}, 1), - m("a", {key: 2}, 2) + m("a", {key: 2}, 2), ]) var firstAfter = root.childNodes[2] @@ -740,7 +740,7 @@ describe("m.render()", function () { m("a", {key: 2}, 2), m("a", {key: 3}, 3), m("a", {key: 4}, 4), - m("a", {key: 5}, 5) + m("a", {key: 5}, 5), ]) var firstBefore = root.childNodes[0] @@ -753,7 +753,7 @@ describe("m.render()", function () { m("a", {key: 2}, 2), m("a", {key: 1}, 1), m("a", {key: 6}, 6), - m("a", {key: 7}, 7) + m("a", {key: 7}, 7), ]) var firstAfter = root.childNodes[3] @@ -780,7 +780,7 @@ describe("m.render()", function () { m("a", {key: 2}), m("a"), m("a", {key: 4}), - m("a", {key: 5}) + m("a", {key: 5}), ]) var firstBefore = root.childNodes[0] @@ -794,7 +794,7 @@ describe("m.render()", function () { m("a", {key: 5}), m("a"), m("a", {key: 1}), - m("a", {key: 2}) + m("a", {key: 2}), ]) var firstAfter = root.childNodes[3] @@ -848,8 +848,8 @@ describe("m.render()", function () { key: 1, config: function (el, init, ctx) { ctx.onunload = spy - } - }) + }, + }), ]) m.render(root, [ m("div", {key: 2}), @@ -857,8 +857,8 @@ describe("m.render()", function () { key: 1, config: function (el, init, ctx) { ctx.onunload = spy - } - }) + }, + }), ]) expect(spy).to.not.have.been.called }) @@ -918,7 +918,7 @@ describe("m.render()", function () { m.render(root, m("ul", [ m("li", {key: 0}, 0), m("li", {key: 2}, 2), - m("li", {key: 4}, 4) + m("li", {key: 4}, 4), ])) m.render(root, m("ul", [ @@ -927,7 +927,7 @@ describe("m.render()", function () { m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), - m("li", {key: 5}, 5) + m("li", {key: 5}, 5), ])) expect( @@ -963,7 +963,7 @@ describe("m.render()", function () { m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), - m("li", {key: 5}, 5) + m("li", {key: 5}, 5), ])) m.render(root, m("ul", [ @@ -971,7 +971,7 @@ describe("m.render()", function () { m("li", {key: 1}, 1), m("li", {key: 2}, 2), m("li", {key: 4}, 4), - m("li", {key: 5}, 5) + m("li", {key: 5}, 5), ])) expect( @@ -991,7 +991,7 @@ describe("m.render()", function () { m("li", {key: 2}, 2), m("li", {key: 3}, 3), m("li", {key: 4}, 4), - m("li", {key: 5}, 5) + m("li", {key: 5}, 5), ])) m.render(root, m("ul", [ @@ -1000,7 +1000,7 @@ describe("m.render()", function () { m("li", {key: 3}, 3), m("li", {key: 4}, 4), m("li", {key: 5}, 5), - m("li", {key: 6}, 6) + m("li", {key: 6}, 6), ])) m.render(root, m("ul", [ @@ -1009,7 +1009,7 @@ describe("m.render()", function () { m("li", {key: 14}, 14), m("li", {key: 15}, 15), m("li", {key: 16}, 16), - m("li", {key: 17}, 17) + m("li", {key: 17}, 17), ])) expect( @@ -1045,7 +1045,7 @@ describe("m.render()", function () { m.render(root, [m("div", { config: function (el, init, ctx) { ctx.onunload = onunload1 - } + }, })]) m.render(root, []) @@ -1053,7 +1053,7 @@ describe("m.render()", function () { m.render(root, [m("div", { config: function (el, init, ctx) { ctx.onunload = onunload2 - } + }, })]) m.render(root, []) @@ -1069,7 +1069,7 @@ describe("m.render()", function () { m.render(root, [ m("div.green", [m("div")]), - m("div.blue") + m("div.blue"), ]) expect(root.childNodes).to.have.length(2) @@ -1103,7 +1103,7 @@ describe("m.render()", function () { 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 + null, null, null, null, null, null, null, null, null, null, ])) m.render(root, m("div", [ @@ -1116,7 +1116,7 @@ describe("m.render()", function () { null, null, m("div", {key: 12}, 12), null, null, - m("div", {key: 15}, 15) + m("div", {key: 15}, 15), ])) m.render(root, m("div", [ @@ -1125,7 +1125,7 @@ describe("m.render()", function () { 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 + null, null, null, null, null, null, null, null, null, null, ])) expect( @@ -1146,9 +1146,9 @@ describe("m.render()", function () { [ m("div", {key: 3}, 3), m("div", {key: 4}, 4), - m("div", {key: 5}, 5) + m("div", {key: 5}, 5), ], - [m("div", {key: 6}, 6)] + [m("div", {key: 6}, 6)], ])) m.render(root, m("div", [ @@ -1157,9 +1157,9 @@ describe("m.render()", function () { [ m("div", {key: 3}, 3), m("div", {key: 4}, 4), - m("div", {key: 5}, 5) + m("div", {key: 5}, 5), ], - [m("div", {key: 6}, 6)] + [m("div", {key: 6}, 6)], ])) expect( @@ -1184,7 +1184,7 @@ describe("m.render()", function () { m.render(root, [ m("#div-1", {key: 1}), m("#div-2", {key: 2}), - m("#div-3", {key: 3}) + m("#div-3", {key: 3}), ]) root.appendChild(root.childNodes[1]) @@ -1192,7 +1192,7 @@ describe("m.render()", function () { m.render(root, [ m("#div-1", {key: 1}), m("#div-3", {key: 3}), - m("#div-2", {key: 2}) + m("#div-2", {key: 2}), ]) expect( @@ -1229,7 +1229,7 @@ describe("m.render()", function () { m("a", {key: 1}), m("a", {key: 2}), m("a", {key: 3}), - m("i") + m("i"), ])) var before = root.childNodes[0].childNodes[3] @@ -1237,7 +1237,7 @@ describe("m.render()", function () { m("b", {key: 3}), m("b", {key: 4}), m("i"), - m("b", {key: 1}) + m("b", {key: 1}), ])) var after = root.childNodes[0].childNodes[2] @@ -1252,7 +1252,7 @@ describe("m.render()", function () { m("a", {key: 2}), "foo", m("a", {key: 3}), - m("i") + m("i"), ])) var before = root.childNodes[0].childNodes[4] @@ -1261,7 +1261,7 @@ describe("m.render()", function () { m("a", {key: 4}), "bar", m("i"), - m("a", {key: 1}) + m("a", {key: 1}), ])) var after = root.childNodes[0].childNodes[3] @@ -1276,7 +1276,7 @@ describe("m.render()", function () { m("a", {key: 2}), null, m("a", {key: 3}), - m("i") + m("i"), ])) var before = root.childNodes[0].childNodes[4] @@ -1285,7 +1285,7 @@ describe("m.render()", function () { m("a", {key: 4}), null, m("i"), - m("a", {key: 1}) + m("a", {key: 1}), ])) var after = root.childNodes[0].childNodes[3] @@ -1300,7 +1300,7 @@ describe("m.render()", function () { m("a", {key: 2}), undefined, m("a", {key: 3}), - m("i") + m("i"), ])) var before = root.childNodes[0].childNodes[4] @@ -1309,7 +1309,7 @@ describe("m.render()", function () { m("a", {key: 4}), undefined, m("i"), - m("a", {key: 1}) + m("a", {key: 1}), ])) var after = root.childNodes[0].childNodes[3] @@ -1326,7 +1326,7 @@ describe("m.render()", function () { m("a", {key: 2}), m.trust("a"), m("a", {key: 3}), - m("i") + m("i"), ])) var before = root.childNodes[0].childNodes[4] @@ -1335,7 +1335,7 @@ describe("m.render()", function () { m("a", {key: 4}), m.trust("a"), m("i"), - m("a", {key: 1}) + m("a", {key: 1}), ])) var after = root.childNodes[0].childNodes[3] @@ -1361,7 +1361,7 @@ describe("m.render()", function () { m.render(root, m("div", {}, [ m("div", {}, "0"), m("div", {}, "1"), - m("div", {}, "2") + m("div", {}, "2"), ])) expect( @@ -1371,7 +1371,7 @@ describe("m.render()", function () { ).to.eql(["0", "1", "2"]) m.render(root, m("div", {}, [ - m("div", {}, "0") + m("div", {}, "0"), ])) expect( @@ -1386,7 +1386,7 @@ describe("m.render()", function () { m.render(root, m("span", {}, [ m("div", {}, "0"), m("div", {}, "1"), - m("div", {}, "2") + m("div", {}, "2"), ])) expect( @@ -1396,7 +1396,7 @@ describe("m.render()", function () { ).to.eql(["0", "1", "2"]) m.render(root, m("span", {}, [ - m("div", {}, "0") + m("div", {}, "0"), ])) expect( @@ -1421,9 +1421,9 @@ describe("m.render()", function () { view: function (ctrl) { return m("input", { value: ctrl.inputValue(), - onkeyup: m.withAttr("value", ctrl.inputValue) + onkeyup: m.withAttr("value", ctrl.inputValue), }) - } + }, }) mock.requestAnimationFrame.$resolve() @@ -1467,11 +1467,11 @@ describe("m.render()", function () { return m("form", {onsubmit: ctrl.submit}, [ m("input", { onkeyup: m.withAttr("value", ctrl.inputValue), - value: ctrl.inputValue() + value: ctrl.inputValue(), }), - m("button[type=submit]") + m("button[type=submit]"), ]) - } + }, }) var form = root.childNodes[0] @@ -1512,7 +1512,7 @@ describe("m.render()", function () { view: function (ctrl) { return m("select", { size: ctrl.values.length, - multiple: "multiple" + multiple: "multiple", }, [ ctrl.values.map(function (v) { var opts = {value: v} @@ -1520,9 +1520,9 @@ describe("m.render()", function () { opts.selected = "selected" } return m("option", opts, v) - }) + }), ]) - } + }, }) mock.requestAnimationFrame.$resolve() diff --git a/test/mithril.request.js b/test/mithril.request.js index fd8ab1f4..e2409959 100644 --- a/test/mithril.request.js +++ b/test/mithril.request.js @@ -21,12 +21,12 @@ describe("m.request()", function () { it("sets the correct properties on `GET`", function () { var prop = request({ method: "GET", - url: "test" + url: "test", }) expect(prop()).to.contain.keys({ method: "GET", - url: "test" + url: "test", }) }) @@ -49,12 +49,12 @@ describe("m.request()", function () { var prop = request({ method: "POST", url: "http://domain.com:80", - data: {} + data: {}, }) expect(prop()).to.contain.keys({ method: "POST", - url: "http://domain.com:80" + url: "http://domain.com:80", }) }) @@ -62,7 +62,7 @@ describe("m.request()", function () { expect(request({ method: "POST", url: "http://domain.com:80/:test1", - data: {test1: "foo"} + data: {test1: "foo"}, })().url).to.equal("http://domain.com:80/foo") }) @@ -72,7 +72,7 @@ describe("m.request()", function () { var prop = m.request({ method: "GET", url: "test", - deserialize: function () { throw new Error("error occurred") } + deserialize: function () { throw new Error("error occurred") }, }).then(null, error) resolve() @@ -86,7 +86,7 @@ describe("m.request()", function () { var prop = m.request({ method: "GET", url: "test", - deserialize: function () { throw new Error("error occurred") } + deserialize: function () { throw new Error("error occurred") }, }).catch(error) resolve() @@ -99,7 +99,7 @@ describe("m.request()", function () { var data = m.prop() var prop = m.request({ method: "GET", - url: "test" + url: "test", }) .then(function () { return "foo" }) .finally(data) @@ -142,7 +142,7 @@ describe("m.request()", function () { var prop = m.request({ method: "GET", url: "test", - deserialize: function () { throw new Error("error occurred") } + deserialize: function () { throw new Error("error occurred") }, }) .catch(error) .finally(function () { error("finally") }) @@ -158,7 +158,7 @@ describe("m.request()", function () { var prop = m.request({ method: "GET", url: "test", - deserialize: function () { throw new TypeError("error occurred") } + deserialize: function () { throw new TypeError("error occurred") }, }).then(null, error) try { @@ -178,7 +178,7 @@ describe("m.request()", function () { m.request({ method: "POST", url: "test", - data: {foo: 1} + data: {foo: 1}, }).then(null, error) var xhr = mock.XMLHttpRequest.$instances.pop() @@ -194,7 +194,7 @@ describe("m.request()", function () { m.request({ method: "POST", - url: "test" + url: "test", }).then(null, error) var xhr = mock.XMLHttpRequest.$instances.pop() @@ -207,7 +207,7 @@ describe("m.request()", function () { var prop = m.request({ method: "POST", url: "test", - initialValue: "foo" + initialValue: "foo", }) var initialValue = prop() @@ -220,7 +220,7 @@ describe("m.request()", function () { var prop = m.request({ method: "POST", url: "test", - initialValue: "foo" + initialValue: "foo", }).then(function (value) { return value }) var initialValue = prop() @@ -233,7 +233,7 @@ describe("m.request()", function () { var prop = m.request({ method: "POST", url: "test", - initialValue: "foo" + initialValue: "foo", }).then(function () { return "bar" }) resolve() @@ -290,7 +290,7 @@ describe("m.request()", function () { url: "/test", dataType: "jsonp", data: data, - callbackKey: callbackKey + callbackKey: callbackKey, }) } diff --git a/test/mithril.route.buildQueryString.js b/test/mithril.route.buildQueryString.js index bd53ad5e..f8c2e159 100644 --- a/test/mithril.route.buildQueryString.js +++ b/test/mithril.route.buildQueryString.js @@ -15,11 +15,11 @@ describe("m.route.buildQueryString()", function () { foo: "bar", hello: ["world", "mars", "mars"], world: { - test: 3 + test: 3, }, bam: "", yup: null, - removed: undefined + removed: undefined, }) ).to.equal("foo=bar&hello=world&hello=mars&world%5Btest%5D=3&bam=&yup") }) diff --git a/test/mithril.route.js b/test/mithril.route.js index 7317d268..20da73ec 100644 --- a/test/mithril.route.js +++ b/test/mithril.route.js @@ -13,7 +13,7 @@ describe("m.route()", function () { var types = { search: "?", hash: "#", - pathname: "/" + pathname: "/", } return function (type) { @@ -32,7 +32,7 @@ describe("m.route()", function () { function pure(view) { return { controller: noop, - view: view + view: view, } } @@ -74,7 +74,7 @@ describe("m.route()", function () { mode("search") route(root, "/test1", { - "/test1": pure(function () { return "foo" }) + "/test1": pure(function () { return "foo" }), }) expect(mock.location.search).to.equal("?/test1") @@ -88,12 +88,12 @@ describe("m.route()", function () { route(root, "/", { "/": { controller: function () { route1 = m.route() }, - view: noop + view: noop, }, "/test13": { controller: function () { route2 = m.route() }, - view: noop - } + view: noop, + }, }) m.route("/test13") @@ -113,7 +113,7 @@ describe("m.route()", function () { }, view: function () { return m("div") - } + }, } route(root, "/a", { @@ -121,8 +121,8 @@ describe("m.route()", function () { "/b": { controller: spy, - view: noop - } + view: noop, + }, }) route("/b") @@ -142,7 +142,7 @@ describe("m.route()", function () { }, view: function () { return m("div") - } + }, } var sub = pure(function () { return subsub }) @@ -152,8 +152,8 @@ describe("m.route()", function () { "/b": { controller: spy, - view: noop - } + view: noop, + }, }) route("/b") @@ -173,7 +173,7 @@ describe("m.route()", function () { }, view: function () { return m("div") - } + }, } route(root, "/a", { @@ -181,8 +181,8 @@ describe("m.route()", function () { "/b": { controller: spy, - view: noop - } + view: noop, + }, }) route("/b") @@ -202,7 +202,7 @@ describe("m.route()", function () { }, view: function () { return m("div") - } + }, } var sub = pure(function () { return subsub }) @@ -212,8 +212,8 @@ describe("m.route()", function () { "/b": { controller: spy, - view: noop - } + view: noop, + }, }) route("/b") @@ -229,26 +229,26 @@ describe("m.route()", function () { var sub1 = { controller: ctrl1, - view: function () { return m("div") } + view: function () { return m("div") }, } var sub2 = { controller: ctrl2, - view: function () { return m("div") } + view: function () { return m("div") }, } route(root, "/a", { "/a": pure(function () { return m(".page-a", [ - m("h1"), m.component(sub1, {x: 11}) + m("h1"), m.component(sub1, {x: 11}), ]) }), "/b": pure(function () { return m(".page-b", [ - m("h2"), m.component(sub2, {y: 22}) + m("h2"), m.component(sub2, {y: 22}), ]) - }) + }), }) route("/b") @@ -264,7 +264,7 @@ describe("m.route()", function () { var Component = pure(function () { return m(".comp") }) route(root, "/foo", { - "/foo": pure(function () { return [Component] }) + "/foo": pure(function () { return [Component] }), }) expect(root.childNodes[0].nodeName).to.equal("DIV") @@ -279,7 +279,7 @@ describe("m.route()", function () { view: function (ctrl) { return m("div", ctrl.name) - } + }, } route(root, "/", { @@ -287,7 +287,7 @@ describe("m.route()", function () { return m("div", [ m("a[href=/]", {config: m.route}, "foo"), m("a[href=/bar]", {config: m.route}, "bar"), - m.component(MyComponent, {name: "Jane"}) + m.component(MyComponent, {name: "Jane"}), ]) }), @@ -295,9 +295,9 @@ describe("m.route()", function () { return m("div", [ m("a[href=/]", {config: m.route}, "foo"), m("a[href=/bar]", {config: m.route}, "bar"), - m.component(MyComponent, {name: "Bob"}) + m.component(MyComponent, {name: "Bob"}), ]) - }) + }), }) route("/bar") @@ -313,9 +313,9 @@ describe("m.route()", function () { "/test2": pure(function () { return [ "foo", - m("a", {href: "/test2", config: m.route}, "Test2") + m("a", {href: "/test2", config: m.route}, "Test2"), ] - }) + }), }) expect(mock.location.pathname).to.equal("/test2") @@ -327,7 +327,7 @@ describe("m.route()", function () { mode("hash") route(root, "/test3", { - "/test3": pure(function () { return "foo" }) + "/test3": pure(function () { return "foo" }), }) expect(mock.location.hash).to.equal("#/test3") @@ -338,7 +338,7 @@ describe("m.route()", function () { mode("search") route(root, "/test4/foo", { - "/test4/:test": pure(function () { return m.route.param("test") }) + "/test4/:test": pure(function () { return m.route.param("test") }), }) expect(mock.location.search).to.equal("?/test4/foo") @@ -357,7 +357,7 @@ describe("m.route()", function () { m.route(root, "/test5/foo", { "/": component, - "/test5/:test": component + "/test5/:test": component, }) var paramValueBefore = m.route.param("test") @@ -381,7 +381,7 @@ describe("m.route()", function () { m.route(root, "/test6/foo", { "/": component, - "/test6/:a1": component + "/test6/:a1": component, }) var paramValueBefore = m.route.param("a1") @@ -406,7 +406,7 @@ describe("m.route()", function () { m.route(root, "/test7/foo", { "/": component, - "/test7/:a1": component + "/test7/:a1": component, }) var routeValueBefore = m.route() @@ -428,7 +428,7 @@ describe("m.route()", function () { route(root, "/test8/foo/SEP/bar/baz", { "/test8/:test/SEP/:path...": pure(function () { return m.route.param("test") + "_" + m.route.param("path") - }) + }), }) expect(mock.location.search).to.equal("?/test8/foo/SEP/bar/baz") @@ -441,7 +441,7 @@ describe("m.route()", function () { route(root, "/test9/foo/bar/SEP/baz", { "/test9/:test.../SEP/:path": pure(function () { return m.route.param("test") + "_" + m.route.param("path") - }) + }), }) expect(mock.location.search).to.equal("?/test9/foo/bar/SEP/baz") @@ -454,7 +454,7 @@ describe("m.route()", function () { route(root, "/test10/foo%20bar", { "/test10/:test": pure(function () { return m.route.param("test") - }) + }), }) expect(root.childNodes[0].nodeValue).to.equal("foo bar") @@ -465,7 +465,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(function () { return "foo" }), - "/test11": pure(function () { return "bar" }) + "/test11": pure(function () { return "bar" }), }) route("/test11/") @@ -479,7 +479,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(noop), - "/test12": pure(noop) + "/test12": pure(noop), }) route("/test12?a=foo&b=bar") @@ -496,7 +496,7 @@ describe("m.route()", function () { "/": pure(function () { return "bar" }), "/test13/:test": pure(function () { return m.route.param("test") - }) + }), }) route("/test13/foo?test=bar") @@ -510,7 +510,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(function () { return "bar" }), - "/test14": pure(function () { return "foo" }) + "/test14": pure(function () { return "foo" }), }) route("/test14?test&test2=") @@ -525,7 +525,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(noop), - "/test12": pure(noop) + "/test12": pure(noop), }) route("/test12", {a: "foo", b: "bar"}) @@ -540,7 +540,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(noop), - "/test12": pure(noop) + "/test12": pure(noop), }) route("/test12", {a: "foo", b: "bar"}) @@ -562,10 +562,10 @@ describe("m.route()", function () { return m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } + }, }) }), - "/test14": pure(noop) + "/test14": pure(noop), }) route("/test14") @@ -585,11 +585,11 @@ describe("m.route()", function () { m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] }), - "/test15": pure(function () { return [m("div")] }) + "/test15": pure(function () { return [m("div")] }), }) route("/test15") @@ -607,10 +607,10 @@ describe("m.route()", function () { return m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } + }, }) }), - "/test16": pure(function () { return m("a") }) + "/test16": pure(function () { return m("a") }), }) route("/test16") @@ -629,11 +629,11 @@ describe("m.route()", function () { m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] }), - "/test17": pure(function () { return m("a") }) + "/test17": pure(function () { return m("a") }), }) route("/test17") @@ -651,10 +651,10 @@ describe("m.route()", function () { return m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } + }, }) }), - "/test18": pure(function () { return [m("a")] }) + "/test18": pure(function () { return [m("a")] }), }) route("/test18") @@ -674,8 +674,8 @@ describe("m.route()", function () { key: 1, config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] }), "/test20": pure(function () { @@ -684,10 +684,10 @@ describe("m.route()", function () { key: 2, config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] - }) + }), }) route("/test20") @@ -707,8 +707,8 @@ describe("m.route()", function () { key: 1, config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] }), "/test21": pure(function () { @@ -716,10 +716,10 @@ describe("m.route()", function () { m("div", { config: function (el, init, ctx) { ctx.onunload = onunload - } - }) + }, + }), ] - }) + }), }) route("/test21") @@ -732,7 +732,7 @@ describe("m.route()", function () { route(root, "/foo", { "/foo": pure(function () { return m("div", "foo") }), - "/bar": pure(function () { return m("div", "bar") }) + "/bar": pure(function () { return m("div", "bar") }), }) var foo = root.childNodes[0].childNodes[0].nodeValue @@ -757,7 +757,7 @@ describe("m.route()", function () { }), "/bar1": pure(function () { return m("main", m("a", {config: config}, "foo")) - }) + }), }) route("/bar1") @@ -774,8 +774,8 @@ describe("m.route()", function () { controller: function () { value = m.route.param("arg") }, view: function () { return "" - } - } + }, + }, }) expect(value).to.equal("foo+bar") }) @@ -785,7 +785,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(function () { return "foo" }), - "/test22": pure(function () { return "bar" }) + "/test22": pure(function () { return "bar" }), }) m.route("/test22/") @@ -799,7 +799,7 @@ describe("m.route()", function () { route(root, "/", { "/": pure(function () { return "foo" }), - "/test23": pure(function () { return "bar" }) + "/test23": pure(function () { return "bar" }), }) route(new String("/test23/")) // eslint-disable-line no-new-wrappers @@ -817,8 +817,8 @@ describe("m.route()", function () { controller: function () { value = m.route.param("arg") }, view: function () { return "" - } - } + }, + }, }) expect(value).to.equal("foo+bar") }) @@ -832,8 +832,8 @@ describe("m.route()", function () { controller: function () { value = m.route.param("arg") }, view: function () { return "" - } - } + }, + }, }) expect(value).to.equal("foo+bar") @@ -845,10 +845,10 @@ describe("m.route()", function () { route(root, "/a", { "/a": { controller: function () { m.route("/b") }, - view: function () { return "a" } + view: function () { return "a" }, }, - "/b": pure(function () { return "b" }) + "/b": pure(function () { return "b" }), }) expect(root.childNodes[0].nodeValue).to.equal("b") @@ -862,9 +862,9 @@ describe("m.route()", function () { controller: function () { m.route("/b?foo=1", {foo: 2}) }, - view: function () { return "a" } + view: function () { return "a" }, }, - "/b": pure(function () { return "b" }) + "/b": pure(function () { return "b" }), }) expect(mock.location.search).to.equal("?/b?foo=2") @@ -876,7 +876,7 @@ describe("m.route()", function () { route(root, "/a", { "/a": pure(function () { return "a" }), - "/b": pure(function () { return "b" }) + "/b": pure(function () { return "b" }), }) route("/b") @@ -890,7 +890,7 @@ describe("m.route()", function () { route(root, "/a", { "/a": pure(function () { return "a" }), - "/b": pure(function () { return "b" }) + "/b": pure(function () { return "b" }), }) route("/a") @@ -908,13 +908,13 @@ describe("m.route()", function () { return m("a", { config: function (el, init) { if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": pure(a.view) + "/b": pure(a.view), }) route("/b") @@ -931,13 +931,13 @@ describe("m.route()", function () { config: function (el, init, ctx) { ctx.retain = false if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": pure(a.view) + "/b": pure(a.view), }) route("/b") @@ -954,13 +954,13 @@ describe("m.route()", function () { config: function (el, init, ctx) { ctx.retain = true if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": pure(a.view) + "/b": pure(a.view), }) route("/b") @@ -984,7 +984,7 @@ describe("m.route()", function () { }), "/b": pure(function () { return m("section", m("a", {config: config})) - }) + }), }) route("/b") @@ -1006,7 +1006,7 @@ describe("m.route()", function () { }), "/b": pure(function () { return m("section", m("a", {config: config})) - }) + }), }) route("/b") @@ -1028,7 +1028,7 @@ describe("m.route()", function () { }), "/b": pure(function () { return m("section", m("a", {config: config})) - }) + }), }) route("/b") @@ -1042,7 +1042,7 @@ describe("m.route()", function () { function diff(view) { return { controller: function () { m.redraw.strategy("diff") }, - view: view + view: view, } } @@ -1055,13 +1055,13 @@ describe("m.route()", function () { return m("a", { config: function (el, init) { if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": diff(a.view) + "/b": diff(a.view), }) route("/b") @@ -1078,13 +1078,13 @@ describe("m.route()", function () { config: function (el, init, ctx) { ctx.retain = true if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": diff(a.view) + "/b": diff(a.view), }) route("/b") @@ -1101,13 +1101,13 @@ describe("m.route()", function () { config: function (el, init, ctx) { ctx.retain = false if (!init) initCount++ - } + }, }) }) route(root, "/a", { "/a": a, - "/b": diff(a.view) + "/b": diff(a.view), }) route("/b") @@ -1131,7 +1131,7 @@ describe("m.route()", function () { }), "/b": diff(function () { return m("section", m("a", {config: config})) - }) + }), }) route("/b") @@ -1154,7 +1154,7 @@ describe("m.route()", function () { }), "/b": diff(function () { return m("section", m("a", {config: config})) - }) + }), }) route("/b") @@ -1177,7 +1177,7 @@ describe("m.route()", function () { }), "/b": diff(function () { return m("section", m("a", {config: config})) - }) + }), }) m.route("/b") @@ -1204,12 +1204,12 @@ describe("m.route()", function () { controller: function () { m.redraw.strategy("diff") }, view: function () { return m("section", m("a", {config: config})) - } + }, } route(root, "/a", { "/a": pure(function () { return m("div", a) }), - "/b": pure(function () { return m("div", b) }) + "/b": pure(function () { return m("div", b) }), }) route("/b") @@ -1226,10 +1226,10 @@ describe("m.route()", function () { return m("div", { config: function (el) { el.childNodes[0].modified = true - } + }, }, m("div")) }), - "/b": pure(function () { return m("div", m("div")) }) + "/b": pure(function () { return m("div", m("div")) }), }) route("/b") diff --git a/test/mithril.route.parseQueryString.js b/test/mithril.route.parseQueryString.js index 3acc68ba..1999ae39 100644 --- a/test/mithril.route.parseQueryString.js +++ b/test/mithril.route.parseQueryString.js @@ -18,7 +18,7 @@ describe("m.route.parseQueryString()", function () { foo: "bar", hello: ["world", "mars"], bam: "", - yup: null + yup: null, }) }) @@ -28,7 +28,7 @@ describe("m.route.parseQueryString()", function () { expect(args).to.eql({ foo: "bar", - "hello[]": ["world", "mars", "pluto"] + "hello[]": ["world", "mars", "pluto"], }) }) }) diff --git a/test/mithril.startComputation.js b/test/mithril.startComputation.js index cfa58063..dffe557c 100644 --- a/test/mithril.startComputation.js +++ b/test/mithril.startComputation.js @@ -12,7 +12,7 @@ describe("m.startComputation(), m.endComputation()", function () { var root = mock.document.createElement("div") var controller = m.mount(root, { controller: function () {}, - view: function (ctrl) { return ctrl.value } + view: function (ctrl) { return ctrl.value }, }) mock.requestAnimationFrame.$resolve() diff --git a/test/mithril.trust.js b/test/mithril.trust.js index 748fa75e..262bb964 100644 --- a/test/mithril.trust.js +++ b/test/mithril.trust.js @@ -36,7 +36,7 @@ describe("m.trust()", function () { var root = document.createElement("div") m.render(root, [ m.trust("

1

123

2

"), - m("i", "foo") + m("i", "foo"), ]) expect(root.childNodes[3].tagName).to.equal("I") }) @@ -49,7 +49,7 @@ describe("m.trust()", function () { m.render(root, [ m.trust("12"), - m("td", "foo") + m("td", "foo"), ]) expect(root.childNodes[2].tagName).to.equal("td") diff --git a/test/svg.html b/test/svg.html index 322d1045..5f99195c 100644 --- a/test/svg.html +++ b/test/svg.html @@ -57,20 +57,20 @@ m.render(document.getElementById("test"), [ height: 100, width: 100, transform: "translate(30) rotate(45 50 50)", - style: {stroke: "#000", fill: "#0086b2"} + style: {stroke: "#000", fill: "#0086b2"}, }), m("a[href='http://google.com'][title='SVG link'][target=_new]", { - style: {textDecoration: "underline"} + style: {textDecoration: "underline"}, }, [ - m("text[x=0][y=20]", "SVG Link") - ]) + m("text[x=0][y=20]", "SVG Link"), + ]), ]), m("svg[height=201px][width=201px]", [ m("image[href='http://placekitten.com/201/201']", { height: "200px", width: "200px", - title: "Cat picture" - }) + title: "Cat picture", + }), ]), m("svg[title='Line drawings']", { "enable-background": "new 0 0 340 333", @@ -78,7 +78,7 @@ m.render(document.getElementById("test"), [ viewBox: "0 0 340 333", width: "340px", x: "0px", - y: "0px" + y: "0px", }, [ m("path.path", { d: [ @@ -141,7 +141,7 @@ m.render(document.getElementById("test"), [ type: "rotate", repeatCount: "indefinite", dur: "12h", - by: 360 + by: 360, }), m("circle[r=7]") ]), @@ -151,7 +151,7 @@ m.render(document.getElementById("test"), [ y2: 93, "stroke-linecap": "round", stroke: "green", - opacity: 0.9 + opacity: 0.9, }), m("animateTransform[attributeName=transform]", { type: "rotate", @@ -167,13 +167,13 @@ m.render(document.getElementById("test"), [ y1: -20, y2: 102, "stroke-linecap": "round", - stroke: "red" + stroke: "red", }), m("animateTransform[attributeName=transform]", { type: "rotate", repeatCount: "indefinite", dur: "60s", - by: 360 + by: 360, }), m("circle[r=4][fill=blue]") ]) @@ -207,8 +207,8 @@ m.render(document.getElementById("test"), [ }, m("div", {xmlns: "http://www.w3.org/1999/xhtml"}, [ m.trust("this is a piece of html rendered as " + "" + - "SVG foreignObject") - ])) - ]) + "SVG foreignObject"), + ])), + ]), ])