diff --git a/src/components/Node.vue b/src/components/Node.vue index e1686e3..4e61363 100644 --- a/src/components/Node.vue +++ b/src/components/Node.vue @@ -17,24 +17,21 @@ const unregister = inject(UnregisterNodeInjectionKey, () => {}); const node = ref(null); const parentNode = computed(() => node.value && node.value.parentElement); -if (register && unregister) { - watch([parentNode, props.id], ([newNode, newID], [prevNode, prevID]) => { - if (prevNode) { - unregister(unref(prevID)); - } - if (newNode) { - register(newID, newNode); - } - }); +watch([parentNode, props.id], ([newNode, newID], [prevNode, prevID]) => { + if (prevNode) { + unregister(unref(prevID)); + } + if (newNode) { + register(newID, newNode); + } +}); - onUnmounted(() => unregister(unref(props.id))); -} +onUnmounted(() => unregister(unref(props.id)));