From 808f926d20a0221f9da528047c08903b97750628 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 16 Aug 2014 18:04:45 -0400 Subject: [PATCH] add test for #200 --- tests/mithril-tests.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index efd48313..7d7687c2 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -720,6 +720,30 @@ function testMithril(mock) { m.render(root, m("div", [m("div")])) return root.childNodes[0].childNodes.length == 1 }) + test(function() { + //https://github.com/lhorie/mithril.js/issues/200 + var root = mock.document.createElement("div") + + var unloaded1 = false + function unloadable1(element, isInit, context) { + context.onunload = function() { + unloaded1 = true + } + } + m.render(root, [ m("div", {config: unloadable1}) ]) + m.render(root, [ ]) + + var unloaded2 = false + function unloadable2(element, isInit, context) { + context.onunload = function() { + unloaded2 = true + } + } + m.render(root, [ m("div", {config: unloadable2}) ]) + m.render(root, [ ]) + + return unloaded1 === true && unloaded2 === true + }) //end m.render //m.redraw