mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Stop treating key={null} as an unspecified key
This reverts commit dd92786fb0, which was intended to be temporary for the 0.12 release.
Fixes #2394.
This commit is contained in:
@@ -141,16 +141,7 @@ ReactElement.createElement = function(type, config, children) {
|
||||
|
||||
if (config != null) {
|
||||
ref = config.ref === undefined ? null : config.ref;
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
config.key !== null,
|
||||
'createElement(...): Encountered component with a `key` of null. In ' +
|
||||
'a future version, this will be treated as equivalent to the string ' +
|
||||
'\'null\'; instead, provide an explicit key or use undefined.'
|
||||
);
|
||||
}
|
||||
// TODO: Change this back to `config.key === undefined`
|
||||
key = config.key == null ? null : '' + config.key;
|
||||
key = config.key === undefined ? null : '' + config.key;
|
||||
// Remaining properties are added to a new props object
|
||||
for (propName in config) {
|
||||
if (config.hasOwnProperty(propName) &&
|
||||
|
||||
@@ -81,22 +81,6 @@ describe('ReactElement', function() {
|
||||
expect(element.props).toEqual({foo:'56'});
|
||||
});
|
||||
|
||||
it('treats a null key as omitted but warns', function() {
|
||||
spyOn(console, 'warn');
|
||||
var element = React.createFactory(ComponentClass)({
|
||||
key: null,
|
||||
foo: '56'
|
||||
});
|
||||
expect(element.type).toBe(ComponentClass);
|
||||
expect(element.key).toBe(null); // as opposed to string 'null'
|
||||
expect(element.ref).toBe(null);
|
||||
expect(element.props).toEqual({foo:'56'});
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
'will be treated as equivalent to the string \'null\''
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves the context on the element', function() {
|
||||
var Component = React.createFactory(ComponentClass);
|
||||
var element;
|
||||
|
||||
Reference in New Issue
Block a user