File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
apps/docs/src/examples/composables/use-mutation-observer Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22 import { useMutationObserver } from ' @vuetify/v0'
3- import { ref , useTemplateRef } from ' vue'
3+ import { ref , shallowRef , useTemplateRef } from ' vue'
44
55 interface MutationEntry {
66 type: string
99
1010 const target = useTemplateRef <HTMLElement >(' target' )
1111 const mutations = ref <MutationEntry []>([])
12- const childCount = ref (0 )
12+ const childCount = shallowRef (0 )
13+ const activeChildren = shallowRef (0 )
1314
1415 const { isPaused, pause, resume } = useMutationObserver (
1516 target ,
6061 child .textContent = ` Child ${childCount .value } `
6162 child .className = ' px-3 py-1 rounded bg-surface-variant text-on-surface-variant text-sm'
6263 el .append (child )
64+ activeChildren .value ++
6365 }
6466
6567 function onRemoveChild () {
6668 const el = target .value
6769 if (! el ?.lastElementChild ) return
6870 el .lastElementChild .remove ()
71+ activeChildren .value --
6972 }
7073
7174 function onToggleAttribute () {
116119 class =" min-h-16 p-3 rounded-lg border-2 border-dashed border-divider flex flex-wrap gap-2 items-start"
117120 >
118121 <span
119- v-if =" !target?.children.length "
122+ v-if =" activeChildren === 0 "
120123 class =" text-sm text-on-surface-variant opacity-60"
121124 >
122125 Add children to observe mutations
You can’t perform that action at this time.
0 commit comments