Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for warning for camelCased unknown props #10612

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMAttribute-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,20 @@ describe('ReactDOM unknown attribute', () => {
);
expectDev(console.error.calls.count()).toBe(1);
});

it('removes camelCased unknown props and warns', () => {
spyOn(console, 'error');

var el = document.createElement('div');
ReactDOM.render(<div hELLo="something" />, el);
expect(el.firstChild.hasAttribute('hELLo')).toBe(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we add this warning I don't think we plan to strip them. Rather, we'll warn but leave them in the DOM.

expect(el.firstChild.hasAttribute('hello')).toBe(false);

expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Invalid prop `hELLo` on <div> tag. Did you mean `hello`?' +
' in div (at **)',
);
expectDev(console.error.calls.count()).toBe(1);
});
});
});