Add unknown property warning for use of (#6461)
hkal committed
Sep 3, 2016 at 19:48 UTC
6a525fdc4c90303c4e14c3aee26f8faa50e77c27
2 files changed
+19
-1
src/renderers/dom/shared/HTMLDOMPropertyConfig.js
+2
-1
@@ -41,7 +41,7 @@ var HTMLDOMPropertyConfig = {
41
async: HAS_BOOLEAN_VALUE,
42
autoComplete: 0,
43
// autoFocus is polyfilled/normalized by AutoFocusUtils
44
- // autoFocus: HAS_BOOLEAN_VALUE,
44
+ autoFocus: HAS_BOOLEAN_VALUE,
45
autoPlay: HAS_BOOLEAN_VALUE,
46
capture: HAS_BOOLEAN_VALUE,
47
cellPadding: 0,
@@ -205,6 +205,7 @@ var HTMLDOMPropertyConfig = {
205
},
206
DOMAttributeNames: {
207
acceptCharset: 'accept-charset',
208
+ autoFocus: 'autofocus',
209
className: 'class',
210
htmlFor: 'for',
211
httpEquiv: 'http-equiv',
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+17
@@ -1495,5 +1495,22 @@ describe('ReactDOMComponent', function() {
1495
//since hard coding the line number would make test too brittle
1496
expect(parseInt(previousLine, 10) + 12).toBe(parseInt(currentLine, 10));
1497
});
1498
+
1499
+ it('should suggest property name if available', () => {
1500
+ spyOn(console, 'error');
1501
+
1502
+ ReactTestUtils.renderIntoDocument(React.createElement('label', {for: 'test'}));
1503
+ ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', autofocus: true}));
1504
+
1505
+ expect(console.error.calls.count()).toBe(2);
1506
+
1507
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1508
+ 'Warning: Unknown DOM property for. Did you mean htmlFor?\n in label'
1509
+ );
1510
+
1511
+ expect(console.error.calls.argsFor(1)[0]).toBe(
1512
+ 'Warning: Unknown DOM property autofocus. Did you mean autoFocus?\n in input'
1513
+ );
1514
+ });
1515
});
1516
});