diff --git a/compat/src/index.js b/compat/src/index.js index c35b623359..198d3c57a5 100644 --- a/compat/src/index.js +++ b/compat/src/index.js @@ -199,6 +199,10 @@ function applyEventNormalization({ type, props }) { props.ondblclick = props[newProps.ondoubleclick]; delete props[newProps.ondoubleclick]; } + if (newProps.onbeforeinput) { + props.onbeforeinput = props[newProps.onbeforeinput]; + delete props[newProps.onbeforeinput]; + } // for *textual inputs* (incl textarea), normalize `onChange` -> `onInput`: if (newProps.onchange && (type==='textarea' || (type.toLowerCase()==='input' && !/^fil|che|rad/i.test(props.type)))) { let normalized = newProps.oninput || 'oninput'; diff --git a/compat/test/browser/index.test.js b/compat/test/browser/index.test.js index 008403dca3..6131fb3bb3 100644 --- a/compat/test/browser/index.test.js +++ b/compat/test/browser/index.test.js @@ -171,6 +171,13 @@ describe('preact-compat', () => { expectToBeNormalized(, ''); }); + + it('should normalize beforeinput event listener', () => { + let spy = sinon.spy(); + render(, scratch); + scratch.firstChild.dispatchEvent(new Event('beforeinput')); + expect(spy).to.be.calledOnce; + }); }); describe('Component', () => {