Skip to content
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

getBody().appendChild(testTextArea); throws Cannot read property 'appendChild' of undefined #25

Open
ndvbd opened this issue Jul 27, 2020 · 4 comments

Comments

@ndvbd
Copy link

ndvbd commented Jul 27, 2020

We use rangyinputs in a Chrome extension, and many times the line
getBody().appendChild(testTextArea);
throws
Cannot read property 'appendChild' of undefined
Probably in pages where they don't have a proper "body".

@kamlekar
Copy link

It usually happens if the script is being called before the body is rendered. Try running the chrome extension script once the body is rendered or loaded. Use something like window.onload.

@ndvbd
Copy link
Author

ndvbd commented Jul 27, 2020

But the problem is that it is out of our control, because the rangyinputs code is hooking the $(document).ready function:

```

$(document).ready(function() {
var testTextArea = document.createElement("textarea");

    getBody().appendChild(testTextArea);

@kamlekar
Copy link

hmm strange. It should not be an issue with this library though. Maybe you are loading multiple jquery libraries or maybe the latest one instead of the actual jquery library version this library relies on?

I don't think there will be a page without a body element though. If you feel so, maybe elaborate on this (give an example?)

Try checking console errors

@ndvbd
Copy link
Author

ndvbd commented Jul 28, 2020

Well, I don't know. I use Sentry, and I get many reports on this error, but I can't reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants