vueuse / vueuse

Collection of essential Vue Composition Utilities for Vue 2 and 3

Home Page:https://vueuse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useMediaControls watch `target` that may not be a Ref

jcc1997 opened this issue · comments

commented

Describe the bug

target: MaybeRef<HTMLMediaElement | null | undefined> maybe just an element. But not Ref.

so codes below watching target causes warnings.

watch([target, volume], () => {
const el = toValue(target)
if (!el)
return
el.volume = volume.value
})
watch([target, muted], () => {
const el = toValue(target)
if (!el)
return
el.muted = muted.value
})
watch([target, rate], () => {
const el = toValue(target)
if (!el)
return
el.playbackRate = rate.value
})

image

Reproduction

https://stackblitz.com/edit/vitejs-vite-liqyke?file=src%2FApp.vue

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 81.46 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 4.0.2 - ~/.nvm/versions/node/v18.18.2/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  Browsers:
    Chrome: 123.0.6312.107
    Edge: 123.0.2420.81
    Safari: 17.2.1
  npmPackages:
    @vueuse/components: ^10.7.2 => 10.7.2 
    @vueuse/core: ^10.9.0 => 10.9.0 
    @vueuse/router: ^10.7.2 => 10.7.2 
    vue: ^3.4.21 => 3.4.21

Used Package Manager

yarn

Validations