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.
This commit is contained in:
Paul O'Shannessy
2013-09-09 14:57:56 -07:00
committed by Paul O’Shannessy
parent 647731e399
commit 4ed7b85ed8
2 changed files with 6 additions and 9 deletions
+6 -3
View File
@@ -44,17 +44,20 @@ if (__DEV__) {
}
warnedProperties[name] = true;
var message = 'Unknown DOM property ' + name + '.';
var lowerCasedName = name.toLowerCase();
// data-* attributes should be lowercase; suggest the lowercase version
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ?
lowerCasedName : DOMProperty.getPossibleStandardName[lowerCasedName];
// For now, only warn when we have a suggested correction. This prevents
// logging too much when using transferPropsTo.
if (standardName != null) {
message += ' Did you mean ' + standardName + '?';
console.warn(
'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
);
}
console.warn(message);
};
}
@@ -151,24 +151,18 @@ describe('DOMPropertyOperations', function() {
describe('injectDOMPropertyConfig', function() {
it('should support custom attributes', function() {
spyOn(console, 'warn');
// foobar does not exist yet
expect(DOMPropertyOperations.createMarkupForProperty(
'foobar',
'simple'
)).toBe(null);
expect(console.warn.argsForCall.length).toBe(1);
// foo-* does not exist yet
expect(DOMPropertyOperations.createMarkupForProperty(
'foo-xyz',
'simple'
)).toBe(null);
expect(console.warn.argsForCall.length).toBe(2);
// inject foobar DOM property
DOMProperty.injection.injectDOMPropertyConfig({
isCustomAttribute: function(name) {