joinClasses.js.flow 762 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @providesModule joinClasses
  8. * @flow
  9. * @typechecks static-only
  10. */
  11. 'use strict';
  12. /**
  13. * Combines multiple className strings into one.
  14. */
  15. function joinClasses(className: mixed): string {
  16. let newClassName = ((className: any): string) || '';
  17. const argLength = arguments.length;
  18. if (argLength > 1) {
  19. for (let index = 1; index < argLength; index++) {
  20. const nextClass = arguments[index];
  21. if (nextClass) {
  22. newClassName = (newClassName ? newClassName + ' ' : '') + nextClass;
  23. }
  24. }
  25. }
  26. return newClassName;
  27. }
  28. module.exports = joinClasses;