mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Allow custom attribute named on to be passed on to elements (#11153)
* 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
This commit is contained in:
committed by
Sebastian Markbåge
parent
80596c2c92
commit
65b16b1c7e
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user