packages/fbjs/src/core/CSSCore.js
function(element, className) {
    invariant(
      !/\s/.test(className),
      'CSSCore.addClass takes only a single class name. "%s" contains ' +
      'multiple classes.', className
    );

    if (className) {
      if (element.classList) {
        element.classList.add(className);
      } else if (!CSSCore.hasClass(element, className)) {
        element.className = element.className + ' ' + className;
      }
    }
    return element;
  }
function(element, className) {
    invariant(
      !/\s/.test(className),
      'CSSCore.addClass takes only a single class name. "%s" contains ' +
      'multiple classes.', className
    );

    if (className) {
      if (element.classList) {
        element.classList.add(className);
      } else if (!CSSCore.hasClass(element, className)) {
        element.className = element.className + ' ' + className;
      }
    }
    return element;
  }
function ( element , className ) { invariant ( ! / \s / . test ( className ) , 'CSSCore.addClass takes only a single class name. "%s" contains ' + 'multiple classes.' , className ) ; if ( className ) { if ( element . classList ) { element . classList . add ( className ) ; } else if ( ! CSSCore . hasClass ( element , className ) ) { element . className = element . className + ' ' + className ; } } return element ; }
Adds the class passed in to the element if it doesn't already have it.

@param {DOMElement} element the element to set the class on
@param {string} className the CSS className
@return {DOMElement} the element passed in
Adds the class passed in to the element if it doesn t already have it .