fix(core): fix tests for uninitialized @Output error (#19116)
PR Close #19116
This commit is contained in:

committed by
Igor Minar

parent
adf510f986
commit
183757daa2
@ -21,6 +21,7 @@ export function isPromise(obj: any): obj is Promise<any> {
|
||||
* Determine if the argument is an Observable
|
||||
*/
|
||||
export function isObservable(obj: any | Observable<any>): obj is Observable<any> {
|
||||
// TODO: use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
|
||||
// TODO: use isObservable once we update pass rxjs 6.1
|
||||
// https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#610-2018-05-03
|
||||
return !!obj && typeof obj.subscribe === 'function';
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import {TemplateRef} from '../linker/template_ref';
|
||||
import {ViewContainerRef} from '../linker/view_container_ref';
|
||||
import {Renderer as RendererV1, Renderer2} from '../render/api';
|
||||
import {stringify} from '../util';
|
||||
import {isObservable} from '../util/lang';
|
||||
|
||||
import {createChangeDetectorRef, createInjector, createRendererV1} from './refs';
|
||||
import {BindingDef, BindingFlags, DepDef, DepFlags, NodeDef, NodeFlags, OutputDef, OutputType, ProviderData, QueryValueType, Services, ViewData, ViewFlags, ViewState, asElementData, asProviderData, shouldCallLifecycleInitHook} from './types';
|
||||
@ -138,7 +139,7 @@ export function createDirectiveInstance(view: ViewData, def: NodeDef): any {
|
||||
for (let i = 0; i < def.outputs.length; i++) {
|
||||
const output = def.outputs[i];
|
||||
const outputObservable = instance[output.propName !];
|
||||
if (typeof outputObservable === 'object') {
|
||||
if (isObservable(outputObservable)) {
|
||||
const subscription = outputObservable.subscribe(
|
||||
eventHandlerClosure(view, def.parent !.nodeIndex, output.eventName));
|
||||
view.disposables ![def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
|
||||
|
Reference in New Issue
Block a user