I think we could eliminate this logic by using CSS3 negation.