Fix JS errors occurring during EnterKeyHandling in IE11. Curiously, the tests did not catch them. Fixes #17466.

(cherry picked from commit 8ec9162b32398ed7a2a15272e277532698a6512d)