Skip to content

Commit

Permalink
fix(core): don't include a local EventListener in typings (#29809)
Browse files Browse the repository at this point in the history
With dts bundles, `core.d.ts` will include an `EventListener` class as it's used in https://github.com/angular/angular/blob/303eae918d997070a36b523ddc97e018f622c258/packages/core/src/debug/debug_node.ts#L32

This will conflict with the DOM EventListener, as anything in `core.d.ts` which is using the DOM EventListener will fallback in using the one defined in the same module and hence build will fail because their implementation is different.

With this change, we rename the local `EventListener` to `DebugEventListener`, the later one is non exported.

Fixes #29806

PR Close #29809
  • Loading branch information
alan-agius4 authored and benlesh committed Apr 17, 2019
1 parent 4271d35 commit 4bde40f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/core.ts
Expand Up @@ -22,7 +22,7 @@ export {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
export * from './zone'; export * from './zone';
export * from './render'; export * from './render';
export * from './linker'; export * from './linker';
export {DebugElement, DebugNode, asNativeElements, getDebugNode, Predicate} from './debug/debug_node'; export {DebugElement, DebugEventListener, DebugNode, asNativeElements, getDebugNode, Predicate} from './debug/debug_node';
export {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter} from './testability/testability'; export {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter} from './testability/testability';
export * from './change_detection'; export * from './change_detection';
export * from './platform_core_providers'; export * from './platform_core_providers';
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/debug/debug_node.ts
Expand Up @@ -21,15 +21,18 @@ import {getComponentViewByIndex, getNativeByTNode, isComponent, isLContainer} fr
import {assertDomNode} from '../util/assert'; import {assertDomNode} from '../util/assert';
import {DebugContext} from '../view/index'; import {DebugContext} from '../view/index';


export class EventListener { /**
* @publicApi
*/
export class DebugEventListener {
constructor(public name: string, public callback: Function) {} constructor(public name: string, public callback: Function) {}
} }


/** /**
* @publicApi * @publicApi
*/ */
export interface DebugNode { export interface DebugNode {
readonly listeners: EventListener[]; readonly listeners: DebugEventListener[];
readonly parent: DebugElement|null; readonly parent: DebugElement|null;
readonly nativeNode: any; readonly nativeNode: any;
readonly injector: Injector; readonly injector: Injector;
Expand All @@ -39,7 +42,7 @@ export interface DebugNode {
readonly providerTokens: any[]; readonly providerTokens: any[];
} }
export class DebugNode__PRE_R3__ { export class DebugNode__PRE_R3__ {
readonly listeners: EventListener[] = []; readonly listeners: DebugEventListener[] = [];
readonly parent: DebugElement|null = null; readonly parent: DebugElement|null = null;
readonly nativeNode: any; readonly nativeNode: any;
private readonly _debugContext: DebugContext; private readonly _debugContext: DebugContext;
Expand Down Expand Up @@ -219,7 +222,7 @@ class DebugNode__POST_R3__ implements DebugNode {
} }
get context(): any { return getContext(this.nativeNode as Element); } get context(): any { return getContext(this.nativeNode as Element); }


get listeners(): EventListener[] { get listeners(): DebugEventListener[] {
return getListeners(this.nativeNode as Element).filter(isBrowserEvents); return getListeners(this.nativeNode as Element).filter(isBrowserEvents);
} }


Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/view/services.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */


import {DebugElement__PRE_R3__, DebugNode__PRE_R3__, EventListener, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node'; import {DebugElement__PRE_R3__, DebugEventListener, DebugNode__PRE_R3__, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
import {Injector} from '../di'; import {Injector} from '../di';
import {InjectableType} from '../di/injectable'; import {InjectableType} from '../di/injectable';
import {getInjectableDef, ɵɵInjectableDef} from '../di/interface/defs'; import {getInjectableDef, ɵɵInjectableDef} from '../di/interface/defs';
Expand Down Expand Up @@ -827,7 +827,7 @@ export class DebugRenderer2 implements Renderer2 {
if (typeof target !== 'string') { if (typeof target !== 'string') {
const debugEl = getDebugNode(target); const debugEl = getDebugNode(target);
if (debugEl) { if (debugEl) {
debugEl.listeners.push(new EventListener(eventName, callback)); debugEl.listeners.push(new DebugEventListener(eventName, callback));
} }
} }


Expand Down
8 changes: 7 additions & 1 deletion tools/public_api_guard/core/core.d.ts
Expand Up @@ -224,11 +224,17 @@ export declare const DebugElement: {
new (...args: any[]): DebugElement; new (...args: any[]): DebugElement;
}; };


export declare class DebugEventListener {
callback: Function;
name: string;
constructor(name: string, callback: Function);
}

export interface DebugNode { export interface DebugNode {
readonly componentInstance: any; readonly componentInstance: any;
readonly context: any; readonly context: any;
readonly injector: Injector; readonly injector: Injector;
readonly listeners: EventListener[]; readonly listeners: DebugEventListener[];
readonly nativeNode: any; readonly nativeNode: any;
readonly parent: DebugElement | null; readonly parent: DebugElement | null;
readonly providerTokens: any[]; readonly providerTokens: any[];
Expand Down

0 comments on commit 4bde40f

Please sign in to comment.