Offscreen widgets can have 0 height

Because `widgetHeight` only checked the parentNode to determine if the widget is in the DOM, there are a class of cases where calculating its height can fail.

Namely:
- it was added to a div under the measure div, then that div was removed
- it was added to a line widget outside the DOM.

I've added a test that triggers the first case (adding then removing from the measure div) and changed the heuristic for checking if we're in the DOM.

NOTE: this PR is into the v3 which we are still using. Let me know if it's a problem to fix it on v3 and v4 both.