Skip to content

Commit

Permalink
refactor(event-manager): rename EventManager to EventDelegator
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleuver committed Oct 21, 2020
1 parent e100eb4 commit 9150bb4
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Constructable } from '@aurelia/kernel';
import { BindingMode, CustomElement, IScheduler } from '@aurelia/runtime';
import { Aurelia, IEventManager, RuntimeHtmlConfiguration } from '@aurelia/runtime-html';
import { Aurelia, IEventDelegator, RuntimeHtmlConfiguration } from '@aurelia/runtime-html';
import { TestContext, eachCartesianJoin, eachCartesianJoinAsync, assert } from '@aurelia/testing';
import { ClassAttributePattern } from './attribute-pattern';

Expand Down Expand Up @@ -196,7 +196,7 @@ describe('template-compiler.binding-commands.class', function () {
);
await testCase.assert(au, scheduler, host, component, testCase, className);
} finally {
const em = ctx.container.get(IEventManager);
const em = ctx.container.get(IEventDelegator);
em.dispose();
tearDown();
await au.stop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Constructable, PLATFORM } from '@aurelia/kernel';
import { CustomElement, IScheduler } from '@aurelia/runtime';
import { Aurelia, IEventManager, RuntimeHtmlConfiguration } from '@aurelia/runtime-html';
import { Aurelia, IEventDelegator, RuntimeHtmlConfiguration } from '@aurelia/runtime-html';
import { assert, eachCartesianJoin, TestContext } from '@aurelia/testing';
import { StyleAttributePattern } from './attribute-pattern';

Expand Down Expand Up @@ -243,7 +243,7 @@ describe('template-compiler.binding-commands.style', function () {

await testCase.assert(au, scheduler, host, component, [ruleName, ruleValue, ruleDefaultValue, isInvalid, valueOnInvalid], testCase);
} finally {
const em = ctx.container.get(IEventManager);
const em = ctx.container.get(IEventDelegator);
em.dispose();
tearDown();
await au.stop();
Expand Down
6 changes: 3 additions & 3 deletions packages/__tests__/3-runtime-html/binding-commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('binding-commands', function () {
});

// import { Aurelia, CustomElement as CE, IViewModel, LifecycleFlags as LF } from '@aurelia/runtime';
// import { IEventManager } from '@aurelia/runtime-html';
// import { IEventDelegator } from '@aurelia/runtime-html';
// import { HTMLTestContext, TestContext, TestConfiguration, setupAndStart, setupWithDocumentAndStart, tearDown } from '@aurelia/testing';

// // TemplateCompiler - Binding Commands integration
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('binding-commands', function () {
// host.firstChild.dispatchEvent(new ctx.CustomEvent('click', { bubbles: true }));
// expect(component.doStuff).to.have.been.called;
// } finally {
// const em = ctx.container.get(IEventManager);
// const em = ctx.container.get(IEventDelegator);
// em.dispose();
// tearDown(au, lifecycle, host);
// }
Expand All @@ -310,7 +310,7 @@ describe('binding-commands', function () {
// host.firstChild.dispatchEvent(new ctx.CustomEvent('click', { bubbles: true }));
// expect(component.doStuff).to.have.been.called;
// } finally {
// const em = ctx.container.get(IEventManager);
// const em = ctx.container.get(IEventDelegator);
// em.dispose();
// tearDown(au, lifecycle, host);
// }
Expand Down
16 changes: 8 additions & 8 deletions packages/__tests__/3-runtime-html/event-manager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IDisposable } from '@aurelia/kernel';
import {
EventManager,
EventDelegator,
EventSubscriber,
} from '@aurelia/runtime-html';
import { _, TestContext, assert, createSpy } from '@aurelia/testing';
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('ListenerTracker', function () {
};
}
}
const sut = new EventManager();
const sut = new EventDelegator();
const el = ctx.createElement('div');
el.addEventListener(eventName, copyHandler(), capture);
ctx.doc.body.appendChild(el);
Expand Down Expand Up @@ -241,10 +241,10 @@ describe('EventSubscriber', function () {
}
});

describe('EventManager', function () {
describe('EventDelegator', function () {

// it(`initializes with correct default element configurations`, function () {
// const sut = new EventManager();
// const sut = new EventDelegator();
// const lookup = sut.elementHandlerLookup;

// assert.strictEqual(lookup['INPUT']['value'].length, 2, `lookup['INPUT']['value'].length`);
Expand Down Expand Up @@ -280,7 +280,7 @@ describe('EventManager', function () {
// });

// it(`registerElementConfiguration() registers the configuration`, function () {
// const sut = new EventManager();
// const sut = new EventDelegator();
// sut.registerElementConfiguration({
// tagName: 'FOO',
// properties: {
Expand All @@ -294,7 +294,7 @@ describe('EventManager', function () {
// });

// it(`registerElementConfiguration() does not register configuration from higher up the prototype chain`, function () {
// const sut = new EventManager();
// const sut = new EventDelegator();
// class ElementProperties {
// public bar: string[];
// constructor() {
Expand All @@ -313,7 +313,7 @@ describe('EventManager', function () {
// });

// describe(`getElementHandler()`, function () {
// const sut = new EventManager();
// const sut = new EventDelegator();
// const lookup = sut.elementHandlerLookup;

// for (let tagName in lookup) {
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('EventManager', function () {
parentListener = { handleEvent: parentHandler };
}

const sut = new EventManager();
const sut = new EventDelegator();
const wrapper = ctx.createElement('div');
const parentEl = ctx.createElement('parent-div');
const childEl = ctx.createElement('child-div');
Expand Down
4 changes: 2 additions & 2 deletions packages/aurelia/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,12 @@ export {
// DelegateOrCaptureSubscription,
// TriggerSubscription,
// IElementConfiguration,
// IEventManager,
// IEventDelegator,
// IEventSubscriber,
// IEventTargetWithLookups,
// EventSubscriber,
// EventSubscription,
// EventManager,
// EventDelegator,

// TargetAccessorLocator,
// TargetObserverLocator,
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-html/src/binding/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IsBindingBehavior,
LifecycleFlags,
} from '@aurelia/runtime';
import { IEventManager } from '../observation/event-manager';
import { IEventDelegator } from '../observation/event-delegator';

import type { Scope } from '@aurelia/runtime';
import { HTMLDOM } from '../dom';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class Listener implements IBinding {
public sourceExpression: IsBindingBehavior,
public target: Node,
public preventDefault: boolean,
public eventManager: IEventManager,
public eventDelegator: IEventDelegator,
public locator: IServiceLocator,
) {}

Expand Down Expand Up @@ -79,7 +79,7 @@ export class Listener implements IBinding {
if (this.delegationStrategy === DelegationStrategy.none) {
this.target.addEventListener(this.targetEvent, this);
} else {
this.handler = this.eventManager.addEventListener(
this.handler = this.eventDelegator.addEventListener(
this.dom.document,
this.target,
this.targetEvent,
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-html/src/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
} from '@aurelia/runtime';
import { AttributeBinding } from './binding/attribute';
import { Listener } from './binding/listener';
import { IEventManager } from './observation/event-manager';
import { IEventDelegator } from './observation/event-delegator';
import {
AttributeBindingInstruction,
CallBindingInstruction,
Expand Down Expand Up @@ -595,7 +595,7 @@ export class TextBindingComposer implements IInstructionComposer {
export class ListenerBindingComposer implements IInstructionComposer {
public constructor(
@IExpressionParser private readonly parser: IExpressionParser,
@IEventManager private readonly eventManager: IEventManager,
@IEventDelegator private readonly eventDelegator: IEventDelegator,
) {}

public compose(
Expand All @@ -608,7 +608,7 @@ export class ListenerBindingComposer implements IInstructionComposer {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
const expr = ensureExpression(this.parser, instruction.from, BindingType.IsEventCommand | (instruction.strategy + BindingType.DelegationStrategyDelta));
const binding = applyBindingBehavior(
new Listener(context.dom as HTMLDOM, instruction.to, instruction.strategy, expr, target, instruction.preventDefault, this.eventManager, context),
new Listener(context.dom as HTMLDOM, instruction.to, instruction.strategy, expr, target, instruction.preventDefault, this.eventDelegator, context),
expr,
context,
);
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-html/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export {
ElementPropertyAccessor
} from './observation/element-property-accessor';
export {
IEventManager,
IEventDelegator,
IEventSubscriber,
EventSubscriber,
EventManager
} from './observation/event-manager';
EventDelegator
} from './observation/event-delegator';
export {
TargetAccessorLocator,
TargetObserverLocator
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-html/src/observation/checked-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ILifecycle,
AccessorType,
} from '@aurelia/runtime';
import { IEventSubscriber } from './event-manager';
import { IEventSubscriber } from './event-delegator';
import { ValueAttributeObserver } from './value-attribute-observer';

type RepeatableCollection = unknown[] | Set<unknown> | Map<unknown, unknown>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ export class EventSubscriber implements IEventSubscriber {
}
}

export interface IEventManager extends EventManager {}
export const IEventManager = DI.createInterface<IEventManager>('IEventManager').withDefault(x => x.singleton(EventManager));
export interface IEventDelegator extends EventDelegator {}
export const IEventDelegator = DI.createInterface<IEventDelegator>('IEventDelegator').withDefault(x => x.singleton(EventDelegator));

export class EventManager implements IDisposable {
export class EventDelegator implements IDisposable {
private readonly trackerMaps: Record<string, Map<EventTarget, ListenerTracker> | undefined> = Object.create(null);

public constructor() { /* do not remove, is necessary for fulfilling the TS (new() => ...) type */ }
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-html/src/observation/observer-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CheckedObserver, IInputElement } from './checked-observer';
import { ClassAttributeAccessor } from './class-attribute-accessor';
import { DataAttributeAccessor } from './data-attribute-accessor';
import { ElementPropertyAccessor } from './element-property-accessor';
import { EventSubscriber } from './event-manager';
import { EventSubscriber } from './event-delegator';
import { ISelectElement, SelectValueObserver } from './select-value-observer';
import { StyleAttributeAccessor } from './style-attribute-accessor';
import { ISVGAnalyzer } from './svg-analyzer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ITask,
AccessorType,
} from '@aurelia/runtime';
import { IEventSubscriber } from './event-manager';
import { IEventSubscriber } from './event-delegator';
import { bound } from '@aurelia/kernel';

const childObserverOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ITask,
AccessorType,
} from '@aurelia/runtime';
import { IEventSubscriber } from './event-manager';
import { IEventSubscriber } from './event-delegator';

export interface ValueAttributeObserver
extends ISubscriberCollection {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Writable } from '@aurelia/kernel';
import { BindingMode, IDOM, IObserverLocator, LifecycleFlags, PropertyBinding, bindingBehavior } from '@aurelia/runtime';
import { CheckedObserver } from '../../observation/checked-observer';
import { EventSubscriber, IEventSubscriber } from '../../observation/event-manager';
import { EventSubscriber, IEventSubscriber } from '../../observation/event-delegator';
import { SelectValueObserver } from '../../observation/select-value-observer';
import { ValueAttributeObserver } from '../../observation/value-attribute-observer';

Expand Down

0 comments on commit 9150bb4

Please sign in to comment.