Log unknown props only when we have a match
Logging every unknown property got very noisy when combined with use of `transferPropsTo`. I knew this would be a potential issue initially but decided it was worth it. Others disagreed and it's resulting in some confusion. This changes the logging to ensure that we have a potential correction, so only DOMish properties should result in warnings.
Paul O'Shannessy committed
Sep 9, 2013 at 14:55 UTC
4ed7b85ed8296259c61eeb4747a067afb35d4f52
2 files changed
+6
-9
src/dom/DOMPropertyOperations.js
+6
-3
@@ -44,17 +44,20 @@ if (__DEV__) {
44
}
45
46
warnedProperties[name] = true;
47
- var message = 'Unknown DOM property ' + name + '.';
47
var lowerCasedName = name.toLowerCase();
48
49
// data-* attributes should be lowercase; suggest the lowercase version
50
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ?
51
lowerCasedName : DOMProperty.getPossibleStandardName[lowerCasedName];
52
+
53
+ // For now, only warn when we have a suggested correction. This prevents
54
+ // logging too much when using transferPropsTo.
55
if (standardName != null) {
54
- message += ' Did you mean ' + standardName + '?';
56
+ console.warn(
57
+ 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
58
+ );
59
}
60
57
- console.warn(message);
61
};
62
}
63
src/dom/__tests__/DOMPropertyOperations-test.js
-6
@@ -151,24 +151,18 @@ describe('DOMPropertyOperations', function() {
151
152
describe('injectDOMPropertyConfig', function() {
153
it('should support custom attributes', function() {
154
- spyOn(console, 'warn');
155
-
154
// foobar does not exist yet
155
expect(DOMPropertyOperations.createMarkupForProperty(
156
'foobar',
157
'simple'
158
)).toBe(null);
159
162
- expect(console.warn.argsForCall.length).toBe(1);
163
-
160
// foo-* does not exist yet
161
expect(DOMPropertyOperations.createMarkupForProperty(
162
'foo-xyz',
163
'simple'
164
)).toBe(null);
165
170
- expect(console.warn.argsForCall.length).toBe(2);
171
-
166
// inject foobar DOM property
167
DOMProperty.injection.injectDOMPropertyConfig({
168
isCustomAttribute: function(name) {