function normalizeContent(content) {

  // First, invoke content if it is a function. If it produces an array,
  // that needs to happen before normalization.
  if (typeof content === 'function') {
    content = content();
  }

  // Next up, normalize to an array, so one or many items can be normalized,
  // filtered, and returned.
  return (Array.isArray(content) ? content : [content]).map(value => {

    // First, invoke value if it is a function to produce a new value,
    // which will be subsequently normalized to a Node of some kind.
    if (typeof value === 'function') {
      value = value();
    }

    if (isEl(value) || isTextNode(value)) {
      return value;
    }

    if (typeof value === 'string' && /\S/.test(value)) {
      return document.createTextNode(value);
    }
  }).filter(value => value);
}
/**
 * Normalizes content for eventual insertion into the DOM.
 *
 * This allows a wide range of content definition methods, but protects
 * from falling into the trap of simply writing to `innerHTML`, which is
 * an XSS concern.
 *
 * The content for an element can be passed in multiple types, whose
 * behavior is as follows:
 *
 * - String: Normalized into a text node.
 * - Node: An Element or TextNode is passed through.
 * - Array: A one-dimensional array of strings, nodes, or functions (which
 *   return single strings or nodes).
 * - Function: If the sole argument, is expected to produce a string, node,
 *   or array.
 *
 * @function normalizeContent
 * @param    {String|Element|Array|Function} content
 * @return   {Array}
 */
Normalizes content for eventual insertion into the DOM.
This allows a wide range of content definition methods, but protects
from falling into the trap of simply writing to `innerHTML`, which is
an XSS concern.

The content for an element can be passed in multiple types, whose
behavior is as follows.

- String: Normalized into a text node.
- Node: An Element or TextNode is passed through.
- Array: A one-dimensional array of strings, nodes, or functions (which
return single strings or nodes).
- Function: If the sole argument, is expected to produce a string, node,
or array.

@function normalizeContent
@param    {String|Element|Array|Function} content
@return   {Array}
Normalizes content for eventual insertion into the DOM . This allows a wide range of content definition methods but protects from falling into the trap of simply writing to ` innerHTML ` which is an XSS concern . The content for an element can be passed in multiple types whose behavior is as follows . - String : Normalized into a text node . - Node : An Element or TextNode is passed through . - Array : A one - dimensional array of strings nodes or functions ( which return single strings or nodes ) . - Function : If the sole argument is expected to produce a string node or array . @function normalizeContent @param { String|Element|Array|Function } content @return { Array }
function normalizeContent(content) {
  if (typeof content === 'function') {
    content = content();
  }
  return (Array.isArray(content) ? content : [content]).map(value => {
    if (typeof value === 'function') {
      value = value();
    }
    if (isEl(value) || isTextNode(value)) {
      return value;
    }
    if (typeof value === 'string' && /\S/.test(value)) {
      return document.createTextNode(value);
    }
  }).filter(value => value);
}
function normalizeContent ( content ) { if ( typeof content === 'function' ) { content = content ( ) ; } return ( Array . isArray ( content ) ? content : [ content ] ) . map ( value => { if ( typeof value === 'function' ) { value = value ( ) ; } if ( isEl ( value ) || isTextNode ( value ) ) { return value ; } if ( typeof value === 'string' && / \S / . test ( value ) ) { return document . createTextNode ( value ) ; } } ) . filter ( value => value ) ; }
Normalizes content for eventual insertion into the DOM.
Normalizes content for eventual insertion into the DOM .
// First, invoke content if it is a function. If it produces an array, // that needs to happen before normalization. // Next up, normalize to an array, so one or many items can be normalized, // filtered, and returned. // First, invoke value if it is a function to produce a new value, // which will be subsequently normalized to a Node of some kind.