diff --git a/mithril.js b/mithril.js index b3b260fd..419ca4fd 100644 --- a/mithril.js +++ b/mithril.js @@ -86,7 +86,7 @@ Mithril = m = new function app(window) { cached.nodes.intact = true if (shouldReattach === true) parentElement.insertBefore(node, parentElement.childNodes[index] || null) } - if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew) + if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew, cached.config_context=cached.config_context || {}) } else { var node diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index a8c03e3d..c9ecbbf7 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -45,3 +45,20 @@ test('issue99 regression', function() { m.render(dummyEl, view2); equal(dummyEl.innerHTML, '
0
', 'view2 should be rendered correctly'); }); + + +test('config handler context', function() { + expect(3); + var view = m('div', {config: function(evt, isInitialized, context){ + equal(context instanceof Object, true); + context.data = 1; + }}) + m.render(dummyEl, view); + + var view = m('div', {config: function(evt, isInitialized, context){ + equal(context instanceof Object, true); + equal(context.data, 1); + }}) + m.render(dummyEl, view); + +})