diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-08 15:07:07 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-08 15:19:39 +0100 |
commit | afb9fba64be1f15a3ce3ed31214a704e73e5e8bb (patch) | |
tree | 6f69712a8c976178c05144483ff0c8e9b09445c8 /thirdparty/preact/src/vdom/component.js | |
parent | b37e7762bb5492cbd6788863232e7d2634ab5e5c (diff) | |
parent | 6e5fb04d3f3f9a6cd43ac20896d73321dd079f96 (diff) | |
download | wallet-core-afb9fba64be1f15a3ce3ed31214a704e73e5e8bb.tar.xz |
Update preact version
Diffstat (limited to 'thirdparty/preact/src/vdom/component.js')
-rw-r--r-- | thirdparty/preact/src/vdom/component.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/thirdparty/preact/src/vdom/component.js b/thirdparty/preact/src/vdom/component.js index bb2e4fa5d..64e7ff81f 100644 --- a/thirdparty/preact/src/vdom/component.js +++ b/thirdparty/preact/src/vdom/component.js @@ -154,11 +154,11 @@ export function renderComponent(component, opts, mountAll, isChild) { let baseParent = initialBase.parentNode; if (baseParent && base!==baseParent) { baseParent.replaceChild(base, initialBase); - } - if (!cbase && !toUnmount && component._parentComponent) { - initialBase._component = null; - recollectNodeTree(initialBase); + if (!toUnmount) { + initialBase._component = null; + recollectNodeTree(initialBase); + } } } @@ -170,7 +170,9 @@ export function renderComponent(component, opts, mountAll, isChild) { if (base && !isChild) { let componentRef = component, t = component; - while ((t=t._parentComponent)) { componentRef = t; } + while ((t=t._parentComponent)) { + (componentRef = t).base = base; + } base._component = componentRef; base._componentConstructor = componentRef.constructor; } @@ -179,8 +181,11 @@ export function renderComponent(component, opts, mountAll, isChild) { if (!isUpdate || mountAll) { mounts.unshift(component); } - else if (!skip && component.componentDidUpdate) { - component.componentDidUpdate(previousProps, previousState, previousContext); + else if (!skip) { + if (component.componentDidUpdate) { + component.componentDidUpdate(previousProps, previousState, previousContext); + } + if (options.afterUpdate) options.afterUpdate(component); } let cb = component._renderCallbacks, fn; @@ -218,7 +223,11 @@ export function buildComponentFromVNode(dom, vnode, context, mountAll) { } c = createComponent(vnode.nodeName, props, context); - if (dom && !c.nextBase) c.nextBase = dom; + if (dom && !c.nextBase) { + c.nextBase = dom; + // passing dom/oldDom as nextBase will recycle it if unused, so bypass recycling on L241: + oldDom = null; + } setComponentProps(c, props, SYNC_RENDER, context, mountAll); dom = c.base; @@ -239,6 +248,8 @@ export function buildComponentFromVNode(dom, vnode, context, mountAll) { * @private */ export function unmountComponent(component, remove) { + if (options.beforeUnmount) options.beforeUnmount(component); + // console.log(`${remove?'Removing':'Unmounting'} component: ${component.constructor.name}`); let base = component.base; |