Skip to content

Commit

Permalink
Remove IE8 event.target polyfill via srcElement
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Nov 10, 2017
1 parent 54051f9 commit 38dfbe3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ describe('SyntheticClipboardEvent', () => {
});

describe('EventInterface', () => {
it('normalizes properties from the Event interface', () => {
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});

expect(syntheticEvent.target).toBe(target);
expect(syntheticEvent.type).toBe(undefined);
});

it('is able to `preventDefault` and `stopPropagation`', () => {
var nativeEvent = {};
var syntheticEvent = createEvent(nativeEvent);
Expand Down
12 changes: 2 additions & 10 deletions packages/react-dom/src/events/__tests__/SyntheticEvent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ describe('SyntheticEvent', () => {
};
});

it('should normalize `target` from the nativeEvent', () => {
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});

expect(syntheticEvent.target).toBe(target);
expect(syntheticEvent.type).toBe(undefined);
});

it('should be able to `preventDefault`', () => {
var nativeEvent = {};
var syntheticEvent = createEvent(nativeEvent);
Expand Down Expand Up @@ -80,7 +72,7 @@ describe('SyntheticEvent', () => {
it('should be nullified if the synthetic event has called destructor and log warnings', () => {
spyOn(console, 'error');
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});
var syntheticEvent = createEvent({target});
syntheticEvent.destructor();
expect(syntheticEvent.type).toBe(null);
expect(syntheticEvent.nativeEvent).toBe(null);
Expand All @@ -100,7 +92,7 @@ describe('SyntheticEvent', () => {
it('should warn when setting properties of a destructored synthetic event', () => {
spyOn(console, 'error');
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});
var syntheticEvent = createEvent({target});
syntheticEvent.destructor();
expect((syntheticEvent.type = 'MouseEvent')).toBe('MouseEvent');
expectDev(console.error.calls.count()).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ describe('SyntheticKeyboardEvent', () => {
});

describe('EventInterface', () => {
it('normalizes properties from the Event interface', () => {
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});

expect(syntheticEvent.target).toBe(target);
expect(syntheticEvent.type).toBe(undefined);
});

it('is able to `preventDefault` and `stopPropagation`', () => {
var nativeEvent = {};
var syntheticEvent = createEvent(nativeEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ describe('SyntheticWheelEvent', () => {
};
});

it('should normalize properties from the Event interface', () => {
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});

expect(syntheticEvent.target).toBe(target);
expect(syntheticEvent.type).toBe(undefined);
});

it('should normalize properties from the MouseEvent interface', () => {
expect(createEvent({which: 2, button: 1}).button).toBe(1);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/getEventTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {TEXT_NODE} from '../shared/HTMLNodeType';
* @return {DOMEventTarget} Target node.
*/
function getEventTarget(nativeEvent) {
var target = nativeEvent.target || nativeEvent.srcElement || window;
var target = nativeEvent.target || window;

// Normalize SVG <use> element events #4963
if (target.correspondingUseElement) {
Expand Down

0 comments on commit 38dfbe3

Please sign in to comment.