Search code examples
javascriptvue.jshotjar

element.nextSibling returns first sibling


So I have a Vue app, with HotJar included.
Everything used to work fine but then I upgraded some packages
Now when I navigate between pages, my browser freezes and then crashes
After a little bit of investigation, I noticed that it's getting stuck in HotJar's code.
They have this little loop that iterate on siblings using

for (let f = someElement; !!f; f = f.nextSibling) { 
  //Some code
}

The problem is that somehow, when it iterates over elements, sometime nextSibling returns the first sibling which is extremely odd and results in an infinite loop.

Anyone has any clue how can I proceed from this?
Changing the code to nextElementSibling from nextSibling solves the issue, but this call is inside HotJar code and I really rather not download and change their code


Solution

  • Okay, so it appears it happened because I used 'vue-fragment'
    The package is overriding default 'nextSibling' property of Node and some other. I resolved it by rolling back to a version where they didn't add this override.