Merge remote-tracking branch 'origin/next' into next
This commit is contained in:
commit
721d56db4c
4 changed files with 51 additions and 8 deletions
|
|
@ -548,7 +548,7 @@ Mithril = m = new function app(window, undefined) {
|
||||||
var context = arguments[2]
|
var context = arguments[2]
|
||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
context.href = element.getAttribute("href")
|
context.href = element.getAttribute("href")
|
||||||
element.href = window.location.pathname + modes[m.route.mode] + context.href
|
element.href = (m.route.mode !== 'pathname' ? window.location.pathname : '') + modes[m.route.mode] + context.href
|
||||||
element.removeEventListener("click", routeUnobtrusive)
|
element.removeEventListener("click", routeUnobtrusive)
|
||||||
element.addEventListener("click", routeUnobtrusive)
|
element.addEventListener("click", routeUnobtrusive)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,6 @@ test('node identity shuffle and remove', function() {
|
||||||
|
|
||||||
asyncTest('issue214 regression', function() {
|
asyncTest('issue214 regression', function() {
|
||||||
// see https://github.com/lhorie/mithril.js/issues/214
|
// see https://github.com/lhorie/mithril.js/issues/214
|
||||||
// this test will pass using phantomjs, because phantomjs
|
|
||||||
// doesn't provide window.requestAnimationFrame
|
|
||||||
expect(2)
|
expect(2)
|
||||||
|
|
||||||
function controller() {
|
function controller() {
|
||||||
|
|
@ -328,8 +326,6 @@ asyncTest('issue214 regression', function() {
|
||||||
|
|
||||||
asyncTest('issue288 regression', function() {
|
asyncTest('issue288 regression', function() {
|
||||||
// see https://github.com/lhorie/mithril.js/issues/288
|
// see https://github.com/lhorie/mithril.js/issues/288
|
||||||
// this test will pass using phantomjs, because phantomjs
|
|
||||||
// doesn't provide window.requestAnimationFrame
|
|
||||||
expect(2)
|
expect(2)
|
||||||
|
|
||||||
function controller() {
|
function controller() {
|
||||||
|
|
@ -365,3 +361,38 @@ asyncTest('issue288 regression', function() {
|
||||||
start()
|
start()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('issue278 regression', function() {
|
||||||
|
// see https://github.com/lhorie/mithril.js/issues/278
|
||||||
|
expect(1)
|
||||||
|
|
||||||
|
var test = {
|
||||||
|
controller: function() {
|
||||||
|
this.values = [1, 2, 3, 4, 5]
|
||||||
|
this.value = m.prop([2, 3])
|
||||||
|
},
|
||||||
|
|
||||||
|
view: function(ctrl) {
|
||||||
|
return m('select#testselect', {
|
||||||
|
size: ctrl.values.length,
|
||||||
|
multiple: 'multiple'
|
||||||
|
}, [
|
||||||
|
ctrl.values.map(function(v){
|
||||||
|
var opts = {value: v}
|
||||||
|
if (ctrl.value().indexOf(v) !== -1) opts.selected = 'selected'
|
||||||
|
return m('option', opts, v)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m.render(dummyEl, test.view(new test.controller))
|
||||||
|
|
||||||
|
var select = document.getElementById('testselect')
|
||||||
|
|
||||||
|
for (var i = 0, selected = 0; i < select.options.length; i++) {
|
||||||
|
if (select.options[i].selected) selected++
|
||||||
|
}
|
||||||
|
|
||||||
|
equal(selected, 2)
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -861,10 +861,20 @@ function testMithril(mock) {
|
||||||
var root = mock.document.createElement("div")
|
var root = mock.document.createElement("div")
|
||||||
m.route.mode = "pathname"
|
m.route.mode = "pathname"
|
||||||
m.route(root, "/test2", {
|
m.route(root, "/test2", {
|
||||||
"/test2": {controller: function() {}, view: function() {return "foo"}}
|
"/test2": {
|
||||||
|
controller: function() {},
|
||||||
|
view: function() {
|
||||||
|
return [
|
||||||
|
"foo",
|
||||||
|
m("a", { href: "/test2", config: m.route }, "Test2")
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
mock.requestAnimationFrame.$resolve() //teardown
|
mock.requestAnimationFrame.$resolve() //teardown
|
||||||
return mock.location.pathname == "/test2" && root.childNodes[0].nodeValue === "foo"
|
return mock.location.pathname == "/test2" &&
|
||||||
|
root.childNodes[0].nodeValue === "foo" &&
|
||||||
|
root.childNodes[1].href == "/test2"
|
||||||
})
|
})
|
||||||
test(function() {
|
test(function() {
|
||||||
mock.requestAnimationFrame.$resolve() //setup
|
mock.requestAnimationFrame.$resolve() //setup
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ mock.window = new function() {
|
||||||
},
|
},
|
||||||
getAttribute: function(name, value) {
|
getAttribute: function(name, value) {
|
||||||
return this[name]
|
return this[name]
|
||||||
}
|
},
|
||||||
|
addEventListener: function () {},
|
||||||
|
removeEventListener: function () {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.document.createElementNS = function(namespace, tag) {
|
window.document.createElementNS = function(namespace, tag) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue