third_party/subscriptions-project/swg.js
/**
 * Create a new element on document with specified tagName and attributes.
 * @param {!Document} doc
 * @param {string} tagName
 * @param {!Object<string, string>} attributes
 * @param {?(string|!Node|!ArrayLike<!Node>|!Array<!Node>)=} content
 * @return {!Element} created element.
 */
Create a new element on document with specified tagName and attributes.
Create a new element on document with specified tagName and attributes .
function createElement(doc, tagName, attributes, content) {
  const element = doc.createElement(tagName);
  addAttributesToElement(element, attributes);
  if (content != null) {
    if (typeof content == 'string') {
      element.textContent = content;
    } else if (content.nodeType) {
      element.appendChild( (content));
    } else if ('length' in content) {
      for (let i = 0; i < content.length; i++) {
        element.appendChild(content[i]);
      }
    } else {
      assert(false, 'Unsupported content: %s', content);
    }
  }
  return element;
}
function createElement ( doc , tagName , attributes , content ) { const element = doc . createElement ( tagName ) ; addAttributesToElement ( element , attributes ) ; if ( content != null ) { if ( typeof content == 'string' ) { element . textContent = content ; } else if ( content . nodeType ) { element . appendChild ( ( content ) ) ; } else if ( 'length' in content ) { for ( let i = 0 ; i < content . length ; i ++ ) { element . appendChild ( content [ i ] ) ; } } else { assert ( false , 'Unsupported content: %s' , content ) ; } } return element ; }
Create a new element on document with specified tagName and attributes.
Create a new element on document with specified tagName and attributes .
/** @type {!Node} */