Skip to content

Commit

Permalink
fix(event): fix angular#911, in IE, event handler event maybe undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion committed Sep 22, 2017
1 parent a1344fc commit e027594
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export function patchEventTarget(

// global shared zoneAwareCallback to handle all event callback with capture = false
const globalZoneAwareCallback = function(event: Event) {
// https://github.com/angular/zone.js/issues/911, in IE, sometimes
// event will be undefined, so we need to use window.event
event = event || _global.event;
if (!event) {
return;
}
Expand Down Expand Up @@ -123,6 +126,9 @@ export function patchEventTarget(

// global shared zoneAwareCallback to handle all event callback with capture = true
const globalZoneAwareCaptureCallback = function(event: Event) {
// https://github.com/angular/zone.js/issues/911, in IE, sometimes
// event will be undefined, so we need to use window.event
event = event || _global.event;
if (!event) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const isMix: boolean = typeof _global.process !== 'undefined' &&
{}.toString.call(_global.process) === '[object process]' && !isWebWorker &&
!!(typeof window !== 'undefined' && (window as any)['HTMLElement']);

const ON_PROPERTY_HANDLER_SYMBOL = zoneSymbol('onPropertyHandler');
const zoneSymbolEventNames: {[eventName: string]: string} = {};

const wrapFn = function(event: Event) {
Expand All @@ -101,7 +100,7 @@ const wrapFn = function(event: Event) {
if (!eventNameSymbol) {
eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type);
}
const target = this || event && event.target || _global;
const target = this || event.target || _global;
const listener = target[eventNameSymbol];
let result = listener && listener.apply(this, arguments);

Expand Down

0 comments on commit e027594

Please sign in to comment.