index.js
function text(element) {
  var type = element.nodeType
    , value = '';

  if (1 === type || 9 === type || 11 === type) {
    //
    // Use `textContent` instead of `innerText` as it's inconsistent with new
    // lines.
    //
    if ('string' === typeof element.textContent) return element.textContent;

    for (element = element.firstChild; element; element = element.nextSibling) {
      value += text(element);
    }
  }

  return 3 === type || 4 === type
  ? element.nodeValue
  : value;
}
function text(element) {
  var type = element.nodeType
    , value = '';

  if (1 === type || 9 === type || 11 === type) {
    //
    // Use `textContent` instead of `innerText` as it's inconsistent with new
    // lines.
    //
    if ('string' === typeof element.textContent) return element.textContent;

    for (element = element.firstChild; element; element = element.nextSibling) {
      value += text(element);
    }
  }

  return 3 === type || 4 === type
  ? element.nodeValue
  : value;
}
function text ( element ) { var type = element . nodeType , value = '' ; if ( 1 === type || 9 === type || 11 === type ) { // // Use `textContent` instead of `innerText` as it's inconsistent with new // lines. // if ( 'string' === typeof element . textContent ) return element . textContent ; for ( element = element . firstChild ; element ; element = element . nextSibling ) { value += text ( element ) ; } } return 3 === type || 4 === type ? element . nodeValue : value ; }
Get the text or inner text from a given element.

@param {Element} element
@returns {String} text
@api public
Get the text or inner text from a given element .