darsain / tooltip

JavaScript Tooltip component.
http://darsa.in/tooltip
190 stars 15 forks source link

Breaks if script tag is in <head> #23

Open iangilman opened 8 years ago

iangilman commented 8 years ago

The code expects window.document.body to already exist when it's loaded, which isn't true if the script tag is in . I realize putting the script tag at the bottom of the body is considered best practice, but the library shouldn't just break if you don't do it.

At the very least, there should be some indication that that's what the issue is.

iangilman commented 8 years ago

It shouldn't have to...as far as I can tell, nothing needs to happen until after new Tooltip is called. The reason there's an error is just that it makes its own local reference to window.document.body right at the beginning. It could easily do that in the first new Tooltip call.

On the other hand, if it is a necessary limitation, it should be mentioned during the installation instructions on http://darsa.in/tooltip/ and if people ignore that, it should generate a console.error that explains the situation.

RandyR34 commented 8 years ago

Second this!!! Thanks Iangilman, spent an hour trying to resolve "Type Error: Body is Null".

This should have some warning or instruction to include at the very bottom.