Update to fbjs@0.3

As far as we're concerned, the only difference is that we moved some files from React to fbjs.
This commit is contained in:
Paul O’Shannessy 2015-10-01 14:29:07 -07:00
parent 4fa3ce48e8
commit 693dd3567b
6 changed files with 2 additions and 152 deletions

View File

@ -15,7 +15,7 @@
"eslint": "^1.5.1",
"eslint-plugin-react": "^3.4.2",
"eslint-plugin-react-internal": "file:eslint-rules",
"fbjs": "^0.2.0",
"fbjs": "^0.3.1",
"fbjs-scripts": "^0.2.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",

View File

@ -22,7 +22,7 @@
},
"dependencies": {
"envify": "^3.0.0",
"fbjs": "^0.2.0"
"fbjs": "^0.3.1"
},
"browserify": {
"transform": [

View File

@ -1,50 +0,0 @@
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
require('mock-modules').dontMock('joinClasses');
var joinClasses = require('joinClasses');
describe('joinClasses', function() {
it('should return a single className', function() {
expect(joinClasses('aaa')).toEqual('aaa');
});
it('should join two classes together', function() {
var aaa = 'aaa';
var bbb = 'bbb';
expect(joinClasses(aaa, bbb)).toEqual('aaa bbb');
});
it('should join many classes together', function() {
var aaa = 'aaa';
var bbb = 'bbb';
var ccc = 'ccc';
var ddd = 'ddd';
var eee = 'eee';
expect(joinClasses(aaa, bbb, ccc, ddd, eee)).toEqual('aaa bbb ccc ddd eee');
});
it('should omit undefined and empty classes', function() {
var aaa = 'aaa';
var bbb;
var ccc = null;
var ddd = '';
var eee = 'eee';
expect(joinClasses(bbb)).toEqual('');
expect(joinClasses(bbb, bbb, bbb)).toEqual('');
expect(joinClasses(aaa, bbb, ccc, ddd, eee)).toEqual('aaa eee');
});
});

View File

@ -1,39 +0,0 @@
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule joinClasses
* @typechecks static-only
*/
'use strict';
/**
* Combines multiple className strings into one.
* http://jsperf.com/joinclasses-args-vs-array
*
* @param {...?string} className
* @return {string}
*/
function joinClasses(className/*, ... */) {
if (!className) {
className = '';
}
var nextClass;
var argLength = arguments.length;
if (argLength > 1) {
for (var ii = 1; ii < argLength; ii++) {
nextClass = arguments[ii];
if (nextClass) {
className = (className ? className + ' ' : '') + nextClass;
}
}
}
return className;
}
module.exports = joinClasses;

View File

@ -1,30 +0,0 @@
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('memoizeStringOnly', function() {
var memoizeStringOnly;
beforeEach(function() {
require('mock-modules').dumpCache();
memoizeStringOnly = require('memoizeStringOnly');
});
it('should be transparent to callers', function() {
var callback = function(string) {
return string;
};
var memoized = memoizeStringOnly(callback);
expect(memoized('foo'), callback('foo'));
});
});

View File

@ -1,31 +0,0 @@
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule memoizeStringOnly
* @typechecks static-only
*/
'use strict';
/**
* Memoizes the return value of a function that accepts one string argument.
*
* @param {function} callback
* @return {function}
*/
function memoizeStringOnly(callback) {
var cache = {};
return function(string) {
if (!cache.hasOwnProperty(string)) {
cache[string] = callback.call(this, string);
}
return cache[string];
};
}
module.exports = memoizeStringOnly;