Fixing edge case for finding elements by invalid class name.

The fix should be isolated only to situations where the IE document
mode is 8 or less. In other words, it should fix the case for quirks
mode for IE9 or below, and for standards mode for IE8 or below.