src/parser/ad_parser.js
function parseExtensions(collection, extensions) {
  extensions.forEach(extNode => {
    const ext = new AdExtension();
    const extNodeAttrs = extNode.attributes;
    const childNodes = extNode.childNodes;

    if (extNode.attributes) {
      for (const extNodeAttrKey in extNodeAttrs) {
        const extNodeAttr = extNodeAttrs[extNodeAttrKey];

        if (extNodeAttr.nodeName && extNodeAttr.nodeValue) {
          ext.attributes[extNodeAttr.nodeName] = extNodeAttr.nodeValue;
        }
      }
    }

    for (const childNodeKey in childNodes) {
      const childNode = childNodes[childNodeKey];
      const txt = parserUtils.parseNodeText(childNode);

      // ignore comments / empty value
      if (childNode.nodeName !== '#comment' && txt !== '') {
        const extChild = new AdExtensionChild();
        extChild.name = childNode.nodeName;
        extChild.value = txt;

        if (childNode.attributes) {
          const childNodeAttributes = childNode.attributes;

          for (const extChildNodeAttrKey in childNodeAttributes) {
            const extChildNodeAttr = childNodeAttributes[extChildNodeAttrKey];

            extChild.attributes[extChildNodeAttr.nodeName] =
              extChildNodeAttr.nodeValue;
          }
        }

        ext.children.push(extChild);
      }
    }

    collection.push(ext);
  });
}
function parseExtensions(collection, extensions) {
  extensions.forEach(extNode => {
    const ext = new AdExtension();
    const extNodeAttrs = extNode.attributes;
    const childNodes = extNode.childNodes;

    if (extNode.attributes) {
      for (const extNodeAttrKey in extNodeAttrs) {
        const extNodeAttr = extNodeAttrs[extNodeAttrKey];

        if (extNodeAttr.nodeName && extNodeAttr.nodeValue) {
          ext.attributes[extNodeAttr.nodeName] = extNodeAttr.nodeValue;
        }
      }
    }

    for (const childNodeKey in childNodes) {
      const childNode = childNodes[childNodeKey];
      const txt = parserUtils.parseNodeText(childNode);

      // ignore comments / empty value
      if (childNode.nodeName !== '#comment' && txt !== '') {
        const extChild = new AdExtensionChild();
        extChild.name = childNode.nodeName;
        extChild.value = txt;

        if (childNode.attributes) {
          const childNodeAttributes = childNode.attributes;

          for (const extChildNodeAttrKey in childNodeAttributes) {
            const extChildNodeAttr = childNodeAttributes[extChildNodeAttrKey];

            extChild.attributes[extChildNodeAttr.nodeName] =
              extChildNodeAttr.nodeValue;
          }
        }

        ext.children.push(extChild);
      }
    }

    collection.push(ext);
  });
}
function parseExtensions ( collection , extensions ) { extensions . forEach ( extNode => { const ext = new AdExtension ( ) ; const extNodeAttrs = extNode . attributes ; const childNodes = extNode . childNodes ; if ( extNode . attributes ) { for ( const extNodeAttrKey in extNodeAttrs ) { const extNodeAttr = extNodeAttrs [ extNodeAttrKey ] ; if ( extNodeAttr . nodeName && extNodeAttr . nodeValue ) { ext . attributes [ extNodeAttr . nodeName ] = extNodeAttr . nodeValue ; } } } for ( const childNodeKey in childNodes ) { const childNode = childNodes [ childNodeKey ] ; const txt = parserUtils . parseNodeText ( childNode ) ; // ignore comments / empty value if ( childNode . nodeName !== '#comment' && txt !== '' ) { const extChild = new AdExtensionChild ( ) ; extChild . name = childNode . nodeName ; extChild . value = txt ; if ( childNode . attributes ) { const childNodeAttributes = childNode . attributes ; for ( const extChildNodeAttrKey in childNodeAttributes ) { const extChildNodeAttr = childNodeAttributes [ extChildNodeAttrKey ] ; extChild . attributes [ extChildNodeAttr . nodeName ] = extChildNodeAttr . nodeValue ; } } ext . children . push ( extChild ) ; } } collection . push ( ext ) ; } ) ; }
Parses an array of Extension elements.
@param  {Array} collection - The array used to store the parsed extensions.
@param  {Array} extensions - The array of extensions to parse.
Parses an array of Extension elements .