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

Allow custom attribute named on to be passed on to elements #11153

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ describe('ReactDOMComponent', () => {
);
});

it('should not warn if property `on` is passed on a custom component', () => {
spyOn(console, 'error');
var container = document.createElement('div');
ReactDOM.render(<amp-image on="tap" />, container);
expectDev(console.error.calls.count()).toBe(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need this (or spyOn call). By default we assume none of the tests warn unless they opt in.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead you'll want to assert that the on attribute gets set (which it probably doesn't right now).

});

it('should warn for unknown function event handlers', () => {
spyOn(console, 'error');
var container = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (__DEV__) {
return true;
}

if (lowerCasedName.indexOf('on') === 0) {
if (lowerCasedName.indexOf('on') === 0 && lowerCasedName !== 'on') {
warning(
false,
'Unknown event handler property `%s`. It will be ignored.%s',
Expand Down