Running event handlers in response to a mouse event may cause full layout invalidation, so we can't expect the layout root to be present right after returning from JS. Fixes #1629.