extensions/amp-analytics/0.1/analytics-root.js
/**
   * Creates listener-filter for DOM events to check against the specified
   * selector. If the node (or its ancestors) match the selector the listener
   * will be called.
   *
   * @param {function(!Element, !Event)} listener The first argument is the
   *   matched target node and the second is the original event.
   * @param {!Element} context
   * @param {string} selector DOM query selector.
   * @param {?string=} selectionMethod Allowed values are `null`,
   *   `'closest'` and `'scope'`.
   * @return {function(!Event)}
   */
Creates listener-filter for DOM events to check against the specified
selector. If the node (or its ancestors) match the selector the listener
will be called.

@param {function(!Element, !Event)} listener The first argument is the
matched target node and the second is the original event.
@param {!Element} context
@param {string} selector DOM query selector.
Creates listener - filter for DOM events to check against the specified selector . If the node ( or its ancestors ) match the selector the listener will be called . @param { function ( !Element !Event ) } listener The first argument is the matched target node and the second is the original event . @param { !Element } context @param { string } selector DOM query selector .
createSelectiveListener(
      listener, context, selector, selectionMethod = null) {
    return event => {
      if (selector == ':host') {
        return;
      }
      const rootElement = this.getRootElement();
      const isSelectAny = (selector == '*');
      const isSelectRoot = (selector == ':root');
      let target = event.target;
      while (target) {
        if (!this.contains(target)) {
          break;
        }
        if (selectionMethod == 'scope' &&
            !isSelectRoot && !context.contains(target)) {
          break;
        }
        if (selectionMethod == 'closest' && !target.contains(context)) {
          target = target.parentElement;
          continue;
        }
        if (isSelectAny ||
            isSelectRoot && target == rootElement ||
            matchesNoInline(target, selector)) {
          listener(target, event);
          break;
        }
        target = target.parentElement;
      }
    };
  }
createSelectiveListener ( listener , context , selector , selectionMethod = null ) { return event => { if ( selector == ':host' ) { return ; } const rootElement = this . getRootElement ( ) ; const isSelectAny = ( selector == '*' ) ; const isSelectRoot = ( selector == ':root' ) ; let target = event . target ; while ( target ) { if ( ! this . contains ( target ) ) { break ; } if ( selectionMethod == 'scope' && ! isSelectRoot && ! context . contains ( target ) ) { break ; } if ( selectionMethod == 'closest' && ! target . contains ( context ) ) { target = target . parentElement ; continue ; } if ( isSelectAny || isSelectRoot && target == rootElement || matchesNoInline ( target , selector ) ) { listener ( target , event ) ; break ; } target = target . parentElement ; } } ; }
Creates listener-filter for DOM events to check against the specified
 selector.
Creates listener - filter for DOM events to check against the specified selector .
// `:host` is not reachable via selective listener b/c event path // cannot be retargeted across the boundary of the embed. // Navigate up the DOM tree to find the actual target. // Target must be contained by this root. // `:scope` context must contain the target. // `closest()` target must contain the conext. // However, the search must continue! // Check if the target matches the selector. // Don't fire the event multiple times even if the more than one // ancestor matches the selector.