Guard against Firefox bug around hidden elements. Fixes #328