diff --git a/src/lib/setup/base.js b/src/lib/setup/base.js index ff1c49c4..d4dab80e 100644 --- a/src/lib/setup/base.js +++ b/src/lib/setup/base.js @@ -272,11 +272,15 @@ export default (component, name) => { const deleteChildren = function (children) { for (let i = 0; i < children.length; i++) { if (!children[i]) return - if (Array.isArray(children[i])) { - deleteChildren(children[i]) - } else if (children[i].destroy) { + // call destroy when method is available on child + if (children[i].destroy && typeof children[i].destroy === 'function') { children[i].destroy() } + // recursively call deleteChildren when it's an object of items (happens when using a forloop construct) + else if (Object.getPrototypeOf(children[i]) === Object.prototype) { + deleteChildren(Object.values(children[i])) + } + children[i] = null } diff --git a/src/router/router.js b/src/router/router.js index dfc3dd23..e097417c 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -253,13 +253,6 @@ const removeView = async (route, view, transition) => { if (route.options && route.options.keepAlive === true) { cacheMap.set(route, { view: view, focus: previousFocus }) } else { - // remove and cleanup - for (let i = 0; i < view[symbols.children].length; i++) { - // if (view[symbols.children][i] && view[symbols.children][i].destroy) { - // view[symbols.children][i].destroy() - view[symbols.children][i] = null - // } - } view.destroy() view = null }