Fix #12945. Check for .getAttribute so IE9 is happy.
Ref #12945, IE9/10 still needs safe .getAttribute check.