From 1da69da4dd86707475c241eac1285dbdf76ad993 Mon Sep 17 00:00:00 2001 From: Jared Morrow Date: Thu, 27 Jul 2017 13:54:04 -0600 Subject: [PATCH 1/6] docs: Fix mismatched brace in Authentication example (#1917) --- docs/route.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/route.md b/docs/route.md index 16a08eec..a8f7a2fe 100644 --- a/docs/route.md +++ b/docs/route.md @@ -568,7 +568,7 @@ var Login = { return m("form", [ m("input[type=text]", {oninput: m.withAttr("value", Auth.setUsername), value: Auth.username}), m("input[type=password]", {oninput: m.withAttr("value", Auth.setPassword), value: Auth.password}), - m("button[type=button]", {onclick: Auth.login, "Login") + m("button[type=button]", {onclick: Auth.login}, "Login") ]) } } From da6122753c93d1b8fece23f3d402a6b95ee2778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Mon, 31 Jul 2017 11:39:36 +0200 Subject: [PATCH 2/6] Add tests for issue 1921 (onremove fires on childrent that don't end up in the instance) --- render/tests/test-onremove.js | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/render/tests/test-onremove.js b/render/tests/test-onremove.js index a7f88a6b..f509e704 100644 --- a/render/tests/test-onremove.js +++ b/render/tests/test-onremove.js @@ -89,6 +89,7 @@ o.spec("onremove", function() { o(vnode.dom.onremove).equals(undefined) o(vnode.dom.attributes["onremove"]).equals(undefined) + o(vnode.events).equals(undefined) }) o("calls onremove on recycle", function() { var remove = o.spy() @@ -150,6 +151,46 @@ o.spec("onremove", function() { o(spy.callCount).equals(1) }) + o("doesn't call onremove on children when the corresponding view returns null (after removing the parent)", function() { + var threw = false + var spy = o.spy() + var parent = createComponent({ + view: function() {} + }) + var child = createComponent({ + view: function() {}, + onremove: spy + }) + render(root, {tag: parent, children: [child]}) + try { + render(root, null) + } catch (e) { + threw = e + } + + o(spy.callCount).equals(0) + o(threw).equals(false) + }) + o("doesn't call onremove on children when the corresponding view returns null (after removing the children)", function() { + var threw = false + var spy = o.spy() + var parent = createComponent({ + view: function() {} + }) + var child = createComponent({ + view: function() {}, + onremove: spy + }) + render(root, {tag: parent, children: [child]}) + try { + render(root, {tag: parent}) + } catch (e) { + threw = true + } + + o(spy.callCount).equals(0) + o(threw).equals(false) + }) }) }) }) \ No newline at end of file From c96e08579973fcbee1800163fafd2c25944992a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Mon, 31 Jul 2017 11:48:15 +0200 Subject: [PATCH 3/6] core: don't call onremove on the children passed to components that return from their view, fix #1921 --- docs/change-log.md | 1 + render/render.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index cb2fabf0..9df82039 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -24,6 +24,7 @@ #### Bug fixes - API: `m.route.set()` causes all mount points to be redrawn ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592)) +- core: don't call `onremove` on the children of components that return null from the view [#1921](https://github.com/MithrilJS/mithril.js/issues/1921) [octavore](https://github.com/octavore) ([#1922](https://github.com/MithrilJS/mithril.js/pull/1922)) --- diff --git a/render/render.js b/render/render.js index e24a76eb..6bebd212 100644 --- a/render/render.js +++ b/render/render.js @@ -451,9 +451,10 @@ module.exports = function($window) { } function onremove(vnode) { if (vnode.attrs && typeof vnode.attrs.onremove === "function") vnode.attrs.onremove.call(vnode.state, vnode) - if (typeof vnode.tag !== "string" && typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode) - if (vnode.instance != null) onremove(vnode.instance) - else { + if (typeof vnode.tag !== "string") { + if (typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode) + if (vnode.instance != null) onremove(vnode.instance) + } else { var children = vnode.children if (Array.isArray(children)) { for (var i = 0; i < children.length; i++) { From 6f77450d03d997da80e9a344648e4d06fab40f14 Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Mon, 31 Jul 2017 10:15:31 +0000 Subject: [PATCH 4/6] Bundled output for commit 157fb7d446ff097f98b1582ada3526d12de6600d [skip ci] --- mithril.js | 7 ++++--- mithril.min.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mithril.js b/mithril.js index 6fbf4ff8..77e3c6d9 100644 --- a/mithril.js +++ b/mithril.js @@ -806,9 +806,10 @@ var coreRenderer = function($window) { } function onremove(vnode) { if (vnode.attrs && typeof vnode.attrs.onremove === "function") vnode.attrs.onremove.call(vnode.state, vnode) - if (typeof vnode.tag !== "string" && typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode) - if (vnode.instance != null) onremove(vnode.instance) - else { + if (typeof vnode.tag !== "string") { + if (typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode) + if (vnode.instance != null) onremove(vnode.instance) + } else { var children = vnode.children if (Array.isArray(children)) { for (var i = 0; i < children.length; i++) { diff --git a/mithril.min.js b/mithril.min.js index c9fd686f..c68ee276 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -27,7 +27,7 @@ a.text):(null!=c.text&&(c.children=[z("#",void 0,void 0,c.text,void 0,c.dom.firs a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=c.instance?(y(c.instance,null),a.dom=void 0,a.domSize=0):(a.dom=c.dom,a.domSize=c.domSize)}}else y(c,null),e(k,a,b,m,d)}function r(a){var c=a.domSize;if(null!=c||null==a.dom){var b=x.createDocumentFragment();if(0 Date: Mon, 31 Jul 2017 12:28:40 +0200 Subject: [PATCH 5/6] Move the #1921/#1922 line into the v1.1.4 change set --- docs/change-log.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/change-log.md b/docs/change-log.md index 9df82039..64c727c8 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -1,5 +1,7 @@ # Change log +- [v2.0.0](#v113) +- [v1.1.4](#v113) - [v1.1.3](#v113) - [v1.1.2](#v112) - [v1.1.1](#v111) @@ -24,6 +26,13 @@ #### Bug fixes - API: `m.route.set()` causes all mount points to be redrawn ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592)) + +--- + +### v1.1.4 + +#### Bug fixes: + - core: don't call `onremove` on the children of components that return null from the view [#1921](https://github.com/MithrilJS/mithril.js/issues/1921) [octavore](https://github.com/octavore) ([#1922](https://github.com/MithrilJS/mithril.js/pull/1922)) --- From fecee45a829efe225f74b300fa1e312dba2601ca Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Mon, 31 Jul 2017 06:38:36 -0400 Subject: [PATCH 6/6] Add me as a `render/` owner [skip ci] --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 30c39524..ab8484ef 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -9,3 +9,4 @@ package.json @tivac README.md @tivac docs/ @tivac performance/ @tivac +render/ @isiahmeadows