Skip to content

fix: missing vue special method #169

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Oct 24, 2024
Merged

Conversation

wilsonwangme
Copy link
Contributor

First, thanks for this project for helping old projects' migration ♥️.
I got a bug while using this project to migrate my project because there has some code like below:

@Component
export default class Test extends Vue {
    created() {
        document.addEventListener('mousedown', onMousedown);
    }
    onMousedown() {
        console.log('mousedown');
    }
    beforeDestroy() {
        document.removeEventListener('mousedown', onMousedown);
    }
}

this code was migrated into below:

import { defineComponent } from "vue";

export default defineComponent({
    created() {
        document.addEventListener('mousedown', onMousedown);
    },
    methods() {
        onMousedown() {
            console.log('mousedown');
        },
        beforeDestroy() {
            document.removeEventListener('mousedown', onMousedown);
        }
    }
})

This will miss the event unregister after the component destroyed because the special method "beforeDestroy" was incorrectly migrated into methods. It cause unexpected event handles in my project.

So I create this PR to fix this bug about "beforeDestroy" using.

@victorcuena victorcuena merged commit 244b09e into getyourguide:main Oct 24, 2024
@victorcuena
Copy link
Collaborator

Thanks a lot for the PR 🫶🏻

@wilsonwangme wilsonwangme deleted the patch-1 branch October 26, 2024 14:17
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants