allow m.redraw(true) to force-render component
This commit is contained in:
parent
cd403225a2
commit
2d5d042131
2 changed files with 30 additions and 3 deletions
|
|
@ -1339,6 +1339,32 @@ function testMithril(mock) {
|
|||
|
||||
return initialized === false
|
||||
})
|
||||
test(function() {
|
||||
var root = mock.document.createElement("div")
|
||||
var el
|
||||
var FooPage = {
|
||||
view: function(ctrl) {
|
||||
return m('div', [
|
||||
m('button', {onclick: function() {
|
||||
ctrl.bar = true;
|
||||
m.redraw(true);
|
||||
el = root.childNodes[0].childNodes[1]
|
||||
}}, 'click me'),
|
||||
ctrl.bar ? m.component(BarComponent) : ''
|
||||
]);
|
||||
}
|
||||
};
|
||||
var BarComponent = {
|
||||
view: function() {
|
||||
return m('#bar', 'test');
|
||||
}
|
||||
};
|
||||
m.mount(root, FooPage);
|
||||
|
||||
root.childNodes[0].childNodes[0].onclick({})
|
||||
|
||||
return el.id == "bar"
|
||||
})
|
||||
|
||||
//m.withAttr
|
||||
test(function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue