Skip to content

Commit

Permalink
Merge pull request #2400 from preactjs/fix-ie11-inputEvent
Browse files Browse the repository at this point in the history
use createEvent since InputEvent and new Event won't work in IE11
  • Loading branch information
marvinhagemeister committed Mar 8, 2020
2 parents 889e33c + e2a229e commit 3f06b00
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions compat/test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { setupRerender, act } from 'preact/test-utils';
import {
setupScratch,
teardown,
serializeHtml
serializeHtml,
createEvent
} from '../../../test/_util/helpers';

describe('compat render', () => {
Expand Down Expand Up @@ -110,13 +111,18 @@ describe('compat render', () => {
it('should keep value of uncontrolled inputs using defaultValue', () => {
// See https://github.com/preactjs/preact/issues/2391

const spy = sinon.spy();

class Input extends Component {
render() {
return (
<input
type="text"
defaultValue="bar"
onChange={() => this.forceUpdate()}
onChange={() => {
spy();
this.forceUpdate();
}}
/>
);
}
Expand All @@ -126,9 +132,11 @@ describe('compat render', () => {
expect(scratch.firstChild.value).to.equal('bar');
scratch.firstChild.focus();
scratch.firstChild.value = 'foo';
scratch.firstChild.dispatchEvent(new InputEvent('input'));

scratch.firstChild.dispatchEvent(createEvent('input'));
rerender();
expect(scratch.firstChild.value).to.equal('foo');
expect(spy).to.be.calledOnce;
});

it('should call the callback', () => {
Expand Down

0 comments on commit 3f06b00

Please sign in to comment.