|
10 | 10 | * @suppress {missingRequire}
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils'; |
| 13 | +import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, isIE, isIEOrEdge, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils'; |
14 | 14 |
|
15 | 15 | /** @internal **/
|
16 | 16 | interface EventTaskData extends TaskData {
|
17 | 17 | // use global callback or not
|
18 | 18 | readonly useG?: boolean;
|
19 | 19 | }
|
20 | 20 |
|
| 21 | +const pointerEventsMap: {[key: string]: string} = { |
| 22 | + 'MSPointerCancel': 'pointercancel', |
| 23 | + 'MSPointerDown': 'pointerdown', |
| 24 | + 'MSPointerEnter': 'pointerenter', |
| 25 | + 'MSPointerHover': 'pointerhover', |
| 26 | + 'MSPointerLeave': 'pointerleave', |
| 27 | + 'MSPointerMove': 'pointermove', |
| 28 | + 'MSPointerOut': 'pointerout', |
| 29 | + 'MSPointerOver': 'pointerover', |
| 30 | + 'MSPointerUp': 'pointerup' |
| 31 | +}; |
| 32 | + |
21 | 33 | let passiveSupported = false;
|
22 | 34 |
|
23 | 35 | if (typeof window !== 'undefined') {
|
@@ -87,6 +99,16 @@ export function patchEventTarget(
|
87 | 99 | const PREPEND_EVENT_LISTENER = 'prependListener';
|
88 | 100 | const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
|
89 | 101 |
|
| 102 | + Object.keys(pointerEventsMap).forEach(msEventName => { |
| 103 | + const eventName = pointerEventsMap[msEventName]; |
| 104 | + zoneSymbolEventNames[eventName] = {}; |
| 105 | + zoneSymbolEventNames[eventName][FALSE_STR] = ZONE_SYMBOL_PREFIX + eventName + FALSE_STR; |
| 106 | + zoneSymbolEventNames[eventName][TRUE_STR] = ZONE_SYMBOL_PREFIX + eventName + TRUE_STR; |
| 107 | + zoneSymbolEventNames[msEventName] = {}; |
| 108 | + zoneSymbolEventNames[msEventName][FALSE_STR] = ZONE_SYMBOL_PREFIX + msEventName + FALSE_STR; |
| 109 | + zoneSymbolEventNames[msEventName][TRUE_STR] = ZONE_SYMBOL_PREFIX + msEventName + TRUE_STR; |
| 110 | + }); |
| 111 | + |
90 | 112 | const invokeTask = function(task: any, target: any, event: Event) {
|
91 | 113 | // for better performance, check isRemoved which is set
|
92 | 114 | // by removeEventListener
|
@@ -122,7 +144,15 @@ export function patchEventTarget(
|
122 | 144 | // event.target is needed for Samsung TV and SourceBuffer
|
123 | 145 | // || global is needed https://github.com/angular/zone.js/issues/190
|
124 | 146 | const target: any = this || event.target || _global;
|
125 |
| - const tasks = target[zoneSymbolEventNames[event.type][FALSE_STR]]; |
| 147 | + let tasks = target[zoneSymbolEventNames[event.type][FALSE_STR]]; |
| 148 | + if (isIEOrEdge) { |
| 149 | + const pointerMappedEvent = pointerEventsMap[event.type]; |
| 150 | + const msTasks = |
| 151 | + pointerMappedEvent && target[zoneSymbolEventNames[pointerMappedEvent]][FALSE_STR]; |
| 152 | + if (msTasks) { |
| 153 | + tasks = tasks.concat(msTasks); |
| 154 | + } |
| 155 | + } |
126 | 156 | if (tasks) {
|
127 | 157 | // invoke all tasks which attached to current target with given event.type and capture = false
|
128 | 158 | // for performance concern, if task.length === 1, just invoke
|
@@ -154,7 +184,15 @@ export function patchEventTarget(
|
154 | 184 | // event.target is needed for Samsung TV and SourceBuffer
|
155 | 185 | // || global is needed https://github.com/angular/zone.js/issues/190
|
156 | 186 | const target: any = this || event.target || _global;
|
157 |
| - const tasks = target[zoneSymbolEventNames[event.type][TRUE_STR]]; |
| 187 | + let tasks = target[zoneSymbolEventNames[event.type][TRUE_STR]]; |
| 188 | + if (isIEOrEdge) { |
| 189 | + const pointerMappedEvent = pointerEventsMap[event.type]; |
| 190 | + const msTasks = |
| 191 | + pointerMappedEvent && target[zoneSymbolEventNames[pointerMappedEvent]][FALSE_STR]; |
| 192 | + if (msTasks) { |
| 193 | + tasks = tasks.concat(msTasks); |
| 194 | + } |
| 195 | + } |
158 | 196 | if (tasks) {
|
159 | 197 | // invoke all tasks which attached to current target with given event.type and capture = false
|
160 | 198 | // for performance concern, if task.length === 1, just invoke
|
@@ -350,7 +388,11 @@ export function patchEventTarget(
|
350 | 388 | return;
|
351 | 389 | }
|
352 | 390 |
|
353 |
| - const eventName = arguments[0]; |
| 391 | + let eventName = arguments[0]; |
| 392 | + if (isIEOrEdge) { |
| 393 | + const msEventName = pointerEventsMap[eventName]; |
| 394 | + eventName = msEventName ? msEventName : eventName; |
| 395 | + } |
354 | 396 | const options = arguments[2];
|
355 | 397 |
|
356 | 398 | if (blackListedEvents) {
|
@@ -393,6 +435,13 @@ export function patchEventTarget(
|
393 | 435 | }
|
394 | 436 | let existingTasks = target[symbolEventName];
|
395 | 437 | let isExisting = false;
|
| 438 | + if (isIEOrEdge && !existingTasks) { |
| 439 | + const msEventName = pointerEventsMap[eventName]; |
| 440 | + if (msEventName) { |
| 441 | + existingTasks = |
| 442 | + target[zoneSymbolEventNames[msEventName][capture ? TRUE_STR : FALSE_STR]]; |
| 443 | + } |
| 444 | + } |
396 | 445 | if (existingTasks) {
|
397 | 446 | // already have task registered
|
398 | 447 | isExisting = true;
|
@@ -427,7 +476,8 @@ export function patchEventTarget(
|
427 | 476 | }
|
428 | 477 | taskData.target = target;
|
429 | 478 | taskData.capture = capture;
|
430 |
| - taskData.eventName = eventName; |
| 479 | + // in pointer event, we need to use original event name here. |
| 480 | + taskData.eventName = arguments[0]; |
431 | 481 | taskData.isExisting = isExisting;
|
432 | 482 |
|
433 | 483 | const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined;
|
@@ -489,7 +539,11 @@ export function patchEventTarget(
|
489 | 539 |
|
490 | 540 | proto[REMOVE_EVENT_LISTENER] = function() {
|
491 | 541 | const target = this || _global;
|
492 |
| - const eventName = arguments[0]; |
| 542 | + let eventName = arguments[0]; |
| 543 | + if (isIEOrEdge) { |
| 544 | + const msEventName = pointerEventsMap[eventName]; |
| 545 | + eventName = msEventName ? msEventName : eventName; |
| 546 | + } |
493 | 547 | const options = arguments[2];
|
494 | 548 |
|
495 | 549 | let capture;
|
@@ -531,6 +585,9 @@ export function patchEventTarget(
|
531 | 585 | // remove globalZoneAwareCallback and remove the task cache from target
|
532 | 586 | (existingTask as any).allRemoved = true;
|
533 | 587 | target[symbolEventName] = null;
|
| 588 | + if (isIEOrEdge) { |
| 589 | + existingTask.eventName = arguments[0]; |
| 590 | + } |
534 | 591 | }
|
535 | 592 | existingTask.zone.cancelTask(existingTask);
|
536 | 593 | if (returnTarget) {
|
|
0 commit comments