fix(ivy): inconsistent value returned by DebugNode.context (#31442)

Fixes Ivy's return value for `DebugNode.context` not being consistent for the case where there is both a structural directive and a component on a node. In `ViewEngine` the instance of the component would be returned, whereas in Ivy the context of the directive is returned.

Also adds a couple of extra test cases for how `DebugNode.context` deals with directives.

This PR resolves FW-1343.

PR Close #31442
This commit is contained in:
crisbeto
2019-07-07 12:17:37 +02:00
committed by Jason Aden
parent 23e0d65471
commit 989ebcbb62
2 changed files with 48 additions and 1 deletions

View File

@ -220,7 +220,9 @@ class DebugNode__POST_R3__ implements DebugNode {
return nativeElement &&
(getComponent(nativeElement as Element) || getViewComponent(nativeElement));
}
get context(): any { return getContext(this.nativeNode as Element); }
get context(): any {
return getComponent(this.nativeNode as Element) || getContext(this.nativeNode as Element);
}
get listeners(): DebugEventListener[] {
return getListeners(this.nativeNode as Element).filter(isBrowserEvents);