Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Error on endTour(true) -- TypeError: Cannot read property 'removeChild' of null #296

Open
steveaft opened this issue Jul 26, 2016 · 3 comments · May be fixed by #361
Open

Error on endTour(true) -- TypeError: Cannot read property 'removeChild' of null #296

steveaft opened this issue Jul 26, 2016 · 3 comments · May be fixed by #361
Labels
Milestone

Comments

@steveaft
Copy link

TypeError: Cannot read property 'removeChild' of null
    at Object.destroy (webpack:///./~/hopscotch/dist/js/hopscotch.min.js?:17:10990)
    at n (webpack:///./~/hopscotch/dist/js/hopscotch.min.js?:17:14811)
    at Hopscotch.endTour (webpack:///./~/hopscotch/dist/js/hopscotch.min.js?:17:19761)
    at startTour$ (webpack:///./client/tour/sagas.js?:197:35)
    at tryCatch (webpack:///./~/regenerator-runtime/runtime.js?:62:40)

I'm using v0.2.5, haven't checked 0.2.6 but the offending line of code looks the same.

https://github.com/linkedin/hopscotch/blob/dc747f0e7fc8009227810ed623e3d31e418cda9b/src/js/hopscotch.js#L979-L986

I haven't figured out the exact cause, but I'm running into a case where I call endTour(true) before I've actually run a tour yet, and I get a console error/exception because parentNode is null.

I don't know enough of the plumbing without digging to figure out why. Maybe you can guess how that element might be detached somehow?

the element is the bubble

    destroy: function() {
      var el = this.element;

      if (el) {
        el.parentNode.removeChild(el);
      }
      utils.removeEvtListener(el, 'click', this.clickCb);
    },

Or perhaps you can do if (el && el.parentNode)

@timlindvall
Copy link
Collaborator

If el exists, it should be attached to the DOM. I'll have to figure out what code path we're taking where the bubble is created but isn't attached to the page for some reason.

@timlindvall timlindvall added this to the ES6 Refresh milestone Jul 27, 2016
@jziggas
Copy link

jziggas commented Mar 1, 2017

I've run into the same error. In my case our code was inadvertently calling hopscotch.endTour() when a tour hadn't been started yet.

@yishaic
Copy link

yishaic commented Apr 2, 2017

same case as @jziggas

@drujensen drujensen linked a pull request Feb 23, 2018 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants