-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding an empty class throws error with @vueuse/head #15488
Comments
it seems, setting bodyClass.value = window.top.scrollY > 100 ? 'fixed-header' : 'something'; but what if i do not want a class at all? |
Can confirm it's an issue, can't upgrade to v3.0.0 because of it. It definitely seems to be Unlike @codeflorist, I do not seem to have these errors in RC 13 though. |
I have the same problem with this code: But if you specify a non-empty class, then it is never deleted. |
facing same issue even it not empty, work fine in RC11 useHead({
bodyAttrs: {
class: computed(() => {return isNavActive.value ? 'active-navbar-body':'none'})
},
})
|
I have the same issue when setting body class to an empty String
Can confirm that this workaround helps:
It just appears on Body Element, not on others. |
cc @harlan-zw |
Hey everyone, so this is indeed a bug and a fix is vailable in @vueuse/head 1.0.18. You can upgrade by deleting lock file / node_modules and re-installing or manually adding this version. Let me know if you have any issues with that. Additionally, I'd recommend you switch to the new class API, which would look like this: useHead({
class: {
'overflow-hidden': isMobile
}
}) <template>
<Body :class="{ 'overflow-hidden': isMobile }" />
</template> Similar to the Vue class API. You can also make use of the DOM events API to clean up your code too. const isFixedHeader = ref(false)
useHead({
bodyAttrs: {
onscroll: (e) => { isFixedHeader.value = window.top.scrollY > 100 },
class: {
['fixed-header']: isFixedHeader
}
},
}) Please consult the unhead documentation to read more about the new features https://unhead.harlanzw.com/ |
Please avoid wrapping useHead({ htmlAttrs: { class: { overflow: () => props.modelValue } }); |
Environment
Linux
v16.14.2
3.0.0-rc.14
1.0.0
npm@7.17.0
vite
-
-
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-kn7cz5?file=package.json
Describe the bug
This app.vue:
...throws the following error in console:
Furthermore, the class
fixed-header
gets correctly set when scrolling down, but does not get removed, when scrolling up again.The problem was introduced in RC12 and persists up to RC14. RC11 does not throw the error and removes the class correctly.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: