-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
Description
Describe the bug
There is a modal component that uses v-if
to control the rendering of the modal element. The goal is to use useCssVar
to add CSS variables to the modal element when the modal opens. However, even though a target
is bound, the CSS variable is still being added to document.documentElement
instead of the expected element.
After examining the source code, I found that when the target
cannot retrieve an element, elRef
always returns document.documentElement. Therefore, I would like to suggest adding a check logic for target
, such as:
const elRef = computed(() => {
return target === undefined
? window?.document?.documentElement
: unrefElement(target)
})
Reproduction
System Info
System:
OS: Windows 10 10.0.19045
CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
Memory: 9.41 GB / 31.86 GB
Binaries:
Node: 22.7.0 - F:\Program Files\nodejs\node.EXE
npm: 10.8.2 - F:\Program Files\nodejs\npm.CMD
pnpm: 9.12.1 - ~\AppData\Local\pnpm\pnpm.CMD
Browsers:
Chrome: 106.0.5249.119
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.19041.4355
npmPackages:
@vueuse/core: ^13.0.0 => 13.0.0
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.