vue-sticky-directive icon indicating copy to clipboard operation
vue-sticky-directive copied to clipboard

TypeError: Cannot destructure property 'parentNode' of 'this.placeholderEl' as it is undefined

Open STsaruk opened this issue 5 years ago • 2 comments

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."

STsaruk avatar May 30 '20 08:05 STsaruk

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

STsaruk avatar May 30 '20 11:05 STsaruk

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 ...

isuke01 avatar Mar 11 '21 15:03 isuke01