That's not a problem since the cell keeps a state and only changes the classes applied to its DOM element iff the state has changed.  Having this outside of that block is just another way of making sure that if the notebook command mode state is out of sync with the cell, they will still get synced up properly.