function listenTo(registrationName, mountAt) {
  var isListening = getListeningForDocument(mountAt);
  var dependencies = registrationNameDependencies[registrationName];

  for (var i = 0; i < dependencies.length; i++) {
    var dependency = dependencies[i];
    if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
      switch (dependency) {
        case TOP_SCROLL:
          trapCapturedEvent(TOP_SCROLL, mountAt);
          break;
        case TOP_FOCUS:
        case TOP_BLUR:
          trapCapturedEvent(TOP_FOCUS, mountAt);
          trapCapturedEvent(TOP_BLUR, mountAt);
          // We set the flag for a single dependency later in this function,
          // but this ensures we mark both as attached rather than just one.
          isListening[TOP_BLUR] = true;
          isListening[TOP_FOCUS] = true;
          break;
        case TOP_CANCEL:
        case TOP_CLOSE:
          if (isEventSupported(getRawEventName(dependency))) {
            trapCapturedEvent(dependency, mountAt);
          }
          break;
        case TOP_INVALID:
        case TOP_SUBMIT:
        case TOP_RESET:
          // We listen to them on the target DOM elements.
          // Some of them bubble so we don't want them to fire twice.
          break;
        default:
          // By default, listen on the top level to all non-media events.
          // Media events don't bubble so adding the listener wouldn't do anything.
          var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1;
          if (!isMediaEvent) {
            trapBubbledEvent(dependency, mountAt);
          }
          break;
      }
      isListening[dependency] = true;
    }
  }
}
function listenTo(registrationName, mountAt) {
  var isListening = getListeningForDocument(mountAt);
  var dependencies = registrationNameDependencies[registrationName];

  for (var i = 0; i < dependencies.length; i++) {
    var dependency = dependencies[i];
    if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
      switch (dependency) {
        case TOP_SCROLL:
          trapCapturedEvent(TOP_SCROLL, mountAt);
          break;
        case TOP_FOCUS:
        case TOP_BLUR:
          trapCapturedEvent(TOP_FOCUS, mountAt);
          trapCapturedEvent(TOP_BLUR, mountAt);
          // We set the flag for a single dependency later in this function,
          // but this ensures we mark both as attached rather than just one.
          isListening[TOP_BLUR] = true;
          isListening[TOP_FOCUS] = true;
          break;
        case TOP_CANCEL:
        case TOP_CLOSE:
          if (isEventSupported(getRawEventName(dependency))) {
            trapCapturedEvent(dependency, mountAt);
          }
          break;
        case TOP_INVALID:
        case TOP_SUBMIT:
        case TOP_RESET:
          // We listen to them on the target DOM elements.
          // Some of them bubble so we don't want them to fire twice.
          break;
        default:
          // By default, listen on the top level to all non-media events.
          // Media events don't bubble so adding the listener wouldn't do anything.
          var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1;
          if (!isMediaEvent) {
            trapBubbledEvent(dependency, mountAt);
          }
          break;
      }
      isListening[dependency] = true;
    }
  }
}
function listenTo ( registrationName , mountAt ) { var isListening = getListeningForDocument ( mountAt ) ; var dependencies = registrationNameDependencies [ registrationName ] ; for ( var i = 0 ; i < dependencies . length ; i ++ ) { var dependency = dependencies [ i ] ; if ( ! ( isListening . hasOwnProperty ( dependency ) && isListening [ dependency ] ) ) { switch ( dependency ) { case TOP_SCROLL : trapCapturedEvent ( TOP_SCROLL , mountAt ) ; break ; case TOP_FOCUS : case TOP_BLUR : trapCapturedEvent ( TOP_FOCUS , mountAt ) ; trapCapturedEvent ( TOP_BLUR , mountAt ) ; // We set the flag for a single dependency later in this function, // but this ensures we mark both as attached rather than just one. isListening [ TOP_BLUR ] = true ; isListening [ TOP_FOCUS ] = true ; break ; case TOP_CANCEL : case TOP_CLOSE : if ( isEventSupported ( getRawEventName ( dependency ) ) ) { trapCapturedEvent ( dependency , mountAt ) ; } break ; case TOP_INVALID : case TOP_SUBMIT : case TOP_RESET : // We listen to them on the target DOM elements. // Some of them bubble so we don't want them to fire twice. break ; default : // By default, listen on the top level to all non-media events. // Media events don't bubble so adding the listener wouldn't do anything. var isMediaEvent = mediaEventTypes . indexOf ( dependency ) !== - 1 ; if ( ! isMediaEvent ) { trapBubbledEvent ( dependency , mountAt ) ; } break ; } isListening [ dependency ] = true ; } } }
We listen for bubbled touch events on the document object.

Firefox v8.01 (and possibly others) exhibited strange behavior when
mounting `onmousemove` events at some node that was not the document
element. The symptoms were that if your mouse is not moving over something
contained within that mount point (for example on the background) the
top-level listeners for `onmousemove` won't be called. However, if you
register the `mousemove` on the document object, then it will of course
catch all `mousemove`s. This along with iOS quirks, justifies restricting
top-level listeners to the document object only, at least for these
movement types of events and possibly all events.

@see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html

Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
they bubble to document.

@param {string} registrationName Name of listener (e.g. `onClick`).
@param {object} mountAt Container where to mount the listener
We listen for bubbled touch events on the document object .