Skip to content

Commit

Permalink
Allow custom attribute named on to be passed on to elements (#11153)
Browse files Browse the repository at this point in the history
* Allow single `on` property for custom elements

* Remove test from ReactDOMComponent-test

* Allow custom attribute named 'on' to be passed

* Check property length instead of comparing strings
  • Loading branch information
nuc authored and sebmarkbage committed Oct 10, 2017
1 parent 80596c2 commit 65b16b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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.length > 2
) {
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.length > 2) {
warning(
false,
'Unknown event handler property `%s`. It will be ignored.%s',
Expand Down

0 comments on commit 65b16b1

Please sign in to comment.