Merge 'origin/patch-2', remove trailing commas

This commit is contained in:
impinball 2015-11-25 22:45:45 -05:00
parent e0f51db618
commit 0b173deed7
19 changed files with 380 additions and 384 deletions

View file

@ -53,7 +53,6 @@
"block-spacing": 2, "block-spacing": 2,
"brace-style": [2, "1tbs", {"allowSingleLine": true}], "brace-style": [2, "1tbs", {"allowSingleLine": true}],
"camelcase": 2, "camelcase": 2,
"comma-dangle": [2, "always-multiline"],
"comma-spacing": 2, "comma-spacing": 2,
"comma-style": 2, "comma-style": 2,
"consistent-this": [2, "self"], "consistent-this": [2, "self"],

View file

@ -120,8 +120,8 @@ for (var i = 0; i < CARD_DECK_SIZE; i++) {
// Also good // Also good
function toFastProperties(obj) { function toFastProperties(obj) {
// Bluebird's toFastProperties hack. Forces V8 to optimize object as prototype, // Bluebird's toFastProperties hack. Forces V8 to optimize object as
// significantly speeding up property access. // prototype, significantly speeding up property access.
/* eslint-disable no-eval */ /* eslint-disable no-eval */
function C() {} function C() {}
@ -362,7 +362,7 @@ var object = {
foo: 1, foo: 1,
bar: 2, bar: 2,
baz: 3, baz: 3,
quux: "string", quux: "string"
} }
// Bad // Bad
@ -373,7 +373,7 @@ var object = {
foo: 1, foo: 1,
bar: 2, bar: 2,
baz: 3, baz: 3,
quux: "string", quux: "string"
} }
``` ```
@ -402,7 +402,7 @@ var object = {
foo: 1, foo: 1,
bar: 2, bar: 2,
baz: 3, baz: 3,
quux: "string", quux: "string"
} }
// Bad // Bad
@ -413,28 +413,25 @@ Prefer plain objects over `new function () {}`, but if you feel the latter is be
### Comma placement ### Comma placement
Commas come last. Also, use trailing commas if the object takes multiple lines. Commas come last. Don't use trailing commas
```js ```js
// Good // Good
var object = { var object = {
foo: 1, foo: 1,
bar: 2, bar: 2
} }
// Bad // Bad
var object = { var object = {
foo: 1, foo: 1,
bar: 2 // No trailing comma bar: 2, // Trailing comma
} }
var object = { var object = {
foo: 1 foo: 1
, bar: 2 // Comma first , bar: 2 // Comma first
} }
// Also bad
var object = {foo: 1,}
``` ```
### Member access ### Member access
@ -461,23 +458,23 @@ Quote properties when needed. Never quote valid identifiers. This may lead to so
// Good // Good
var object = { var object = {
foo: 1, foo: 1,
bar: 2, bar: 2
} }
var object = { var object = {
foo: 1, foo: 1,
"non-identifier": 2, "non-identifier": 2
} }
// Bad // Bad
var object = { var object = {
"foo": 1, "foo": 1,
"bar": 2, "bar": 2
} }
var object = { var object = {
"foo": 1, "foo": 1,
"non-identifier": 2, "non-identifier": 2
} }
``` ```

View file

@ -22,7 +22,7 @@ module.exports = function (grunt) { // eslint-disable-line
"refactoring", "refactoring",
"routing", "routing",
"tools", "tools",
"web-services", "web-services"
] ]
var api = [ var api = [
@ -43,7 +43,7 @@ module.exports = function (grunt) { // eslint-disable-line
"mithril.sync", "mithril.sync",
"mithril.trust", "mithril.trust",
"mithril.withAttr", "mithril.withAttr",
"mithril.xhr", "mithril.xhr"
] ]
var md2htmlTasks = {} var md2htmlTasks = {}
@ -60,12 +60,12 @@ module.exports = function (grunt) { // eslint-disable-line
md2htmlTasks[name] = { md2htmlTasks[name] = {
options: { options: {
layout: inputFolder + "/layout/" + layout + ".html", layout: inputFolder + "/layout/" + layout + ".html",
templateData: {topic: title}, templateData: {topic: title}
}, },
files: [{ files: [{
src: [src], src: [src],
dest: tempFolder + "/" + name + ".html", dest: tempFolder + "/" + name + ".html"
}], }]
} }
}) })
} }
@ -80,7 +80,7 @@ module.exports = function (grunt) { // eslint-disable-line
eslint: { eslint: {
options: { options: {
extensions: [".js"], extensions: [".js"],
fix: true, fix: true
}, },
all: [ all: [
"**/*.js", "**/*.js",
@ -89,17 +89,17 @@ module.exports = function (grunt) { // eslint-disable-line
"!archive/**", "!archive/**",
"!deploy/**", "!deploy/**",
"!mithril.closure-compiler-externs.js", "!mithril.closure-compiler-externs.js",
"!docs/layout/lib/**", "!docs/layout/lib/**"
], ]
}, },
mocha_phantomjs: { // eslint-disable-line camelcase mocha_phantomjs: { // eslint-disable-line camelcase
test: { test: {
src: ["test/index.html"], src: ["test/index.html"],
options: { options: {
reporter: "dot", reporter: "dot"
}, }
}, }
}, },
md2html: md2htmlTasks, md2html: md2htmlTasks,
@ -112,11 +112,11 @@ module.exports = function (grunt) { // eslint-disable-line
pkg.homepage, pkg.homepage,
"(c) 2014-" + currentYear + " " + pkg.author.name, "(c) 2014-" + currentYear + " " + pkg.author.name,
"License: " + pkg.license, "License: " + pkg.license,
"*/", "*/"
].join("\n"), ].join("\n"),
sourceMap: true, sourceMap: true
}, },
mithril: {src: "mithril.js", dest: "mithril.min.js"}, mithril: {src: "mithril.js", dest: "mithril.min.js"}
}, },
zip: { zip: {
@ -125,10 +125,10 @@ module.exports = function (grunt) { // eslint-disable-line
src: [ src: [
currentVersionArchiveFolder + "/mithril.min.js", currentVersionArchiveFolder + "/mithril.min.js",
currentVersionArchiveFolder + "/mithril.min.js.map", currentVersionArchiveFolder + "/mithril.min.js.map",
currentVersionArchiveFolder + "/mithril.js", currentVersionArchiveFolder + "/mithril.js"
], ],
dest: currentVersionArchiveFolder + "/mithril.min.zip", dest: currentVersionArchiveFolder + "/mithril.min.zip"
}, }
}, },
replace: { replace: {
@ -136,105 +136,105 @@ module.exports = function (grunt) { // eslint-disable-line
force: true, force: true,
patterns: [ patterns: [
{match: /\.md/g, replacement: ".html"}, {match: /\.md/g, replacement: ".html"},
{match: /\$version/g, replacement: pkg.version}, {match: /\$version/g, replacement: pkg.version}
], ]
}, },
links: { links: {
expand: true, expand: true,
flatten: true, flatten: true,
src: [tempFolder + "/**/*.html"], src: [tempFolder + "/**/*.html"],
dest: currentVersionArchiveFolder + "/", dest: currentVersionArchiveFolder + "/"
}, },
index: { index: {
src: inputFolder + "/layout/index.html", src: inputFolder + "/layout/index.html",
dest: currentVersionArchiveFolder + "/index.html", dest: currentVersionArchiveFolder + "/index.html"
}, },
commonjs: { commonjs: {
expand: true, expand: true,
flatten: true, flatten: true,
src: [inputFolder + "/layout/*.json"], src: [inputFolder + "/layout/*.json"],
dest: currentVersionArchiveFolder, dest: currentVersionArchiveFolder
}, },
cdnjs: { cdnjs: {
src: "deploy/cdnjs-package.json", src: "deploy/cdnjs-package.json",
dest: "../cdnjs/ajax/libs/mithril/package.json", dest: "../cdnjs/ajax/libs/mithril/package.json"
}, }
}, },
copy: { copy: {
style: { style: {
src: inputFolder + "/layout/style.css", src: inputFolder + "/layout/style.css",
dest: currentVersionArchiveFolder + "/style.css", dest: currentVersionArchiveFolder + "/style.css"
}, },
pages: { pages: {
src: inputFolder + "/layout/pages.json", src: inputFolder + "/layout/pages.json",
dest: currentVersionArchiveFolder + "/pages.json", dest: currentVersionArchiveFolder + "/pages.json"
}, },
lib: { lib: {
expand: true, expand: true,
cwd: inputFolder + "/layout/lib/", cwd: inputFolder + "/layout/lib/",
src: "./**", src: "./**",
dest: currentVersionArchiveFolder + "/lib/", dest: currentVersionArchiveFolder + "/lib/"
}, },
tools: { tools: {
expand: true, expand: true,
cwd: inputFolder + "/layout/tools/", cwd: inputFolder + "/layout/tools/",
src: "./**", src: "./**",
dest: currentVersionArchiveFolder + "/tools/", dest: currentVersionArchiveFolder + "/tools/"
}, },
comparisons: { comparisons: {
expand: true, expand: true,
cwd: inputFolder + "/layout/comparisons/", cwd: inputFolder + "/layout/comparisons/",
src: "./**", src: "./**",
dest: currentVersionArchiveFolder + "/comparisons/", dest: currentVersionArchiveFolder + "/comparisons/"
}, },
unminified: { unminified: {
src: "mithril.js", src: "mithril.js",
dest: currentVersionArchiveFolder + "/mithril.js", dest: currentVersionArchiveFolder + "/mithril.js"
}, },
minified: { minified: {
src: "mithril.min.js", src: "mithril.min.js",
dest: currentVersionArchiveFolder + "/mithril.min.js", dest: currentVersionArchiveFolder + "/mithril.min.js"
}, },
readme: { readme: {
src: "README.md", src: "README.md",
dest: currentVersionArchiveFolder + "/README.md", dest: currentVersionArchiveFolder + "/README.md"
}, },
map: { map: {
src: "mithril.min.js.map", src: "mithril.min.js.map",
dest: currentVersionArchiveFolder + "/mithril.min.js.map", dest: currentVersionArchiveFolder + "/mithril.min.js.map"
}, },
typescript: { typescript: {
src: "mithril.d.ts", src: "mithril.d.ts",
dest: currentVersionArchiveFolder + "/mithril.d.ts", dest: currentVersionArchiveFolder + "/mithril.d.ts"
}, },
publish: { publish: {
expand: true, expand: true,
cwd: currentVersionArchiveFolder, cwd: currentVersionArchiveFolder,
src: "./**", src: "./**",
dest: outputFolder, dest: outputFolder
}, },
archive: { archive: {
expand: true, expand: true,
cwd: currentVersionArchiveFolder, cwd: currentVersionArchiveFolder,
src: "./**", src: "./**",
dest: outputFolder + "/archive/v" + pkg.version, dest: outputFolder + "/archive/v" + pkg.version
}, }
}, },
"saucelabs-browsers": { "saucelabs-browsers": {
@ -246,7 +246,7 @@ module.exports = function (grunt) { // eslint-disable-line
return version === "dev" || version === "beta" || return version === "dev" || version === "beta" ||
+version >= 38 // The latest ESR version +version >= 38 // The latest ESR version
}) })
}, }
}, },
chrome: { chrome: {
@ -257,7 +257,7 @@ module.exports = function (grunt) { // eslint-disable-line
return version === "dev" || version === "beta" || return version === "dev" || version === "beta" ||
+version >= 41 +version >= 41
}) })
}, }
}, },
ie: { ie: {
@ -266,7 +266,7 @@ module.exports = function (grunt) { // eslint-disable-line
return browser.browserName === "internet explorer" && return browser.browserName === "internet explorer" &&
!/2003/.test(browser.platform) !/2003/.test(browser.platform)
}) })
}, }
}, },
edge: { edge: {
@ -274,7 +274,7 @@ module.exports = function (grunt) { // eslint-disable-line
return browsers.filter(function (browser) { return browsers.filter(function (browser) {
return browser.browserName === "microsoftedge" return browser.browserName === "microsoftedge"
}) })
}, }
}, },
safari: { safari: {
@ -282,7 +282,7 @@ module.exports = function (grunt) { // eslint-disable-line
return browsers.filter(function (browser) { return browsers.filter(function (browser) {
return browser.browserName === "safari" return browser.browserName === "safari"
}) })
}, }
}, },
opera: { opera: {
@ -290,8 +290,8 @@ module.exports = function (grunt) { // eslint-disable-line
return browsers.filter(function (browser) { return browsers.filter(function (browser) {
return browser.browserName === "opera" return browser.browserName === "opera"
}) })
}, }
}, }
}, },
saucelabs: { saucelabs: {
@ -304,7 +304,7 @@ module.exports = function (grunt) { // eslint-disable-line
urls: ["http://localhost:8000/test/index.html"], urls: ["http://localhost:8000/test/index.html"],
sauceConfig: { sauceConfig: {
"record-video": false, "record-video": false,
"record-screenshots": false, "record-screenshots": false
}, },
build: process.env.TRAVIS_JOB_ID, build: process.env.TRAVIS_JOB_ID,
onTestComplete: function (result, callback) { onTestComplete: function (result, callback) {
@ -313,13 +313,13 @@ module.exports = function (grunt) { // eslint-disable-line
var url = [ var url = [
"https://saucelabs.com/rest/v1", user, "jobs", "https://saucelabs.com/rest/v1", user, "jobs",
result.job_id, result.job_id
].join("/") ].join("/")
require("request").put({ require("request").put({
url: url, url: url,
auth: {user: user, pass: pass}, auth: {user: user, pass: pass},
json: {passed: result.passed}, json: {passed: result.passed}
}, function (error, response) { }, function (error, response) {
if (error) { if (error) {
return callback(error) return callback(error)
@ -332,24 +332,24 @@ module.exports = function (grunt) { // eslint-disable-line
} }
}) })
}, },
tunnelTimeout: 5, tunnelTimeout: 5
}, }
}, }
}, },
connect: { connect: {
server: { server: {
options: { options: {
port: 8888, port: 8888,
base: ".", base: "."
}, }
}, }
}, },
clean: { clean: {
options: {force: true}, options: {force: true},
generated: [tempFolder], generated: [tempFolder]
}, }
}) })
grunt.loadNpmTasks("grunt-saucelabs-browsers") grunt.loadNpmTasks("grunt-saucelabs-browsers")
@ -371,7 +371,7 @@ module.exports = function (grunt) { // eslint-disable-line
"md2html", "md2html",
"replace", "replace",
"copy", "copy",
"clean", "clean"
]) ])
grunt.registerTask("test", ["eslint:all", "mocha_phantomjs"]) grunt.registerTask("test", ["eslint:all", "mocha_phantomjs"])
@ -380,6 +380,6 @@ module.exports = function (grunt) { // eslint-disable-line
grunt.registerTask("sauce", [ grunt.registerTask("sauce", [
"saucelabs-browsers:all", "saucelabs-browsers:all",
"connect", "connect",
"saucelabs", "saucelabs"
]) ])
} }

View file

@ -14,7 +14,7 @@ window.templateConverter = (function () {
return [ return [
new DOMParser() new DOMParser()
.parseFromString(markup, "text/html") .parseFromString(markup, "text/html")
.childNodes[1], .childNodes[1]
] ]
} }
@ -39,7 +39,7 @@ window.templateConverter = (function () {
list.push({ list.push({
tag: el.nodeName.toLowerCase(), tag: el.nodeName.toLowerCase(),
attrs: attrs, attrs: attrs,
children: createVirtual(el.childNodes), children: createVirtual(el.childNodes)
}) })
} }
}) })
@ -115,7 +115,7 @@ window.templateConverter = (function () {
var body = this.virtuals.join("," + tab) var body = this.virtuals.join("," + tab)
return "[" + tab + body + tab.slice(0, -1) + "]" return "[" + tab + body + tab.slice(0, -1) + "]"
} }
}, }
} }
return { return {
@ -134,12 +134,12 @@ window.templateConverter = (function () {
m("textarea", { m("textarea", {
autofocus: true, autofocus: true,
style: {width: "100%", height: "40%"}, style: {width: "100%", height: "40%"},
onchange: m.withAttr("value", ctrl.source), onchange: m.withAttr("value", ctrl.source)
}, ctrl.source()), }, ctrl.source()),
m("button", {onclick: ctrl.convert}, "Convert"), m("button", {onclick: ctrl.convert}, "Convert"),
m("textarea", {style: {width: "100%", height: "40%"}}, m("textarea", {style: {width: "100%", height: "40%"}},
ctrl.output()), ctrl.output())
]) ])
}, }
} }
})() })()

View file

@ -231,7 +231,7 @@ void (function (global, factory) { // eslint-disable-line
index: i, index: i,
from: existing[key].index, from: existing[key].index,
element: cached.nodes[existing[key].index] || element: cached.nodes[existing[key].index] ||
$document.createElement("div"), $document.createElement("div")
} }
} else { } else {
existing[key] = {action: INSERTION, index: i} existing[key] = {action: INSERTION, index: i}
@ -263,7 +263,7 @@ void (function (global, factory) { // eslint-disable-line
insertNode(parent, dummy, index) insertNode(parent, dummy, index)
newCached.splice(index, 0, { newCached.splice(index, 0, {
attrs: {key: data[index].attrs.key}, attrs: {key: data[index].attrs.key},
nodes: [dummy], nodes: [dummy]
}) })
newCached.nodes[index] = dummy newCached.nodes[index] = dummy
break break
@ -694,7 +694,7 @@ void (function (global, factory) { // eslint-disable-line
tag: data.tag, tag: data.tag,
attrs: attrs, attrs: attrs,
children: children, children: children,
nodes: [node], nodes: [node]
} }
unloadCachedControllers(cached, views, controllers) unloadCachedControllers(cached, views, controllers)
@ -732,7 +732,7 @@ void (function (global, factory) { // eslint-disable-line
if (controller.onunload != null) { if (controller.onunload != null) {
unloaders.push({ unloaders.push({
controller: controller, controller: controller,
handler: controller.onunload, handler: controller.onunload
}) })
} }
@ -1133,7 +1133,7 @@ void (function (global, factory) { // eslint-disable-line
this.appendChild(node) this.appendChild(node)
}, },
childNodes: [], childNodes: []
} }
var nodeCache = [] var nodeCache = []
@ -1296,7 +1296,7 @@ void (function (global, factory) { // eslint-disable-line
preventDefault: function () { preventDefault: function () {
isPrevented = true isPrevented = true
computePreRedrawHook = computePostRedrawHook = null computePreRedrawHook = computePostRedrawHook = null
}, }
} }
forEach(unloaders, function (unloader) { forEach(unloaders, function (unloader) {
@ -1434,7 +1434,7 @@ void (function (global, factory) { // eslint-disable-line
var modes = { var modes = {
pathname: "", pathname: "",
hash: "#", hash: "#",
search: "?", search: "?"
} }
var redirect = noop var redirect = noop
@ -1955,8 +1955,8 @@ void (function (global, factory) { // eslint-disable-line
options.onload({ options.onload({
type: "load", type: "load",
target: { target: {
responseText: resp, responseText: resp
}, }
}) })
window[callbackKey] = undefined window[callbackKey] = undefined
@ -1969,8 +1969,8 @@ void (function (global, factory) { // eslint-disable-line
type: "error", type: "error",
target: { target: {
status: 500, status: 500,
responseText: '{"error": "Error making jsonp request"}', responseText: '{"error": "Error making jsonp request"}'
}, }
}) })
window[callbackKey] = undefined window[callbackKey] = undefined

View file

@ -49,7 +49,7 @@ this.mock = (function (global) {
// the browser. Still waiting on mocha-phantomjs to update to be // the browser. Still waiting on mocha-phantomjs to update to be
// compatible with PhantomJS 2.x. // compatible with PhantomJS 2.x.
phantom: global.window && global.window.navigator && phantom: global.window && global.window.navigator &&
/PhantomJS/.test(global.window.navigator.userAgent), /PhantomJS/.test(global.window.navigator.userAgent)
} }
var document = window.document = { var document = window.document = {
@ -102,7 +102,7 @@ this.mock = (function (global) {
}, },
addEventListener: function () {}, addEventListener: function () {},
removeEventListener: function () {}, removeEventListener: function () {}
} }
}, },
@ -156,7 +156,7 @@ this.mock = (function (global) {
traverse(document) traverse(document)
return out return out
}, }
} }
document.documentElement = document.createElement("html") document.documentElement = document.createElement("html")
@ -182,7 +182,7 @@ this.mock = (function (global) {
indices[id] = callbacks.length indices[id] = callbacks.length
callbacks.push({ callbacks.push({
callback: callback, callback: callback,
id: id, id: id
}) })
return id return id
} }
@ -258,7 +258,7 @@ this.mock = (function (global) {
replaceState: function (data, title, url) { replaceState: function (data, title, url) {
location.pathname = location.search = location.hash = url location.pathname = location.search = location.hash = url
}, }
} }
return window return window

View file

@ -67,7 +67,7 @@ runner.on('fail', function (test, err) {
result: false, result: false,
message: err.message, message: err.message,
stack: err.stack, stack: err.stack,
titles: flattenTitles(test), titles: flattenTitles(test)
}) })
}) })
</script> </script>

View file

@ -20,7 +20,7 @@
function test(sel) { function test(sel) {
return m("li", [ return m("li", [
m("p", m("code", "m(" + JSON.stringify(sel) + ")")), m("p", m("code", "m(" + JSON.stringify(sel) + ")")),
m.apply(null, arguments), m.apply(null, arguments)
]) ])
} }
@ -35,18 +35,18 @@ m.module(document.getElementById("test"), {
m("ul", [ m("ul", [
test("input[list=data]", { test("input[list=data]", {
onkeyup: m.withAttr("value", ctrl.title), onkeyup: m.withAttr("value", ctrl.title),
value: ctrl.title(), value: ctrl.title()
}), }),
test("datalist#data", [ test("datalist#data", [
m("option", "John"), m("option", "John"),
m("option", "Bob"), m("option", "Bob"),
m("option", "Mary"), m("option", "Mary")
]), ]),
test("textarea", { test("textarea", {
onkeyup: m.withAttr("value", ctrl.title), onkeyup: m.withAttr("value", ctrl.title),
value: ctrl.title(), value: ctrl.title()
}), }),
m("li", [ m("li", [
@ -55,7 +55,7 @@ m.module(document.getElementById("test"), {
m("div[contenteditable]", { m("div[contenteditable]", {
style: {border: "1px solid #888"}, style: {border: "1px solid #888"},
onkeyup: m.withAttr("innerHTML", ctrl.title) onkeyup: m.withAttr("innerHTML", ctrl.title)
}, ctrl.title()), }, ctrl.title())
]), ]),
m("li", [ m("li", [
@ -63,11 +63,11 @@ m.module(document.getElementById("test"), {
m("code", "m(\"div[contenteditable]\")")), m("code", "m(\"div[contenteditable]\")")),
m("div[contenteditable]", { m("div[contenteditable]", {
style: {border: "1px solid #888"}, style: {border: "1px solid #888"},
onkeyup: m.withAttr("innerHTML", ctrl.title), onkeyup: m.withAttr("innerHTML", ctrl.title)
}, m.trust(ctrl.title())), }, m.trust(ctrl.title()))
]), ])
]), ])
]) ])
}, }
}) })
</script> </script>

View file

@ -202,7 +202,7 @@ describe("m()", function () {
controller: spy, controller: spy,
view: function () { view: function () {
return m("div", "testing") return m("div", "testing")
}, }
} }
var args = {age: 12} var args = {age: 12}

View file

@ -22,7 +22,7 @@ describe("m.mount()", function () {
function pure(view) { function pure(view) {
return { return {
controller: function () {}, controller: function () {},
view: view, view: view
} }
} }
@ -38,7 +38,7 @@ describe("m.mount()", function () {
return [ return [
whatever % 2 ? m("span", "% 2") : undefined, whatever % 2 ? m("span", "% 2") : undefined,
m("div", "bugs"), m("div", "bugs"),
m("a"), m("a")
] ]
}) })
@ -64,7 +64,7 @@ describe("m.mount()", function () {
var mod1 = m.mount(root1, { var mod1 = m.mount(root1, {
controller: controller1, controller: controller1,
view: view1, view: view1
}) })
var controller2 = sinon.spy(function () { this.value = "test2" }) // eslint-disable-line var controller2 = sinon.spy(function () { this.value = "test2" }) // eslint-disable-line
@ -73,7 +73,7 @@ describe("m.mount()", function () {
var mod2 = mount(root2, { var mod2 = mount(root2, {
controller: controller2, controller: controller2,
view: view2, view: view2
}) })
expect(controller1).to.have.been.called expect(controller1).to.have.been.called
@ -97,7 +97,7 @@ describe("m.mount()", function () {
controller: function () { controller: function () {
this.onunload = spy this.onunload = spy
}, },
view: function () {}, view: function () {}
}) })
clear(root) clear(root)
@ -114,7 +114,7 @@ describe("m.mount()", function () {
var component = { var component = {
controller: ctrlSpy, controller: ctrlSpy,
view: viewSpy, view: viewSpy
} }
var arg = {} var arg = {}
@ -148,7 +148,7 @@ describe("m.mount()", function () {
var sub = { var sub = {
controller: ctrlSpy, controller: ctrlSpy,
view: viewSpy, view: viewSpy
} }
mount(root, pure(function () { return sub })) mount(root, pure(function () { return sub }))
@ -168,7 +168,7 @@ describe("m.mount()", function () {
var subsub = { var subsub = {
controller: ctrl1, controller: ctrl1,
view: view1, view: view1
} }
var ctrl2 = sinon.spy() var ctrl2 = sinon.spy()
@ -176,7 +176,7 @@ describe("m.mount()", function () {
var sub = { var sub = {
controller: ctrl2, controller: ctrl2,
view: view2, view: view2
} }
mount(root, pure(function () { return sub })) mount(root, pure(function () { return sub }))
@ -326,7 +326,7 @@ describe("m.mount()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
mount(root, pure(function () { mount(root, pure(function () {
@ -358,7 +358,7 @@ describe("m.mount()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
var sub = { var sub = {
@ -367,7 +367,7 @@ describe("m.mount()", function () {
}, },
view: function (ctrl, opts) { view: function (ctrl, opts) {
return m.component(subsub, {key: opts.key}) return m.component(subsub, {key: opts.key})
}, }
} }
mount(root, pure(function () { mount(root, pure(function () {
@ -400,7 +400,7 @@ describe("m.mount()", function () {
controller: function () { controller: function () {
m.redraw() m.redraw()
}, },
view: spy, view: spy
} }
mount(root, pure(function () { return sub })) mount(root, pure(function () { return sub }))
@ -418,7 +418,7 @@ describe("m.mount()", function () {
controller: function () { controller: function () {
m.redraw() m.redraw()
}, },
view: spy, view: spy
} }
var sub = pure(function () { return subsub }) var sub = pure(function () { return subsub })
@ -439,14 +439,14 @@ describe("m.mount()", function () {
var CommentList = pure(function (ctrl, props) { var CommentList = pure(function (ctrl, props) {
return m(".list", props.list.map(function (i) { return m(".list", props.list.map(function (i) {
return m(".comment", [ return m(".comment", [
m.component(Reply, {key: i}), m.component(Reply, {key: i})
]) ])
})) }))
}) })
mount(root, pure(function () { mount(root, pure(function () {
return m(".outer", [ 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 () { controller: function () {
this.onunload = spy this.onunload = spy
}, },
view: function () {}, view: function () {}
}) })
m.mount(root, pure(function () {})) m.mount(root, pure(function () {}))
@ -479,7 +479,7 @@ describe("m.mount()", function () {
return m("div", { return m("div", {
config: function (el, init) { config: function (el, init) {
if (init) count += 1 if (init) count += 1
}, }
}) })
})) }))
@ -505,9 +505,9 @@ describe("m.mount()", function () {
m(".foo", { m(".foo", {
key: 1, key: 1,
config: test, config: test,
onclick: function () { show = !show }, onclick: function () { show = !show }
}), }),
show ? m(".bar", {key: 2}) : null, show ? m(".bar", {key: 2}) : null
] ]
})) }))
@ -529,9 +529,9 @@ describe("m.mount()", function () {
mount(root, pure(function () { mount(root, pure(function () {
return show ? [ return show ? [
m("h1", "1"), m("h1", "1"),
sub, sub
] : [ ] : [
m("h1", "2"), m("h1", "2")
] ]
})) }))
@ -560,10 +560,10 @@ describe("m.mount()", function () {
a = !a a = !a
m.redraw(true) m.redraw(true)
found = root.childNodes[0].childNodes[1] found = root.childNodes[0].childNodes[1]
}, }
}, "asd"), }, "asd"),
a ? m("#a", "aaa") : null, a ? m("#a", "aaa") : null,
"test", "test"
]) ])
}) })
@ -572,7 +572,7 @@ describe("m.mount()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
if (!init) ctx.onunload = onunload if (!init) ctx.onunload = onunload
}, }
} }
m.mount(root, pure(function () { return Comp })) m.mount(root, pure(function () { return Comp }))
@ -602,10 +602,10 @@ describe("m.mount()", function () {
m.redraw(true) m.redraw(true)
found = root.childNodes[0].childNodes[1] found = root.childNodes[0].childNodes[1]
m.redraw.strategy("none") m.redraw.strategy("none")
}, }
}, "asd"), }, "asd"),
a ? m("#a", "aaa") : null, a ? m("#a", "aaa") : null,
"test", "test"
]) ])
}) })
@ -614,7 +614,7 @@ describe("m.mount()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
if (!init) ctx.onunload = onunload if (!init) ctx.onunload = onunload
}, }
} }
m.mount(root, pure(function () { return Comp })) m.mount(root, pure(function () { return Comp }))
@ -634,7 +634,7 @@ describe("m.mount()", function () {
var root = mock.document.createElement("div") var root = mock.document.createElement("div")
var view = sinon.stub().returns(m("div", { var view = sinon.stub().returns(m("div", {
onclick: function () { m.redraw(true) }, onclick: function () { m.redraw(true) }
})) }))
m.mount(root, pure(view)) m.mount(root, pure(view))
@ -666,7 +666,7 @@ describe("m.mount()", function () {
this.foo = m.request({method: "GET", url: "/foo"}) this.foo = m.request({method: "GET", url: "/foo"})
}, },
view: view, view: view
} }
mount(root, pure(function () { return Comp })) mount(root, pure(function () { return Comp }))
@ -691,20 +691,20 @@ describe("m.mount()", function () {
controller: function () { controller: function () {
this.foo = m.request({method: "GET", url: "/foo"}) this.foo = m.request({method: "GET", url: "/foo"})
}, },
view: view1, view: view1
} }
var Comp2 = { var Comp2 = {
controller: function () { controller: function () {
this.bar = m.request({method: "GET", url: "/bar"}) this.bar = m.request({method: "GET", url: "/bar"})
}, },
view: view2, view: view2
} }
mount(root, pure(function () { mount(root, pure(function () {
return m("div", [ return m("div", [
Comp1, Comp1,
Comp2, Comp2
]) ])
})) }))
@ -751,7 +751,7 @@ describe("m.mount()", function () {
return m("div", { return m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}) })
}) })
@ -794,9 +794,9 @@ describe("m.mount()", function () {
ctrl.bar = true ctrl.bar = true
m.redraw(true) m.redraw(true)
el = root.childNodes[0].childNodes[1] el = root.childNodes[0].childNodes[1]
}, }
}, "click me"), }, "click me"),
ctrl.bar ? m.component(sub) : "", ctrl.bar ? m.component(sub) : ""
]) ])
})) }))

View file

@ -15,7 +15,7 @@ describe("m.redraw()", function () {
m.mount(root, { m.mount(root, {
controller: function () { ctx = this }, // eslint-disable-line controller: function () { ctx = this }, // eslint-disable-line
view: function (ctrl) { return ctrl.value }, view: function (ctrl) { return ctrl.value }
}) })
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()
@ -38,7 +38,7 @@ describe("m.redraw()", function () {
m.mount(root, { m.mount(root, {
controller: function () {}, controller: function () {},
view: view, view: view
}) })
mock.requestAnimationFrame.$resolve() // teardown mock.requestAnimationFrame.$resolve() // teardown
m.redraw() m.redraw()
@ -57,7 +57,7 @@ describe("m.redraw()", function () {
var view = sinon.spy() var view = sinon.spy()
m.mount(root, { m.mount(root, {
controller: function () {}, controller: function () {},
view: view, view: view
}) })
mock.requestAnimationFrame.$resolve() // teardown mock.requestAnimationFrame.$resolve() // teardown
m.redraw(true) m.redraw(true)
@ -88,7 +88,7 @@ describe("m.redraw()", function () {
function pure(view) { function pure(view) {
return { return {
controller: noop, controller: noop,
view: view, view: view
} }
} }
@ -138,8 +138,8 @@ describe("m.redraw()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
}, }
}) })
expect(strategy).to.equal("all") expect(strategy).to.equal("all")
@ -164,8 +164,8 @@ describe("m.redraw()", function () {
}, },
view: function () { view: function () {
return m("div", {config: config}) return m("div", {config: config})
}, }
}, }
}) })
route("/bar1") route("/bar1")
@ -185,10 +185,10 @@ describe("m.redraw()", function () {
strategy = m.redraw.strategy() strategy = m.redraw.strategy()
ctrl.number++ ctrl.number++
m.redraw.strategy("none") m.redraw.strategy("none")
}, }
}, ctrl.number) }, ctrl.number)
}, }
}, }
}) })
root.childNodes[0].onclick({}) root.childNodes[0].onclick({})
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()
@ -211,9 +211,9 @@ describe("m.redraw()", function () {
config: config, config: config,
onclick: function () { onclick: function () {
m.redraw.strategy("all") m.redraw.strategy("all")
}, }
}) })
}), })
}) })
root.childNodes[0].onclick({}) root.childNodes[0].onclick({})
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()

View file

@ -62,7 +62,7 @@ describe("m.render()", function () {
m.render(root, m("svg", [m("g")])) m.render(root, m("svg", [m("g")]))
expect(root.childNodes[0].childNodes[0]).to.contain.all.keys({ expect(root.childNodes[0].childNodes[0]).to.contain.all.keys({
nodeName: "G", 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.render(root, m("#foo", [
[m("div", "a"), m("div", "b")], [m("div", "a"), m("div", "b")],
[m("div", "c"), m("div", "d")], [m("div", "c"), m("div", "d")],
m("#bar"), m("#bar")
])) ]))
expect(root.childNodes[0].childNodes[3].childNodes[0].nodeValue) expect(root.childNodes[0].childNodes[3].childNodes[0].nodeValue)
@ -269,7 +269,7 @@ describe("m.render()", function () {
["a", "b", "c", "d"].map(function () { ["a", "b", "c", "d"].map(function () {
return [m("div"), " "] return [m("div"), " "]
}), }),
m("span"), m("span")
])) ]))
expect(root.childNodes[0].childNodes[8].nodeName).to.equal("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.render(root, m("#foo", [
[m("div", "a"), m("div", "b"), m("div", "c")], [m("div", "a"), m("div", "b"), m("div", "c")],
m("#bar"), m("#bar")
])) ]))
expect(root.childNodes[0].childNodes[2].childNodes[0].nodeValue) expect(root.childNodes[0].childNodes[2].childNodes[0].nodeValue)
@ -295,12 +295,12 @@ describe("m.render()", function () {
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), m("button"),
m("article", [m("section"), m("nav")]), m("article", [m("section"), m("nav")])
])) ]))
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), m("button"),
m("article", [m("span"), m("nav")]), m("article", [m("span"), m("nav")])
])) ]))
expect(root.childNodes[0].childNodes[1].childNodes[0].nodeName) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeName)
@ -313,12 +313,12 @@ describe("m.render()", function () {
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), m("button"),
m("article", [m("section"), m("nav")]), m("article", [m("section"), m("nav")])
])) ]))
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), m("button"),
m("article", ["test", m("nav")]), m("article", ["test", m("nav")])
])) ]))
expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue)
@ -331,12 +331,12 @@ describe("m.render()", function () {
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), m("button"),
m("article", [m("section"), m("nav")]), m("article", [m("section"), m("nav")])
])) ]))
m.render(root, m("main", [ m.render(root, m("main", [
m("button"), 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) expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue)
@ -550,7 +550,7 @@ describe("m.render()", function () {
var config = sinon.spy() var config = sinon.spy()
m.render(root, m("div", { 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})) m.render(root, m("div", {config: config}))
@ -564,7 +564,7 @@ describe("m.render()", function () {
var index = 0 var index = 0
var node = m("div", { 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]) m.render(root, [node, node])
@ -604,7 +604,7 @@ describe("m.render()", function () {
m.render(root, m("div", [ m.render(root, m("div", [
["foo", "bar"], ["foo", "bar"],
["foo", "bar"], ["foo", "bar"],
["foo", "bar"], ["foo", "bar"]
])) ]))
m.render(root, m("div", ["asdf", "asdf2", "asdf3"])) m.render(root, m("div", ["asdf", "asdf2", "asdf3"]))
@ -619,7 +619,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3)
]) ])
var firstBefore = root.childNodes[0] var firstBefore = root.childNodes[0]
@ -628,7 +628,7 @@ describe("m.render()", function () {
m("a", {key: 4}, 4), m("a", {key: 4}, 4),
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3)
]) ])
var firstAfter = root.childNodes[1] var firstAfter = root.childNodes[1]
@ -648,7 +648,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3)
]) ])
var firstBefore = root.childNodes[0] var firstBefore = root.childNodes[0]
@ -656,7 +656,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("a", {key: 4}, 4), m("a", {key: 4}, 4),
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2)
]) ])
var firstAfter = root.childNodes[1] var firstAfter = root.childNodes[1]
@ -676,7 +676,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3)
]) ])
var firstBefore = root.childNodes[1] var firstBefore = root.childNodes[1]
@ -684,7 +684,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3),
m("a", {key: 4}, 4), m("a", {key: 4}, 4)
]) ])
var firstAfter = root.childNodes[0] var firstAfter = root.childNodes[0]
@ -706,7 +706,7 @@ describe("m.render()", function () {
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3),
m("a", {key: 4}, 4), m("a", {key: 4}, 4),
m("a", {key: 5}, 5), m("a", {key: 5}, 5)
]) ])
var firstBefore = root.childNodes[0] var firstBefore = root.childNodes[0]
@ -717,7 +717,7 @@ describe("m.render()", function () {
m("a", {key: 4}, 4), m("a", {key: 4}, 4),
m("a", {key: 10}, 10), m("a", {key: 10}, 10),
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 2}, 2), m("a", {key: 2}, 2)
]) ])
var firstAfter = root.childNodes[2] var firstAfter = root.childNodes[2]
@ -740,7 +740,7 @@ describe("m.render()", function () {
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 3}, 3), m("a", {key: 3}, 3),
m("a", {key: 4}, 4), m("a", {key: 4}, 4),
m("a", {key: 5}, 5), m("a", {key: 5}, 5)
]) ])
var firstBefore = root.childNodes[0] var firstBefore = root.childNodes[0]
@ -753,7 +753,7 @@ describe("m.render()", function () {
m("a", {key: 2}, 2), m("a", {key: 2}, 2),
m("a", {key: 1}, 1), m("a", {key: 1}, 1),
m("a", {key: 6}, 6), m("a", {key: 6}, 6),
m("a", {key: 7}, 7), m("a", {key: 7}, 7)
]) ])
var firstAfter = root.childNodes[3] var firstAfter = root.childNodes[3]
@ -780,7 +780,7 @@ describe("m.render()", function () {
m("a", {key: 2}), m("a", {key: 2}),
m("a"), m("a"),
m("a", {key: 4}), m("a", {key: 4}),
m("a", {key: 5}), m("a", {key: 5})
]) ])
var firstBefore = root.childNodes[0] var firstBefore = root.childNodes[0]
@ -794,7 +794,7 @@ describe("m.render()", function () {
m("a", {key: 5}), m("a", {key: 5}),
m("a"), m("a"),
m("a", {key: 1}), m("a", {key: 1}),
m("a", {key: 2}), m("a", {key: 2})
]) ])
var firstAfter = root.childNodes[3] var firstAfter = root.childNodes[3]
@ -848,8 +848,8 @@ describe("m.render()", function () {
key: 1, key: 1,
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = spy ctx.onunload = spy
}, }
}), })
]) ])
m.render(root, [ m.render(root, [
m("div", {key: 2}), m("div", {key: 2}),
@ -857,8 +857,8 @@ describe("m.render()", function () {
key: 1, key: 1,
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = spy ctx.onunload = spy
}, }
}), })
]) ])
expect(spy).to.not.have.been.called expect(spy).to.not.have.been.called
}) })
@ -917,7 +917,7 @@ describe("m.render()", function () {
m.render(root, m("ul", [ m.render(root, m("ul", [
m("li", {key: 0}, 0), m("li", {key: 0}, 0),
m("li", {key: 2}, 2), m("li", {key: 2}, 2),
m("li", {key: 4}, 4), m("li", {key: 4}, 4)
])) ]))
m.render(root, m("ul", [ m.render(root, m("ul", [
@ -926,7 +926,7 @@ describe("m.render()", function () {
m("li", {key: 2}, 2), m("li", {key: 2}, 2),
m("li", {key: 3}, 3), m("li", {key: 3}, 3),
m("li", {key: 4}, 4), m("li", {key: 4}, 4),
m("li", {key: 5}, 5), m("li", {key: 5}, 5)
])) ]))
expect( expect(
@ -962,7 +962,7 @@ describe("m.render()", function () {
m("li", {key: 2}, 2), m("li", {key: 2}, 2),
m("li", {key: 3}, 3), m("li", {key: 3}, 3),
m("li", {key: 4}, 4), m("li", {key: 4}, 4),
m("li", {key: 5}, 5), m("li", {key: 5}, 5)
])) ]))
m.render(root, m("ul", [ m.render(root, m("ul", [
@ -970,7 +970,7 @@ describe("m.render()", function () {
m("li", {key: 1}, 1), m("li", {key: 1}, 1),
m("li", {key: 2}, 2), m("li", {key: 2}, 2),
m("li", {key: 4}, 4), m("li", {key: 4}, 4),
m("li", {key: 5}, 5), m("li", {key: 5}, 5)
])) ]))
expect( expect(
@ -990,7 +990,7 @@ describe("m.render()", function () {
m("li", {key: 2}, 2), m("li", {key: 2}, 2),
m("li", {key: 3}, 3), m("li", {key: 3}, 3),
m("li", {key: 4}, 4), m("li", {key: 4}, 4),
m("li", {key: 5}, 5), m("li", {key: 5}, 5)
])) ]))
m.render(root, m("ul", [ m.render(root, m("ul", [
@ -999,7 +999,7 @@ describe("m.render()", function () {
m("li", {key: 3}, 3), m("li", {key: 3}, 3),
m("li", {key: 4}, 4), m("li", {key: 4}, 4),
m("li", {key: 5}, 5), m("li", {key: 5}, 5),
m("li", {key: 6}, 6), m("li", {key: 6}, 6)
])) ]))
m.render(root, m("ul", [ m.render(root, m("ul", [
@ -1008,7 +1008,7 @@ describe("m.render()", function () {
m("li", {key: 14}, 14), m("li", {key: 14}, 14),
m("li", {key: 15}, 15), m("li", {key: 15}, 15),
m("li", {key: 16}, 16), m("li", {key: 16}, 16),
m("li", {key: 17}, 17), m("li", {key: 17}, 17)
])) ]))
expect( expect(
@ -1044,7 +1044,7 @@ describe("m.render()", function () {
m.render(root, [m("div", { m.render(root, [m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload1 ctx.onunload = onunload1
}, }
})]) })])
m.render(root, []) m.render(root, [])
@ -1052,7 +1052,7 @@ describe("m.render()", function () {
m.render(root, [m("div", { m.render(root, [m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload2 ctx.onunload = onunload2
}, }
})]) })])
m.render(root, []) m.render(root, [])
@ -1068,7 +1068,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("div.green", [m("div")]), m("div.green", [m("div")]),
m("div.blue"), m("div.blue")
]) ])
expect(root.childNodes).to.have.length(2) expect(root.childNodes).to.have.length(2)
@ -1102,7 +1102,7 @@ describe("m.render()", function () {
m("div", {key: 3}, 3), m("div", {key: 3}, 3),
m("div", {key: 4}, 4), m("div", {key: 4}, 4),
m("div", {key: 5}, 5), 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", [ m.render(root, m("div", [
@ -1115,7 +1115,7 @@ describe("m.render()", function () {
null, null, null, null,
m("div", {key: 12}, 12), m("div", {key: 12}, 12),
null, null, null, null,
m("div", {key: 15}, 15), m("div", {key: 15}, 15)
])) ]))
m.render(root, m("div", [ m.render(root, m("div", [
@ -1124,7 +1124,7 @@ describe("m.render()", function () {
m("div", {key: 3}, 3), m("div", {key: 3}, 3),
m("div", {key: 4}, 4), m("div", {key: 4}, 4),
m("div", {key: 5}, 5), 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( expect(
@ -1145,9 +1145,9 @@ describe("m.render()", function () {
[ [
m("div", {key: 3}, 3), m("div", {key: 3}, 3),
m("div", {key: 4}, 4), 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", [ m.render(root, m("div", [
@ -1156,9 +1156,9 @@ describe("m.render()", function () {
[ [
m("div", {key: 3}, 3), m("div", {key: 3}, 3),
m("div", {key: 4}, 4), 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( expect(
@ -1183,7 +1183,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("#div-1", {key: 1}), m("#div-1", {key: 1}),
m("#div-2", {key: 2}), m("#div-2", {key: 2}),
m("#div-3", {key: 3}), m("#div-3", {key: 3})
]) ])
root.appendChild(root.childNodes[1]) root.appendChild(root.childNodes[1])
@ -1191,7 +1191,7 @@ describe("m.render()", function () {
m.render(root, [ m.render(root, [
m("#div-1", {key: 1}), m("#div-1", {key: 1}),
m("#div-3", {key: 3}), m("#div-3", {key: 3}),
m("#div-2", {key: 2}), m("#div-2", {key: 2})
]) ])
expect( expect(
@ -1228,7 +1228,7 @@ describe("m.render()", function () {
m("a", {key: 1}), m("a", {key: 1}),
m("a", {key: 2}), m("a", {key: 2}),
m("a", {key: 3}), m("a", {key: 3}),
m("i"), m("i")
])) ]))
var before = root.childNodes[0].childNodes[3] var before = root.childNodes[0].childNodes[3]
@ -1236,7 +1236,7 @@ describe("m.render()", function () {
m("b", {key: 3}), m("b", {key: 3}),
m("b", {key: 4}), m("b", {key: 4}),
m("i"), m("i"),
m("b", {key: 1}), m("b", {key: 1})
])) ]))
var after = root.childNodes[0].childNodes[2] var after = root.childNodes[0].childNodes[2]
@ -1251,7 +1251,7 @@ describe("m.render()", function () {
m("a", {key: 2}), m("a", {key: 2}),
"foo", "foo",
m("a", {key: 3}), m("a", {key: 3}),
m("i"), m("i")
])) ]))
var before = root.childNodes[0].childNodes[4] var before = root.childNodes[0].childNodes[4]
@ -1260,7 +1260,7 @@ describe("m.render()", function () {
m("a", {key: 4}), m("a", {key: 4}),
"bar", "bar",
m("i"), m("i"),
m("a", {key: 1}), m("a", {key: 1})
])) ]))
var after = root.childNodes[0].childNodes[3] var after = root.childNodes[0].childNodes[3]
@ -1275,7 +1275,7 @@ describe("m.render()", function () {
m("a", {key: 2}), m("a", {key: 2}),
null, null,
m("a", {key: 3}), m("a", {key: 3}),
m("i"), m("i")
])) ]))
var before = root.childNodes[0].childNodes[4] var before = root.childNodes[0].childNodes[4]
@ -1284,7 +1284,7 @@ describe("m.render()", function () {
m("a", {key: 4}), m("a", {key: 4}),
null, null,
m("i"), m("i"),
m("a", {key: 1}), m("a", {key: 1})
])) ]))
var after = root.childNodes[0].childNodes[3] var after = root.childNodes[0].childNodes[3]
@ -1299,7 +1299,7 @@ describe("m.render()", function () {
m("a", {key: 2}), m("a", {key: 2}),
undefined, undefined,
m("a", {key: 3}), m("a", {key: 3}),
m("i"), m("i")
])) ]))
var before = root.childNodes[0].childNodes[4] var before = root.childNodes[0].childNodes[4]
@ -1308,7 +1308,7 @@ describe("m.render()", function () {
m("a", {key: 4}), m("a", {key: 4}),
undefined, undefined,
m("i"), m("i"),
m("a", {key: 1}), m("a", {key: 1})
])) ]))
var after = root.childNodes[0].childNodes[3] var after = root.childNodes[0].childNodes[3]
@ -1325,7 +1325,7 @@ describe("m.render()", function () {
m("a", {key: 2}), m("a", {key: 2}),
m.trust("a"), m.trust("a"),
m("a", {key: 3}), m("a", {key: 3}),
m("i"), m("i")
])) ]))
var before = root.childNodes[0].childNodes[4] var before = root.childNodes[0].childNodes[4]
@ -1334,7 +1334,7 @@ describe("m.render()", function () {
m("a", {key: 4}), m("a", {key: 4}),
m.trust("a"), m.trust("a"),
m("i"), m("i"),
m("a", {key: 1}), m("a", {key: 1})
])) ]))
var after = root.childNodes[0].childNodes[3] var after = root.childNodes[0].childNodes[3]
@ -1360,7 +1360,7 @@ describe("m.render()", function () {
m.render(root, m("div", {}, [ m.render(root, m("div", {}, [
m("div", {}, "0"), m("div", {}, "0"),
m("div", {}, "1"), m("div", {}, "1"),
m("div", {}, "2"), m("div", {}, "2")
])) ]))
expect( expect(
@ -1370,7 +1370,7 @@ describe("m.render()", function () {
).to.eql(["0", "1", "2"]) ).to.eql(["0", "1", "2"])
m.render(root, m("div", {}, [ m.render(root, m("div", {}, [
m("div", {}, "0"), m("div", {}, "0")
])) ]))
expect( expect(
@ -1385,7 +1385,7 @@ describe("m.render()", function () {
m.render(root, m("span", {}, [ m.render(root, m("span", {}, [
m("div", {}, "0"), m("div", {}, "0"),
m("div", {}, "1"), m("div", {}, "1"),
m("div", {}, "2"), m("div", {}, "2")
])) ]))
expect( expect(
@ -1395,7 +1395,7 @@ describe("m.render()", function () {
).to.eql(["0", "1", "2"]) ).to.eql(["0", "1", "2"])
m.render(root, m("span", {}, [ m.render(root, m("span", {}, [
m("div", {}, "0"), m("div", {}, "0")
])) ]))
expect( expect(
@ -1420,9 +1420,9 @@ describe("m.render()", function () {
view: function (ctrl) { view: function (ctrl) {
return m("input", { return m("input", {
value: ctrl.inputValue(), value: ctrl.inputValue(),
onkeyup: m.withAttr("value", ctrl.inputValue), onkeyup: m.withAttr("value", ctrl.inputValue)
}) })
}, }
}) })
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()
@ -1466,11 +1466,11 @@ describe("m.render()", function () {
return m("form", {onsubmit: ctrl.submit}, [ return m("form", {onsubmit: ctrl.submit}, [
m("input", { m("input", {
onkeyup: m.withAttr("value", ctrl.inputValue), 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] var form = root.childNodes[0]
@ -1511,7 +1511,7 @@ describe("m.render()", function () {
view: function (ctrl) { view: function (ctrl) {
return m("select", { return m("select", {
size: ctrl.values.length, size: ctrl.values.length,
multiple: "multiple", multiple: "multiple"
}, [ }, [
ctrl.values.map(function (v) { ctrl.values.map(function (v) {
var opts = {value: v} var opts = {value: v}
@ -1519,9 +1519,9 @@ describe("m.render()", function () {
opts.selected = "selected" opts.selected = "selected"
} }
return m("option", opts, v) return m("option", opts, v)
}), })
]) ])
}, }
}) })
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()

View file

@ -21,12 +21,12 @@ describe("m.request()", function () {
it("sets the correct properties on `GET`", function () { it("sets the correct properties on `GET`", function () {
var prop = request({ var prop = request({
method: "GET", method: "GET",
url: "test", url: "test"
}) })
expect(prop()).to.contain.keys({ expect(prop()).to.contain.keys({
method: "GET", method: "GET",
url: "test", url: "test"
}) })
}) })
@ -49,12 +49,12 @@ describe("m.request()", function () {
var prop = request({ var prop = request({
method: "POST", method: "POST",
url: "http://domain.com:80", url: "http://domain.com:80",
data: {}, data: {}
}) })
expect(prop()).to.contain.keys({ expect(prop()).to.contain.keys({
method: "POST", method: "POST",
url: "http://domain.com:80", url: "http://domain.com:80"
}) })
}) })
@ -62,7 +62,7 @@ describe("m.request()", function () {
expect(request({ expect(request({
method: "POST", method: "POST",
url: "http://domain.com:80/:test1", url: "http://domain.com:80/:test1",
data: {test1: "foo"}, data: {test1: "foo"}
})().url).to.equal("http://domain.com:80/foo") })().url).to.equal("http://domain.com:80/foo")
}) })
@ -72,7 +72,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "GET", method: "GET",
url: "test", url: "test",
deserialize: function () { throw new Error("error occurred") }, deserialize: function () { throw new Error("error occurred") }
}).then(null, error) }).then(null, error)
resolve() resolve()
@ -86,7 +86,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "GET", method: "GET",
url: "test", url: "test",
deserialize: function () { throw new Error("error occurred") }, deserialize: function () { throw new Error("error occurred") }
}).catch(error) }).catch(error)
resolve() resolve()
@ -99,7 +99,7 @@ describe("m.request()", function () {
var data = m.prop() var data = m.prop()
var prop = m.request({ var prop = m.request({
method: "GET", method: "GET",
url: "test", url: "test"
}) })
.then(function () { return "foo" }) .then(function () { return "foo" })
.finally(data) .finally(data)
@ -142,7 +142,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "GET", method: "GET",
url: "test", url: "test",
deserialize: function () { throw new Error("error occurred") }, deserialize: function () { throw new Error("error occurred") }
}) })
.catch(error) .catch(error)
.finally(function () { error("finally") }) .finally(function () { error("finally") })
@ -158,7 +158,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "GET", method: "GET",
url: "test", url: "test",
deserialize: function () { throw new TypeError("error occurred") }, deserialize: function () { throw new TypeError("error occurred") }
}).then(null, error) }).then(null, error)
try { try {
@ -178,7 +178,7 @@ describe("m.request()", function () {
m.request({ m.request({
method: "POST", method: "POST",
url: "test", url: "test",
data: {foo: 1}, data: {foo: 1}
}).then(null, error) }).then(null, error)
var xhr = mock.XMLHttpRequest.$instances.pop() var xhr = mock.XMLHttpRequest.$instances.pop()
@ -194,7 +194,7 @@ describe("m.request()", function () {
m.request({ m.request({
method: "POST", method: "POST",
url: "test", url: "test"
}).then(null, error) }).then(null, error)
var xhr = mock.XMLHttpRequest.$instances.pop() var xhr = mock.XMLHttpRequest.$instances.pop()
@ -207,7 +207,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "POST", method: "POST",
url: "test", url: "test",
initialValue: "foo", initialValue: "foo"
}) })
var initialValue = prop() var initialValue = prop()
@ -220,7 +220,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "POST", method: "POST",
url: "test", url: "test",
initialValue: "foo", initialValue: "foo"
}).then(function (value) { return value }) }).then(function (value) { return value })
var initialValue = prop() var initialValue = prop()
@ -233,7 +233,7 @@ describe("m.request()", function () {
var prop = m.request({ var prop = m.request({
method: "POST", method: "POST",
url: "test", url: "test",
initialValue: "foo", initialValue: "foo"
}).then(function () { return "bar" }) }).then(function () { return "bar" })
resolve() resolve()
@ -290,7 +290,7 @@ describe("m.request()", function () {
url: "/test", url: "/test",
dataType: "jsonp", dataType: "jsonp",
data: data, data: data,
callbackKey: callbackKey, callbackKey: callbackKey
}) })
} }

View file

@ -15,11 +15,11 @@ describe("m.route.buildQueryString()", function () {
foo: "bar", foo: "bar",
hello: ["world", "mars", "mars"], hello: ["world", "mars", "mars"],
world: { world: {
test: 3, test: 3
}, },
bam: "", bam: "",
yup: null, yup: null,
removed: undefined, removed: undefined
}) })
).to.equal("foo=bar&hello=world&hello=mars&world%5Btest%5D=3&bam=&yup") ).to.equal("foo=bar&hello=world&hello=mars&world%5Btest%5D=3&bam=&yup")
}) })

View file

@ -13,7 +13,7 @@ describe("m.route()", function () {
var types = { var types = {
search: "?", search: "?",
hash: "#", hash: "#",
pathname: "/", pathname: "/"
} }
return function (type) { return function (type) {
@ -32,7 +32,7 @@ describe("m.route()", function () {
function pure(view) { function pure(view) {
return { return {
controller: noop, controller: noop,
view: view, view: view
} }
} }
@ -74,7 +74,7 @@ describe("m.route()", function () {
mode("search") mode("search")
route(root, "/test1", { route(root, "/test1", {
"/test1": pure(function () { return "foo" }), "/test1": pure(function () { return "foo" })
}) })
expect(mock.location.search).to.equal("?/test1") expect(mock.location.search).to.equal("?/test1")
@ -88,12 +88,12 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": { "/": {
controller: function () { route1 = m.route() }, controller: function () { route1 = m.route() },
view: noop, view: noop
}, },
"/test13": { "/test13": {
controller: function () { route2 = m.route() }, controller: function () { route2 = m.route() },
view: noop, view: noop
}, }
}) })
m.route("/test13") m.route("/test13")
@ -113,7 +113,7 @@ describe("m.route()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
route(root, "/a", { route(root, "/a", {
@ -121,8 +121,8 @@ describe("m.route()", function () {
"/b": { "/b": {
controller: spy, controller: spy,
view: noop, view: noop
}, }
}) })
route("/b") route("/b")
@ -142,7 +142,7 @@ describe("m.route()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
var sub = pure(function () { return subsub }) var sub = pure(function () { return subsub })
@ -152,8 +152,8 @@ describe("m.route()", function () {
"/b": { "/b": {
controller: spy, controller: spy,
view: noop, view: noop
}, }
}) })
route("/b") route("/b")
@ -173,7 +173,7 @@ describe("m.route()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
route(root, "/a", { route(root, "/a", {
@ -181,8 +181,8 @@ describe("m.route()", function () {
"/b": { "/b": {
controller: spy, controller: spy,
view: noop, view: noop
}, }
}) })
route("/b") route("/b")
@ -202,7 +202,7 @@ describe("m.route()", function () {
}, },
view: function () { view: function () {
return m("div") return m("div")
}, }
} }
var sub = pure(function () { return subsub }) var sub = pure(function () { return subsub })
@ -212,8 +212,8 @@ describe("m.route()", function () {
"/b": { "/b": {
controller: spy, controller: spy,
view: noop, view: noop
}, }
}) })
route("/b") route("/b")
@ -229,26 +229,26 @@ describe("m.route()", function () {
var sub1 = { var sub1 = {
controller: ctrl1, controller: ctrl1,
view: function () { return m("div") }, view: function () { return m("div") }
} }
var sub2 = { var sub2 = {
controller: ctrl2, controller: ctrl2,
view: function () { return m("div") }, view: function () { return m("div") }
} }
route(root, "/a", { route(root, "/a", {
"/a": pure(function () { "/a": pure(function () {
return m(".page-a", [ return m(".page-a", [
m("h1"), m.component(sub1, {x: 11}), m("h1"), m.component(sub1, {x: 11})
]) ])
}), }),
"/b": pure(function () { "/b": pure(function () {
return m(".page-b", [ return m(".page-b", [
m("h2"), m.component(sub2, {y: 22}), m("h2"), m.component(sub2, {y: 22})
]) ])
}), })
}) })
route("/b") route("/b")
@ -264,7 +264,7 @@ describe("m.route()", function () {
var Component = pure(function () { return m(".comp") }) var Component = pure(function () { return m(".comp") })
route(root, "/foo", { route(root, "/foo", {
"/foo": pure(function () { return [Component] }), "/foo": pure(function () { return [Component] })
}) })
expect(root.childNodes[0].nodeName).to.equal("DIV") expect(root.childNodes[0].nodeName).to.equal("DIV")
@ -279,7 +279,7 @@ describe("m.route()", function () {
view: function (ctrl) { view: function (ctrl) {
return m("div", ctrl.name) return m("div", ctrl.name)
}, }
} }
route(root, "/", { route(root, "/", {
@ -287,7 +287,7 @@ describe("m.route()", function () {
return m("div", [ return m("div", [
m("a[href=/]", {config: m.route}, "foo"), m("a[href=/]", {config: m.route}, "foo"),
m("a[href=/bar]", {config: m.route}, "bar"), 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", [ return m("div", [
m("a[href=/]", {config: m.route}, "foo"), m("a[href=/]", {config: m.route}, "foo"),
m("a[href=/bar]", {config: m.route}, "bar"), m("a[href=/bar]", {config: m.route}, "bar"),
m.component(MyComponent, {name: "Bob"}), m.component(MyComponent, {name: "Bob"})
]) ])
}), })
}) })
route("/bar") route("/bar")
@ -313,9 +313,9 @@ describe("m.route()", function () {
"/test2": pure(function () { "/test2": pure(function () {
return [ return [
"foo", "foo",
m("a", {href: "/test2", config: m.route}, "Test2"), m("a", {href: "/test2", config: m.route}, "Test2")
] ]
}), })
}) })
expect(mock.location.pathname).to.equal("/test2") expect(mock.location.pathname).to.equal("/test2")
@ -327,7 +327,7 @@ describe("m.route()", function () {
mode("hash") mode("hash")
route(root, "/test3", { route(root, "/test3", {
"/test3": pure(function () { return "foo" }), "/test3": pure(function () { return "foo" })
}) })
expect(mock.location.hash).to.equal("#/test3") expect(mock.location.hash).to.equal("#/test3")
@ -338,7 +338,7 @@ describe("m.route()", function () {
mode("search") mode("search")
route(root, "/test4/foo", { 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") expect(mock.location.search).to.equal("?/test4/foo")
@ -357,7 +357,7 @@ describe("m.route()", function () {
m.route(root, "/test5/foo", { m.route(root, "/test5/foo", {
"/": component, "/": component,
"/test5/:test": component, "/test5/:test": component
}) })
var paramValueBefore = m.route.param("test") var paramValueBefore = m.route.param("test")
@ -381,7 +381,7 @@ describe("m.route()", function () {
m.route(root, "/test6/foo", { m.route(root, "/test6/foo", {
"/": component, "/": component,
"/test6/:a1": component, "/test6/:a1": component
}) })
var paramValueBefore = m.route.param("a1") var paramValueBefore = m.route.param("a1")
@ -406,7 +406,7 @@ describe("m.route()", function () {
m.route(root, "/test7/foo", { m.route(root, "/test7/foo", {
"/": component, "/": component,
"/test7/:a1": component, "/test7/:a1": component
}) })
var routeValueBefore = m.route() var routeValueBefore = m.route()
@ -428,7 +428,7 @@ describe("m.route()", function () {
route(root, "/test8/foo/SEP/bar/baz", { route(root, "/test8/foo/SEP/bar/baz", {
"/test8/:test/SEP/:path...": pure(function () { "/test8/:test/SEP/:path...": pure(function () {
return m.route.param("test") + "_" + m.route.param("path") return m.route.param("test") + "_" + m.route.param("path")
}), })
}) })
expect(mock.location.search).to.equal("?/test8/foo/SEP/bar/baz") 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", { route(root, "/test9/foo/bar/SEP/baz", {
"/test9/:test.../SEP/:path": pure(function () { "/test9/:test.../SEP/:path": pure(function () {
return m.route.param("test") + "_" + m.route.param("path") return m.route.param("test") + "_" + m.route.param("path")
}), })
}) })
expect(mock.location.search).to.equal("?/test9/foo/bar/SEP/baz") expect(mock.location.search).to.equal("?/test9/foo/bar/SEP/baz")
@ -454,7 +454,7 @@ describe("m.route()", function () {
route(root, "/test10/foo%20bar", { route(root, "/test10/foo%20bar", {
"/test10/:test": pure(function () { "/test10/:test": pure(function () {
return m.route.param("test") return m.route.param("test")
}), })
}) })
expect(root.childNodes[0].nodeValue).to.equal("foo bar") expect(root.childNodes[0].nodeValue).to.equal("foo bar")
@ -465,7 +465,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(function () { return "foo" }), "/": pure(function () { return "foo" }),
"/test11": pure(function () { return "bar" }), "/test11": pure(function () { return "bar" })
}) })
route("/test11/") route("/test11/")
@ -479,7 +479,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(noop), "/": pure(noop),
"/test12": pure(noop), "/test12": pure(noop)
}) })
route("/test12?a=foo&b=bar") route("/test12?a=foo&b=bar")
@ -496,7 +496,7 @@ describe("m.route()", function () {
"/": pure(function () { return "bar" }), "/": pure(function () { return "bar" }),
"/test13/:test": pure(function () { "/test13/:test": pure(function () {
return m.route.param("test") return m.route.param("test")
}), })
}) })
route("/test13/foo?test=bar") route("/test13/foo?test=bar")
@ -510,7 +510,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(function () { return "bar" }), "/": pure(function () { return "bar" }),
"/test14": pure(function () { return "foo" }), "/test14": pure(function () { return "foo" })
}) })
route("/test14?test&test2=") route("/test14?test&test2=")
@ -525,7 +525,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(noop), "/": pure(noop),
"/test12": pure(noop), "/test12": pure(noop)
}) })
route("/test12", {a: "foo", b: "bar"}) route("/test12", {a: "foo", b: "bar"})
@ -540,7 +540,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(noop), "/": pure(noop),
"/test12": pure(noop), "/test12": pure(noop)
}) })
route("/test12", {a: "foo", b: "bar"}) route("/test12", {a: "foo", b: "bar"})
@ -562,10 +562,10 @@ describe("m.route()", function () {
return m("div", { return m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}) })
}), }),
"/test14": pure(noop), "/test14": pure(noop)
}) })
route("/test14") route("/test14")
@ -585,11 +585,11 @@ describe("m.route()", function () {
m("div", { m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), }),
"/test15": pure(function () { return [m("div")] }), "/test15": pure(function () { return [m("div")] })
}) })
route("/test15") route("/test15")
@ -607,10 +607,10 @@ describe("m.route()", function () {
return m("div", { return m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}) })
}), }),
"/test16": pure(function () { return m("a") }), "/test16": pure(function () { return m("a") })
}) })
route("/test16") route("/test16")
@ -629,11 +629,11 @@ describe("m.route()", function () {
m("div", { m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), }),
"/test17": pure(function () { return m("a") }), "/test17": pure(function () { return m("a") })
}) })
route("/test17") route("/test17")
@ -651,10 +651,10 @@ describe("m.route()", function () {
return m("div", { return m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}) })
}), }),
"/test18": pure(function () { return [m("a")] }), "/test18": pure(function () { return [m("a")] })
}) })
route("/test18") route("/test18")
@ -674,8 +674,8 @@ describe("m.route()", function () {
key: 1, key: 1,
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), }),
"/test20": pure(function () { "/test20": pure(function () {
@ -684,10 +684,10 @@ describe("m.route()", function () {
key: 2, key: 2,
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), })
}) })
route("/test20") route("/test20")
@ -707,8 +707,8 @@ describe("m.route()", function () {
key: 1, key: 1,
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), }),
"/test21": pure(function () { "/test21": pure(function () {
@ -716,10 +716,10 @@ describe("m.route()", function () {
m("div", { m("div", {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.onunload = onunload ctx.onunload = onunload
}, }
}), })
] ]
}), })
}) })
route("/test21") route("/test21")
@ -732,7 +732,7 @@ describe("m.route()", function () {
route(root, "/foo", { route(root, "/foo", {
"/foo": pure(function () { return m("div", "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 var foo = root.childNodes[0].childNodes[0].nodeValue
@ -757,7 +757,7 @@ describe("m.route()", function () {
}), }),
"/bar1": pure(function () { "/bar1": pure(function () {
return m("main", m("a", {config: config}, "foo")) return m("main", m("a", {config: config}, "foo"))
}), })
}) })
route("/bar1") route("/bar1")
@ -774,8 +774,8 @@ describe("m.route()", function () {
controller: function () { value = m.route.param("arg") }, controller: function () { value = m.route.param("arg") },
view: function () { view: function () {
return "" return ""
}, }
}, }
}) })
expect(value).to.equal("foo+bar") expect(value).to.equal("foo+bar")
}) })
@ -785,7 +785,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(function () { return "foo" }), "/": pure(function () { return "foo" }),
"/test22": pure(function () { return "bar" }), "/test22": pure(function () { return "bar" })
}) })
m.route("/test22/") m.route("/test22/")
@ -799,7 +799,7 @@ describe("m.route()", function () {
route(root, "/", { route(root, "/", {
"/": pure(function () { return "foo" }), "/": pure(function () { return "foo" }),
"/test23": pure(function () { return "bar" }), "/test23": pure(function () { return "bar" })
}) })
route(new String("/test23/")) // eslint-disable-line no-new-wrappers 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") }, controller: function () { value = m.route.param("arg") },
view: function () { view: function () {
return "" return ""
}, }
}, }
}) })
expect(value).to.equal("foo+bar") expect(value).to.equal("foo+bar")
}) })
@ -832,8 +832,8 @@ describe("m.route()", function () {
controller: function () { value = m.route.param("arg") }, controller: function () { value = m.route.param("arg") },
view: function () { view: function () {
return "" return ""
}, }
}, }
}) })
expect(value).to.equal("foo+bar") expect(value).to.equal("foo+bar")
@ -845,10 +845,10 @@ describe("m.route()", function () {
route(root, "/a", { route(root, "/a", {
"/a": { "/a": {
controller: function () { m.route("/b") }, 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") expect(root.childNodes[0].nodeValue).to.equal("b")
@ -862,9 +862,9 @@ describe("m.route()", function () {
controller: function () { controller: function () {
m.route("/b?foo=1", {foo: 2}) 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") expect(mock.location.search).to.equal("?/b?foo=2")
@ -876,7 +876,7 @@ describe("m.route()", function () {
route(root, "/a", { route(root, "/a", {
"/a": pure(function () { return "a" }), "/a": pure(function () { return "a" }),
"/b": pure(function () { return "b" }), "/b": pure(function () { return "b" })
}) })
route("/b") route("/b")
@ -890,7 +890,7 @@ describe("m.route()", function () {
route(root, "/a", { route(root, "/a", {
"/a": pure(function () { return "a" }), "/a": pure(function () { return "a" }),
"/b": pure(function () { return "b" }), "/b": pure(function () { return "b" })
}) })
route("/a") route("/a")
@ -908,13 +908,13 @@ describe("m.route()", function () {
return m("a", { return m("a", {
config: function (el, init) { config: function (el, init) {
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": pure(a.view), "/b": pure(a.view)
}) })
route("/b") route("/b")
@ -931,13 +931,13 @@ describe("m.route()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.retain = false ctx.retain = false
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": pure(a.view), "/b": pure(a.view)
}) })
route("/b") route("/b")
@ -954,13 +954,13 @@ describe("m.route()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.retain = true ctx.retain = true
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": pure(a.view), "/b": pure(a.view)
}) })
route("/b") route("/b")
@ -984,7 +984,7 @@ describe("m.route()", function () {
}), }),
"/b": pure(function () { "/b": pure(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
route("/b") route("/b")
@ -1006,7 +1006,7 @@ describe("m.route()", function () {
}), }),
"/b": pure(function () { "/b": pure(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
route("/b") route("/b")
@ -1028,7 +1028,7 @@ describe("m.route()", function () {
}), }),
"/b": pure(function () { "/b": pure(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
route("/b") route("/b")
@ -1042,7 +1042,7 @@ describe("m.route()", function () {
function diff(view) { function diff(view) {
return { return {
controller: function () { m.redraw.strategy("diff") }, controller: function () { m.redraw.strategy("diff") },
view: view, view: view
} }
} }
@ -1055,13 +1055,13 @@ describe("m.route()", function () {
return m("a", { return m("a", {
config: function (el, init) { config: function (el, init) {
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": diff(a.view), "/b": diff(a.view)
}) })
route("/b") route("/b")
@ -1078,13 +1078,13 @@ describe("m.route()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.retain = true ctx.retain = true
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": diff(a.view), "/b": diff(a.view)
}) })
route("/b") route("/b")
@ -1101,13 +1101,13 @@ describe("m.route()", function () {
config: function (el, init, ctx) { config: function (el, init, ctx) {
ctx.retain = false ctx.retain = false
if (!init) initCount++ if (!init) initCount++
}, }
}) })
}) })
route(root, "/a", { route(root, "/a", {
"/a": a, "/a": a,
"/b": diff(a.view), "/b": diff(a.view)
}) })
route("/b") route("/b")
@ -1131,7 +1131,7 @@ describe("m.route()", function () {
}), }),
"/b": diff(function () { "/b": diff(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
route("/b") route("/b")
@ -1154,7 +1154,7 @@ describe("m.route()", function () {
}), }),
"/b": diff(function () { "/b": diff(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
route("/b") route("/b")
@ -1177,7 +1177,7 @@ describe("m.route()", function () {
}), }),
"/b": diff(function () { "/b": diff(function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}), })
}) })
m.route("/b") m.route("/b")
@ -1204,12 +1204,12 @@ describe("m.route()", function () {
controller: function () { m.redraw.strategy("diff") }, controller: function () { m.redraw.strategy("diff") },
view: function () { view: function () {
return m("section", m("a", {config: config})) return m("section", m("a", {config: config}))
}, }
} }
route(root, "/a", { route(root, "/a", {
"/a": pure(function () { return m("div", a) }), "/a": pure(function () { return m("div", a) }),
"/b": pure(function () { return m("div", b) }), "/b": pure(function () { return m("div", b) })
}) })
route("/b") route("/b")
@ -1226,10 +1226,10 @@ describe("m.route()", function () {
return m("div", { return m("div", {
config: function (el) { config: function (el) {
el.childNodes[0].modified = true el.childNodes[0].modified = true
}, }
}, m("div")) }, m("div"))
}), }),
"/b": pure(function () { return m("div", m("div")) }), "/b": pure(function () { return m("div", m("div")) })
}) })
route("/b") route("/b")

View file

@ -18,7 +18,7 @@ describe("m.route.parseQueryString()", function () {
foo: "bar", foo: "bar",
hello: ["world", "mars"], hello: ["world", "mars"],
bam: "", bam: "",
yup: null, yup: null
}) })
}) })
@ -28,7 +28,7 @@ describe("m.route.parseQueryString()", function () {
expect(args).to.eql({ expect(args).to.eql({
foo: "bar", foo: "bar",
"hello[]": ["world", "mars", "pluto"], "hello[]": ["world", "mars", "pluto"]
}) })
}) })
}) })

View file

@ -12,7 +12,7 @@ describe("m.startComputation(), m.endComputation()", function () {
var root = mock.document.createElement("div") var root = mock.document.createElement("div")
var controller = m.mount(root, { var controller = m.mount(root, {
controller: function () {}, controller: function () {},
view: function (ctrl) { return ctrl.value }, view: function (ctrl) { return ctrl.value }
}) })
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()

View file

@ -36,7 +36,7 @@ describe("m.trust()", function () {
var root = document.createElement("div") var root = document.createElement("div")
m.render(root, [ m.render(root, [
m.trust("<p>1</p>123<p>2</p>"), m.trust("<p>1</p>123<p>2</p>"),
m("i", "foo"), m("i", "foo")
]) ])
expect(root.childNodes[3].tagName).to.equal("I") expect(root.childNodes[3].tagName).to.equal("I")
}) })
@ -49,7 +49,7 @@ describe("m.trust()", function () {
m.render(root, [ m.render(root, [
m.trust("<td>1</td><td>2</td>"), m.trust("<td>1</td><td>2</td>"),
m("td", "foo"), m("td", "foo")
]) ])
expect(root.childNodes[2].tagName).to.equal("td") expect(root.childNodes[2].tagName).to.equal("td")

View file

@ -57,20 +57,20 @@ m.render(document.getElementById("test"), [
height: 100, height: 100,
width: 100, width: 100,
transform: "translate(30) rotate(45 50 50)", 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]", { 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("svg[height=201px][width=201px]", [
m("image[href='http://placekitten.com/201/201']", { m("image[href='http://placekitten.com/201/201']", {
height: "200px", height: "200px",
width: "200px", width: "200px",
title: "Cat picture", title: "Cat picture"
}), })
]), ]),
m("svg[title='Line drawings']", { m("svg[title='Line drawings']", {
"enable-background": "new 0 0 340 333", "enable-background": "new 0 0 340 333",
@ -78,7 +78,7 @@ m.render(document.getElementById("test"), [
viewBox: "0 0 340 333", viewBox: "0 0 340 333",
width: "340px", width: "340px",
x: "0px", x: "0px",
y: "0px", y: "0px"
}, [ }, [
m("path.path", { m("path.path", {
d: [ d: [
@ -94,13 +94,13 @@ m.render(document.getElementById("test"), [
"s 11 -61 -11 -80", "s 11 -61 -11 -80",
"s -79 -7 -70 -41", "s -79 -7 -70 -41",
"C 46.039,146.545,53.039,128.545,66.039,133.545", "C 46.039,146.545,53.039,128.545,66.039,133.545",
"z", "z"
].join(" "), ].join(" "),
fill: "#FFFFFF", fill: "#FFFFFF",
stroke: "#000000", stroke: "#000000",
"stroke-miterlimit": 10, "stroke-miterlimit": 10,
"stroke-width": 4, "stroke-width": 4
}), })
]), ]),
m("svg[height=270px][width=270px][viewBox='0 0 270 270']", [ m("svg[height=270px][width=270px][viewBox='0 0 270 270']", [
m("g[transform='translate(150,150)'][title=Clock]", [ m("g[transform='translate(150,150)'][title=Clock]", [
@ -109,7 +109,7 @@ m.render(document.getElementById("test"), [
r: 108, r: 108,
fill: "none", fill: "none",
"stroke-width": 4, "stroke-width": 4,
stroke: "gray", stroke: "gray"
}), }),
m("circle", { m("circle", {
r: 97, r: 97,
@ -117,7 +117,7 @@ m.render(document.getElementById("test"), [
"stroke-width": 11, "stroke-width": 11,
stroke: "black", stroke: "black",
"stroke-dasharray": "4,46.789082", "stroke-dasharray": "4,46.789082",
transform: "rotate(-1.5)", transform: "rotate(-1.5)"
}), }),
m("circle", { m("circle", {
r: 100, r: 100,
@ -125,8 +125,8 @@ m.render(document.getElementById("test"), [
"stroke-width": 5, "stroke-width": 5,
stroke: "black", stroke: "black",
"stroke-dasharray": "2,8.471976", "stroke-dasharray": "2,8.471976",
transform: "rotate(-.873)", transform: "rotate(-.873)"
}), })
]), ]),
m("g[transform='rotate(180)']", [ m("g[transform='rotate(180)']", [
m("g#hour", [ m("g#hour", [
@ -135,15 +135,15 @@ m.render(document.getElementById("test"), [
y2: 75, y2: 75,
"stroke-linecap": "round", "stroke-linecap": "round",
stroke: "blue", stroke: "blue",
opacity: 0.5, opacity: 0.5
}), }),
m("animateTransform[attributeName=transform]", { m("animateTransform[attributeName=transform]", {
type: "rotate", type: "rotate",
repeatCount: "indefinite", repeatCount: "indefinite",
dur: "12h", dur: "12h",
by: 360, by: 360
}), }),
m("circle[r=7]"), m("circle[r=7]")
]), ]),
m("g#minute", [ m("g#minute", [
m("line", { m("line", {
@ -151,15 +151,15 @@ m.render(document.getElementById("test"), [
y2: 93, y2: 93,
"stroke-linecap": "round", "stroke-linecap": "round",
stroke: "green", stroke: "green",
opacity: 0.9, opacity: 0.9
}), }),
m("animateTransform[attributeName=transform]", { m("animateTransform[attributeName=transform]", {
type: "rotate", type: "rotate",
repeatCount: "indefinite", repeatCount: "indefinite",
dur: "60min", dur: "60min",
by: 360, by: 360
}), }),
m("circle[r=6][fill=red]"), m("circle[r=6][fill=red]")
]), ]),
m("g#second", [ m("g#second", [
m("line", { m("line", {
@ -167,17 +167,17 @@ m.render(document.getElementById("test"), [
y1: -20, y1: -20,
y2: 102, y2: 102,
"stroke-linecap": "round", "stroke-linecap": "round",
stroke: "red", stroke: "red"
}), }),
m("animateTransform[attributeName=transform]", { m("animateTransform[attributeName=transform]", {
type: "rotate", type: "rotate",
repeatCount: "indefinite", repeatCount: "indefinite",
dur: "60s", dur: "60s",
by: 360, by: 360
}), }),
m("circle[r=4][fill=blue]"), m("circle[r=4][fill=blue]")
]), ])
]), ])
]), ]),
m("script", "(" + function () { m("script", "(" + function () {
"use strict" "use strict"
@ -195,7 +195,7 @@ m.render(document.getElementById("test"), [
rotate("hour", 30 * (hours + minutes / 60 + seconds / 3600)) rotate("hour", 30 * (hours + minutes / 60 + seconds / 3600))
rotate("minute", 6 * (minutes + seconds / 60)) rotate("minute", 6 * (minutes + seconds / 60))
rotate("second", 6 * seconds) rotate("second", 6 * seconds)
}.toString() + ")()"), }.toString() + ")()")
]), ]),
m("svg[height=200px][width=200px]", [ m("svg[height=200px][width=200px]", [
m("foreignObject", { m("foreignObject", {
@ -203,12 +203,12 @@ m.render(document.getElementById("test"), [
y: 0, y: 0,
width: "100px", width: "100px",
height: "100px", height: "100px",
transform: "translate(0,0)", transform: "translate(0,0)"
}, m("div", {xmlns: "http://www.w3.org/1999/xhtml"}, [ }, m("div", {xmlns: "http://www.w3.org/1999/xhtml"}, [
m.trust("this is a piece of html rendered as " + m.trust("this is a piece of html rendered as " +
"<a href=\"http://www.w3.org/TR/SVG11/extend.html\">" + "<a href=\"http://www.w3.org/TR/SVG11/extend.html\">" +
"SVG foreignObject</a>"), "SVG foreignObject</a>")
])), ]))
]), ])
]) ])
</script> </script>