Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmount of component not called? #14

Closed
zaceno opened this issue Apr 24, 2018 · 3 comments
Closed

Unmount of component not called? #14

zaceno opened this issue Apr 24, 2018 · 3 comments
Labels

Comments

@zaceno
Copy link

zaceno commented Apr 24, 2018

Hi!

See here: https://codepen.io/zaceno/pen/WJwmge

I'm essentially trying to define a component <FadeOut> which ... you guessed it: fades out it's content.

My idea was to make a basic "pass-through" component like this:

class FadeOut {
    mount(_, child) {
        this.vnode = child
        return mount(child)
    }
    patch (_, __, ___, child) {
        var oldVNode = this.vnode
        this.vnode = child
        return patch(this.vnode, oldVNode)
    }
    unmount (el) {
        console.log('UNMOUNTING', this)
    }
}

...And then (hopefully) I would somehow be able to access the element of the child (perhaps by capturing it earlier in mount or patch) so I could fade it out slowly before removing it for real.

But apparently unmount is not even called! Is this a bug, or am I missing something?

@yelouafi
Copy link
Owner

This is a bug; the lib should call unmount on the old vnode when replacing elements

petit-dom/src/vdom.js

Lines 222 to 226 in 5412b18

} else {
childNode = mount(newch);
if (parent) {
parent.replaceChild(childNode, oldch._node);
}

@yelouafi yelouafi added the bug label Apr 25, 2018
@zaceno
Copy link
Author

zaceno commented Apr 25, 2018

Ok thanks! Glad to know I'm not completely off the trail at least 😄

@yelouafi
Copy link
Owner

should be fixed in v 0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants