diff --git a/docs/change-log.md b/docs/change-log.md index 26f6c18c..ccc10706 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -18,6 +18,7 @@ #### Bug fixes - core: render() function can no longer prevent from changing `document.activeElement` in lifecycle hooks ([#1988](https://github.com/MithrilJS/mithril.js/pull/1988), [@purplecode](https://github.com/purplecode)) +- 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 e1f9e201..c053517d 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++) {