This is a workaround for #990, until we finish the refactors of Element._update_state() such that we manage the state bits more sensibly.
Also this adds a regression test for #990.