Cursor stops blinking on Firefox

In Firefox, with drawSelection enabled, if the editor is scrolled and the mouse pointer is not moving, the cursor stops blinking. Steps to reproduce:

  1. In Firefox, go to Try CodeMirror
  2. Scroll the editor on the right-hand side down a little
  3. Place the cursor and stop moving the mouse. After a short time, the cursor will stop blinking.

I’ve seen this in Firefox on Linux and Windows, so it seems likely it affects Mac as well.

I strongly suspect this is a Firefox bug with CSS animation, which (judging by browser bug trackers) seems a bountiful source of bugs in all browsers (see also Use opacity instead of visibility for cursor blink animation by hubgit · Pull Request #37 · codemirror/view · GitHub). I couldn’t find another property to animate that didn’t cause performance issues in Chrome, so am working around this by blinking the cursor the old-fashioned way, i.e. with a setInterval.

Ugh, this seems indeed to be a Firefox bug. The patch below seems to work around it.