vue-sticky-directive
vue-sticky-directive copied to clipboard
TypeError: Cannot destructure property 'parentNode' of 'this.placeholderEl' as it is undefined
when I try to disable sticky when resizing to mobile v-sticky="!isMobile" - an error appears:
vue.esm.js?a026:628 [Vue warn]: Error in directive sticky componentUpdated hook: "TypeError: Cannot destructure property 'parentNode' of 'this.placeholderEl' as it is undefined."
it was my mistake, I defined the variable on the mounted hook instead of created, but, I think, the directive needs to be secured with additional checks so that such an error does not occur in any case
Funny store I have same error but I dont have anything hooked with hooks.
I just tried to use in on nuxt and when I come from page without sticky element to page with it this error appear ;)
Code is just missing some checks like if element exists and (typeof el.getBoundingClientRect === "function")
It was in my case by double iF
I had
<aside v-if="pageHasSidebar">
<floatingMenu v-if="pageHasFloatingMenu"></floatingMenu>
....
</aside>
I changed second v-if to v-show and looks it fixed the issue. But I'd preffer to use v-if ...