Correct IE detection code for containsNode workaround
Remove global references in tight loops to aid browser optimization

Global references tend to be impossible for v8 to safely inline. By
capturing a closure variable, v8 can better infer the values can't be
modified.
Use faster key iteration method