react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / vendor / stubs / cx.js
81155 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule cx9*/1011/**12* This function is used to mark string literals representing CSS class names13* so that they can be transformed statically. This allows for modularization14* and minification of CSS class names.15*16* In static_upstream, this function is actually implemented, but it should17* eventually be replaced with something more descriptive, and the transform18* that is used in the main stack should be ported for use elsewhere.19*20* @param string|object className to modularize, or an object of key/values.21* In the object case, the values are conditions that22* determine if the className keys should be included.23* @param [string ...] Variable list of classNames in the string case.24* @return string Renderable space-separated CSS className.25*/26function cx(classNames) {27if (typeof classNames == 'object') {28return Object.keys(classNames).filter(function(className) {29return classNames[className];30}).join(' ');31} else {32return Array.prototype.join.call(arguments, ' ');33}34}3536module.exports = cx;373839