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 3 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
3 changes: 2 additions & 1 deletion src/renderers/dom/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ var DOMProperty = {
}
if (
(name[0] === 'o' || name[0] === 'O') &&
(name[1] === 'n' || name[1] === 'N')
(name[1] === 'n' || name[1] === 'N') &&
name.toLowerCase() !== 'on'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just check name.length instead?

) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ describe('ReactDOMServerIntegration', () => {
);
expect(e.getAttribute('onunknownevent')).toBe(null);
});

itRenders('custom attribute named `on`', async render => {
const e = await render(<div on="tap:do-something" />);
expect(e.getAttribute('on')).toEqual('tap:do-something');
});
});

describe('elements and children', function() {
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