Skip to content

Commit fb25057

Browse files
author
Joren Broekema
committed
fix(field): change FocusEvent to regular Event to support IE11
1 parent a5c7861 commit fb25057

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/field/src/FocusMixin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,30 @@ export const FocusMixin = dedupeMixin(
8282
// focus
8383
this.__redispatchFocus = ev => {
8484
ev.stopPropagation();
85-
this.dispatchEvent(new FocusEvent('focus'));
85+
this.dispatchEvent(new Event('focus'));
8686
};
8787
this.inputElement.addEventListener('focus', this.__redispatchFocus);
8888

8989
// blur
9090
this.__redispatchBlur = ev => {
9191
ev.stopPropagation();
92-
this.dispatchEvent(new FocusEvent('blur'));
92+
this.dispatchEvent(new Event('blur'));
9393
};
9494
this.inputElement.addEventListener('blur', this.__redispatchBlur);
9595

9696
// focusin
9797
this.__redispatchFocusin = ev => {
9898
ev.stopPropagation();
9999
this._onFocus(ev);
100-
this.dispatchEvent(new FocusEvent('focusin', { bubbles: true, composed: true }));
100+
this.dispatchEvent(new Event('focusin', { bubbles: true, composed: true }));
101101
};
102102
this.inputElement.addEventListener('focusin', this.__redispatchFocusin);
103103

104104
// focusout
105105
this.__redispatchFocusout = ev => {
106106
ev.stopPropagation();
107107
this._onBlur();
108-
this.dispatchEvent(new FocusEvent('focusout', { bubbles: true, composed: true }));
108+
this.dispatchEvent(new Event('focusout', { bubbles: true, composed: true }));
109109
};
110110
this.inputElement.addEventListener('focusout', this.__redispatchFocusout);
111111
}

packages/field/test/FocusMixin.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('FocusMixin', () => {
7777
`);
7878
setTimeout(() => el.focus());
7979
const focusEv = await oneEvent(el, 'focus');
80-
expect(focusEv).to.be.instanceOf(FocusEvent);
80+
expect(focusEv).to.be.instanceOf(Event);
8181
expect(focusEv.target).to.equal(el);
8282
expect(focusEv.bubbles).to.be.false;
8383
expect(focusEv.composed).to.be.false;
@@ -87,7 +87,7 @@ describe('FocusMixin', () => {
8787
el.blur();
8888
});
8989
const blurEv = await oneEvent(el, 'blur');
90-
expect(blurEv).to.be.instanceOf(FocusEvent);
90+
expect(blurEv).to.be.instanceOf(Event);
9191
expect(blurEv.target).to.equal(el);
9292
expect(blurEv.bubbles).to.be.false;
9393
expect(blurEv.composed).to.be.false;
@@ -99,7 +99,7 @@ describe('FocusMixin', () => {
9999
`);
100100
setTimeout(() => el.focus());
101101
const focusinEv = await oneEvent(el, 'focusin');
102-
expect(focusinEv).to.be.instanceOf(FocusEvent);
102+
expect(focusinEv).to.be.instanceOf(Event);
103103
expect(focusinEv.target).to.equal(el);
104104
expect(focusinEv.bubbles).to.be.true;
105105
expect(focusinEv.composed).to.be.true;
@@ -109,7 +109,7 @@ describe('FocusMixin', () => {
109109
el.blur();
110110
});
111111
const focusoutEv = await oneEvent(el, 'focusout');
112-
expect(focusoutEv).to.be.instanceOf(FocusEvent);
112+
expect(focusoutEv).to.be.instanceOf(Event);
113113
expect(focusoutEv.target).to.equal(el);
114114
expect(focusoutEv.bubbles).to.be.true;
115115
expect(focusoutEv.composed).to.be.true;

0 commit comments

Comments
 (0)