Create CONTRIBUTING.md

I added the following to it:

- Bug reporting
- Feature requests
- Contributing guide
- Style guide
This commit is contained in:
Isiah Meadows 2015-11-07 06:34:11 -05:00 committed by impinball
parent df114a4ee2
commit 9fab2b8371
18 changed files with 1209 additions and 352 deletions

View file

@ -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())),
])
])
]);
}
});
]),
]),
])
},
})
</script>

View file

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

View file

@ -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) : "",
])
}))

View file

@ -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()

View file

@ -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()

View file

@ -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,
})
}

View file

@ -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")
})

View file

@ -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")

View file

@ -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"],
})
})
})

View file

@ -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()

View file

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

View file

@ -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 " +
"<a href=\"http://www.w3.org/TR/SVG11/extend.html\">" +
"SVG foreignObject</a>")
]))
])
"SVG foreignObject</a>"),
])),
]),
])
</script>