function parseWrapper(wrapperElement, emit) {
  var ad = parseAdElement(wrapperElement, emit);
  var followAdditionalWrappersValue = wrapperElement.getAttribute('followAdditionalWrappers');
  var allowMultipleAdsValue = wrapperElement.getAttribute('allowMultipleAds');
  var fallbackOnNoAdValue = wrapperElement.getAttribute('fallbackOnNoAd');
  ad.followAdditionalWrappers = followAdditionalWrappersValue ? parserUtils.parseBoolean(followAdditionalWrappersValue) : true;
  ad.allowMultipleAds = allowMultipleAdsValue ? parserUtils.parseBoolean(allowMultipleAdsValue) : false;
  ad.fallbackOnNoAd = fallbackOnNoAdValue ? parserUtils.parseBoolean(fallbackOnNoAdValue) : null;
  var wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURI');

  if (wrapperURLElement) {
    ad.nextWrapperURL = parserUtils.parseNodeText(wrapperURLElement);
  } else {
    wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURL');

    if (wrapperURLElement) {
      ad.nextWrapperURL = parserUtils.parseNodeText(parserUtils.childByName(wrapperURLElement, 'URL'));
    }
  }

  ad.creatives.forEach(function (wrapperCreativeElement) {
    if (['linear', 'nonlinear'].indexOf(wrapperCreativeElement.type) !== -1) {
      // TrackingEvents Linear / NonLinear
      if (wrapperCreativeElement.trackingEvents) {
        if (!ad.trackingEvents) {
          ad.trackingEvents = {};
        }

        if (!ad.trackingEvents[wrapperCreativeElement.type]) {
          ad.trackingEvents[wrapperCreativeElement.type] = {};
        }

        var _loop = function _loop(eventName) {
          var urls = wrapperCreativeElement.trackingEvents[eventName];

          if (!Array.isArray(ad.trackingEvents[wrapperCreativeElement.type][eventName])) {
            ad.trackingEvents[wrapperCreativeElement.type][eventName] = [];
          }

          urls.forEach(function (url) {
            ad.trackingEvents[wrapperCreativeElement.type][eventName].push(url);
          });
        };

        for (var eventName in wrapperCreativeElement.trackingEvents) {
          _loop(eventName);
        }
      } // ClickTracking


      if (wrapperCreativeElement.videoClickTrackingURLTemplates) {
        if (!Array.isArray(ad.videoClickTrackingURLTemplates)) {
          ad.videoClickTrackingURLTemplates = [];
        } // tmp property to save wrapper tracking URLs until they are merged


        wrapperCreativeElement.videoClickTrackingURLTemplates.forEach(function (item) {
          ad.videoClickTrackingURLTemplates.push(item);
        });
      } // ClickThrough


      if (wrapperCreativeElement.videoClickThroughURLTemplate) {
        ad.videoClickThroughURLTemplate = wrapperCreativeElement.videoClickThroughURLTemplate;
      } // CustomClick


      if (wrapperCreativeElement.videoCustomClickURLTemplates) {
        if (!Array.isArray(ad.videoCustomClickURLTemplates)) {
          ad.videoCustomClickURLTemplates = [];
        } // tmp property to save wrapper tracking URLs until they are merged


        wrapperCreativeElement.videoCustomClickURLTemplates.forEach(function (item) {
          ad.videoCustomClickURLTemplates.push(item);
        });
      }
    }
  });

  if (ad.nextWrapperURL) {
    return ad;
  }
}
/**
 * Parses a Wrapper element without resolving the wrapped urls.
 * @param  {Object} wrapperElement - The VAST Wrapper element to be parsed.
 * @param  {Function} emit - Emit function used to trigger Warning event.
 * @emits  VASTParser#VAST-warning
 * @return {Ad}
 */
Parses a Wrapper element without resolving the wrapped urls.
@param  {Object} wrapperElement - The VAST Wrapper element to be parsed.
@param  {Function} emit - Emit function used to trigger Warning event.
@emits  VASTParser#VAST-warning
@return {Ad}
Parses a Wrapper element without resolving the wrapped urls . @param { Object } wrapperElement - The VAST Wrapper element to be parsed . @param { Function } emit - Emit function used to trigger Warning event . @emits VASTParser#VAST - warning @return { Ad }
function parseWrapper(wrapperElement, emit) {
  var ad = parseAdElement(wrapperElement, emit);
  var followAdditionalWrappersValue = wrapperElement.getAttribute('followAdditionalWrappers');
  var allowMultipleAdsValue = wrapperElement.getAttribute('allowMultipleAds');
  var fallbackOnNoAdValue = wrapperElement.getAttribute('fallbackOnNoAd');
  ad.followAdditionalWrappers = followAdditionalWrappersValue ? parserUtils.parseBoolean(followAdditionalWrappersValue) : true;
  ad.allowMultipleAds = allowMultipleAdsValue ? parserUtils.parseBoolean(allowMultipleAdsValue) : false;
  ad.fallbackOnNoAd = fallbackOnNoAdValue ? parserUtils.parseBoolean(fallbackOnNoAdValue) : null;
  var wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURI');
  if (wrapperURLElement) {
    ad.nextWrapperURL = parserUtils.parseNodeText(wrapperURLElement);
  } else {
    wrapperURLElement = parserUtils.childByName(wrapperElement, 'VASTAdTagURL');
    if (wrapperURLElement) {
      ad.nextWrapperURL = parserUtils.parseNodeText(parserUtils.childByName(wrapperURLElement, 'URL'));
    }
  }
  ad.creatives.forEach(function (wrapperCreativeElement) {
    if (['linear', 'nonlinear'].indexOf(wrapperCreativeElement.type) !== -1) {
      if (wrapperCreativeElement.trackingEvents) {
        if (!ad.trackingEvents) {
          ad.trackingEvents = {};
        }
        if (!ad.trackingEvents[wrapperCreativeElement.type]) {
          ad.trackingEvents[wrapperCreativeElement.type] = {};
        }
        var _loop = function _loop(eventName) {
          var urls = wrapperCreativeElement.trackingEvents[eventName];
          if (!Array.isArray(ad.trackingEvents[wrapperCreativeElement.type][eventName])) {
            ad.trackingEvents[wrapperCreativeElement.type][eventName] = [];
          }
          urls.forEach(function (url) {
            ad.trackingEvents[wrapperCreativeElement.type][eventName].push(url);
          });
        };
        for (var eventName in wrapperCreativeElement.trackingEvents) {
          _loop(eventName);
        }
      } 
      if (wrapperCreativeElement.videoClickTrackingURLTemplates) {
        if (!Array.isArray(ad.videoClickTrackingURLTemplates)) {
          ad.videoClickTrackingURLTemplates = [];
        } 
        wrapperCreativeElement.videoClickTrackingURLTemplates.forEach(function (item) {
          ad.videoClickTrackingURLTemplates.push(item);
        });
      } 
      if (wrapperCreativeElement.videoClickThroughURLTemplate) {
        ad.videoClickThroughURLTemplate = wrapperCreativeElement.videoClickThroughURLTemplate;
      } 
      if (wrapperCreativeElement.videoCustomClickURLTemplates) {
        if (!Array.isArray(ad.videoCustomClickURLTemplates)) {
          ad.videoCustomClickURLTemplates = [];
        } 
        wrapperCreativeElement.videoCustomClickURLTemplates.forEach(function (item) {
          ad.videoCustomClickURLTemplates.push(item);
        });
      }
    }
  });
  if (ad.nextWrapperURL) {
    return ad;
  }
}
function parseWrapper ( wrapperElement , emit ) { var ad = parseAdElement ( wrapperElement , emit ) ; var followAdditionalWrappersValue = wrapperElement . getAttribute ( 'followAdditionalWrappers' ) ; var allowMultipleAdsValue = wrapperElement . getAttribute ( 'allowMultipleAds' ) ; var fallbackOnNoAdValue = wrapperElement . getAttribute ( 'fallbackOnNoAd' ) ; ad . followAdditionalWrappers = followAdditionalWrappersValue ? parserUtils . parseBoolean ( followAdditionalWrappersValue ) : true ; ad . allowMultipleAds = allowMultipleAdsValue ? parserUtils . parseBoolean ( allowMultipleAdsValue ) : false ; ad . fallbackOnNoAd = fallbackOnNoAdValue ? parserUtils . parseBoolean ( fallbackOnNoAdValue ) : null ; var wrapperURLElement = parserUtils . childByName ( wrapperElement , 'VASTAdTagURI' ) ; if ( wrapperURLElement ) { ad . nextWrapperURL = parserUtils . parseNodeText ( wrapperURLElement ) ; } else { wrapperURLElement = parserUtils . childByName ( wrapperElement , 'VASTAdTagURL' ) ; if ( wrapperURLElement ) { ad . nextWrapperURL = parserUtils . parseNodeText ( parserUtils . childByName ( wrapperURLElement , 'URL' ) ) ; } } ad . creatives . forEach ( function ( wrapperCreativeElement ) { if ( [ 'linear' , 'nonlinear' ] . indexOf ( wrapperCreativeElement . type ) !== - 1 ) { if ( wrapperCreativeElement . trackingEvents ) { if ( ! ad . trackingEvents ) { ad . trackingEvents = { } ; } if ( ! ad . trackingEvents [ wrapperCreativeElement . type ] ) { ad . trackingEvents [ wrapperCreativeElement . type ] = { } ; } var _loop = function _loop ( eventName ) { var urls = wrapperCreativeElement . trackingEvents [ eventName ] ; if ( ! Array . isArray ( ad . trackingEvents [ wrapperCreativeElement . type ] [ eventName ] ) ) { ad . trackingEvents [ wrapperCreativeElement . type ] [ eventName ] = [ ] ; } urls . forEach ( function ( url ) { ad . trackingEvents [ wrapperCreativeElement . type ] [ eventName ] . push ( url ) ; } ) ; } ; for ( var eventName in wrapperCreativeElement . trackingEvents ) { _loop ( eventName ) ; } } if ( wrapperCreativeElement . videoClickTrackingURLTemplates ) { if ( ! Array . isArray ( ad . videoClickTrackingURLTemplates ) ) { ad . videoClickTrackingURLTemplates = [ ] ; } wrapperCreativeElement . videoClickTrackingURLTemplates . forEach ( function ( item ) { ad . videoClickTrackingURLTemplates . push ( item ) ; } ) ; } if ( wrapperCreativeElement . videoClickThroughURLTemplate ) { ad . videoClickThroughURLTemplate = wrapperCreativeElement . videoClickThroughURLTemplate ; } if ( wrapperCreativeElement . videoCustomClickURLTemplates ) { if ( ! Array . isArray ( ad . videoCustomClickURLTemplates ) ) { ad . videoCustomClickURLTemplates = [ ] ; } wrapperCreativeElement . videoCustomClickURLTemplates . forEach ( function ( item ) { ad . videoCustomClickURLTemplates . push ( item ) ; } ) ; } } } ) ; if ( ad . nextWrapperURL ) { return ad ; } }
Parses a Wrapper element without resolving the wrapped urls.
Parses a Wrapper element without resolving the wrapped urls .
// TrackingEvents Linear / NonLinear // ClickTracking // tmp property to save wrapper tracking URLs until they are merged // ClickThrough // CustomClick // tmp property to save wrapper tracking URLs until they are merged