class {
    onMount() {
        this.detachEvent = undefined;
    }

    handleDetach(event, node) {
        event.preventDefault();
        this.detachEvent = event;
    }
}

<div.root on-detach('handleDetach')>I'm here!</div>
