From fb25057964568bafc3b7fd42e323a0a480b3eae4 Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Fri, 13 Sep 2019 16:02:31 +0200 Subject: [PATCH] fix(field): change FocusEvent to regular Event to support IE11 --- packages/field/src/FocusMixin.js | 8 ++++---- packages/field/test/FocusMixin.test.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/field/src/FocusMixin.js b/packages/field/src/FocusMixin.js index 2837c05dd..f16b4e6b2 100644 --- a/packages/field/src/FocusMixin.js +++ b/packages/field/src/FocusMixin.js @@ -82,14 +82,14 @@ export const FocusMixin = dedupeMixin( // focus this.__redispatchFocus = ev => { ev.stopPropagation(); - this.dispatchEvent(new FocusEvent('focus')); + this.dispatchEvent(new Event('focus')); }; this.inputElement.addEventListener('focus', this.__redispatchFocus); // blur this.__redispatchBlur = ev => { ev.stopPropagation(); - this.dispatchEvent(new FocusEvent('blur')); + this.dispatchEvent(new Event('blur')); }; this.inputElement.addEventListener('blur', this.__redispatchBlur); @@ -97,7 +97,7 @@ export const FocusMixin = dedupeMixin( this.__redispatchFocusin = ev => { ev.stopPropagation(); this._onFocus(ev); - this.dispatchEvent(new FocusEvent('focusin', { bubbles: true, composed: true })); + this.dispatchEvent(new Event('focusin', { bubbles: true, composed: true })); }; this.inputElement.addEventListener('focusin', this.__redispatchFocusin); @@ -105,7 +105,7 @@ export const FocusMixin = dedupeMixin( this.__redispatchFocusout = ev => { ev.stopPropagation(); this._onBlur(); - this.dispatchEvent(new FocusEvent('focusout', { bubbles: true, composed: true })); + this.dispatchEvent(new Event('focusout', { bubbles: true, composed: true })); }; this.inputElement.addEventListener('focusout', this.__redispatchFocusout); } diff --git a/packages/field/test/FocusMixin.test.js b/packages/field/test/FocusMixin.test.js index e2085f2cc..8f5eb8b4f 100644 --- a/packages/field/test/FocusMixin.test.js +++ b/packages/field/test/FocusMixin.test.js @@ -77,7 +77,7 @@ describe('FocusMixin', () => { `); setTimeout(() => el.focus()); const focusEv = await oneEvent(el, 'focus'); - expect(focusEv).to.be.instanceOf(FocusEvent); + expect(focusEv).to.be.instanceOf(Event); expect(focusEv.target).to.equal(el); expect(focusEv.bubbles).to.be.false; expect(focusEv.composed).to.be.false; @@ -87,7 +87,7 @@ describe('FocusMixin', () => { el.blur(); }); const blurEv = await oneEvent(el, 'blur'); - expect(blurEv).to.be.instanceOf(FocusEvent); + expect(blurEv).to.be.instanceOf(Event); expect(blurEv.target).to.equal(el); expect(blurEv.bubbles).to.be.false; expect(blurEv.composed).to.be.false; @@ -99,7 +99,7 @@ describe('FocusMixin', () => { `); setTimeout(() => el.focus()); const focusinEv = await oneEvent(el, 'focusin'); - expect(focusinEv).to.be.instanceOf(FocusEvent); + expect(focusinEv).to.be.instanceOf(Event); expect(focusinEv.target).to.equal(el); expect(focusinEv.bubbles).to.be.true; expect(focusinEv.composed).to.be.true; @@ -109,7 +109,7 @@ describe('FocusMixin', () => { el.blur(); }); const focusoutEv = await oneEvent(el, 'focusout'); - expect(focusoutEv).to.be.instanceOf(FocusEvent); + expect(focusoutEv).to.be.instanceOf(Event); expect(focusoutEv.target).to.equal(el); expect(focusoutEv.bubbles).to.be.true; expect(focusoutEv.composed).to.be.true;