Stop treating key={null} as an unspecified key
This reverts commit dd92786fb038c4eb7c6545928646ec8aa9ecfa36, which was intended to be temporary for the 0.12 release. Fixes #2394.
Ben Alpert committed
Nov 12, 2014 at 02:37 UTC
903db8bd14e0aaa8a2db3527f60102f9341dbd42
2 files changed
+1
-26
src/core/ReactElement.js
+1
-10
@@ -141,16 +141,7 @@ ReactElement.createElement = function(type, config, children) {
141
142
if (config != null) {
143
ref = config.ref === undefined ? null : config.ref;
144
- if (__DEV__) {
145
- warning(
146
- config.key !== null,
147
- 'createElement(...): Encountered component with a `key` of null. In ' +
148
- 'a future version, this will be treated as equivalent to the string ' +
149
- '\'null\'; instead, provide an explicit key or use undefined.'
150
- );
151
- }
152
- // TODO: Change this back to `config.key === undefined`
153
- key = config.key == null ? null : '' + config.key;
144
+ key = config.key === undefined ? null : '' + config.key;
145
// Remaining properties are added to a new props object
146
for (propName in config) {
147
if (config.hasOwnProperty(propName) &&
src/core/__tests__/ReactElement-test.js
-16
@@ -81,22 +81,6 @@ describe('ReactElement', function() {
81
expect(element.props).toEqual({foo:'56'});
82
});
83
84
- it('treats a null key as omitted but warns', function() {
85
- spyOn(console, 'warn');
86
- var element = React.createFactory(ComponentClass)({
87
- key: null,
88
- foo: '56'
89
- });
90
- expect(element.type).toBe(ComponentClass);
91
- expect(element.key).toBe(null); // as opposed to string 'null'
92
- expect(element.ref).toBe(null);
93
- expect(element.props).toEqual({foo:'56'});
94
- expect(console.warn.argsForCall.length).toBe(1);
95
- expect(console.warn.argsForCall[0][0]).toContain(
96
- 'will be treated as equivalent to the string \'null\''
97
- );
98
- });
99
-
84
it('preserves the context on the element', function() {
85
var Component = React.createFactory(ComponentClass);
86
var element;