Refactors Element.update_contents method.