refactor(zone.js): remove usages of blacklist related to UNPATCHED_EVENTS (#38930)

Remove usages of blacklist around UNPATCHED_EVENTS configuration

PR Close #38930
This commit is contained in:
Joey Perrott 2020-09-21 14:27:44 -07:00 committed by Misko Hevery
parent ba3f4c26bb
commit 75610505c6
3 changed files with 26 additions and 26 deletions

View File

@ -127,10 +127,10 @@ ZoneAwareError makes sure that `this` is ZoneAwareError even without new.
ZoneAwarePromise wraps the global Promise and makes it run in zones as a MicroTask.
It also passes promise A+ tests.
## BlackListEvents
## UnpatchedEvents
Sometimes we don't want some `event` to be patched by `zone.js`, we can blacklist events
by following settings.
Sometimes we don't want some `event` to be patched by `zone.js`, we can instruct zone.js to leave
these `event` to be unpatched by following settings.
```javascript
// disable on properties
@ -144,5 +144,5 @@ by following settings.
});
// disable addEventListener
global['__zone_symbol__BLACK_LISTED_EVENTS'] = ['scroll'];
global['__zone_symbol__UNPATCHED_EVENTS'] = ['scroll'];
```

View File

@ -351,7 +351,7 @@ export function patchEventTarget(
const compare =
(patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate;
const blackListedEvents: string[] = (Zone as any)[zoneSymbol('BLACK_LISTED_EVENTS')];
const unpatchedEvents: string[] = (Zone as any)[zoneSymbol('UNPATCHED_EVENTS')];
const passiveEvents: string[] = _global[zoneSymbol('PASSIVE_EVENTS')];
const makeAddListener = function(
@ -391,10 +391,10 @@ export function patchEventTarget(
passiveSupported && !!passiveEvents && passiveEvents.indexOf(eventName) !== -1;
const options = buildEventListenerOptions(arguments[2], passive);
if (blackListedEvents) {
// check black list
for (let i = 0; i < blackListedEvents.length; i++) {
if (eventName === blackListedEvents[i]) {
if (unpatchedEvents) {
// check upatched list
for (let i = 0; i < unpatchedEvents.length; i++) {
if (eventName === unpatchedEvents[i]) {
if (passive) {
return nativeListener.call(target, eventName, delegate, options);
} else {

View File

@ -1154,10 +1154,10 @@ describe('Zone', function() {
it('should not be passive with global variable defined with passive false option', () => {
testPassive('touchstart', 'defaultPrevented', {passive: false});
});
it('should be passive with global variable defined and also blacklisted', () => {
it('should be passive with global variable defined and also unpatched', () => {
testPassive('scroll', 'default will run', undefined);
});
it('should not be passive without global variable defined and also blacklisted', () => {
it('should not be passive without global variable defined and also unpatched', () => {
testPassive('wheel', 'defaultPrevented', undefined);
});
});
@ -1376,7 +1376,7 @@ describe('Zone', function() {
let hookSpy2 = jasmine.createSpy('spy2');
let hookSpy3 = jasmine.createSpy('spy3');
let logs: string[] = [];
const isBlacklistedEvent = function(source: string) {
const isUnpatchedEvent = function(source: string) {
return source.lastIndexOf('click') !== -1;
};
const zone1 = Zone.current.fork({
@ -1385,7 +1385,7 @@ describe('Zone', function() {
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
any => {
if ((task.type === 'eventTask' || task.type === 'macroTask') &&
isBlacklistedEvent(task.source)) {
isUnpatchedEvent(task.source)) {
task.cancelScheduleRequest();
return zone2.scheduleTask(task);