test(ivy): fix flaky tests (#23010)

PR Close #23010
This commit is contained in:
Kara Erickson 2018-03-26 23:41:38 -07:00 committed by Matias Niemelä
parent 910a16a1ff
commit f739f756ce
2 changed files with 4 additions and 6 deletions

View File

@ -572,9 +572,6 @@ class ViewContainerRef implements viewEngine_ViewContainerRef {
createEmbeddedView<C>( createEmbeddedView<C>(
templateRef: viewEngine_TemplateRef<C>, context?: C|undefined, templateRef: viewEngine_TemplateRef<C>, context?: C|undefined,
index?: number|undefined): viewEngine_EmbeddedViewRef<C> { index?: number|undefined): viewEngine_EmbeddedViewRef<C> {
// set current view to container node's view
enterView(this._node.view, null);
const viewRef = templateRef.createEmbeddedView(context !); const viewRef = templateRef.createEmbeddedView(context !);
this.insert(viewRef, index); this.insert(viewRef, index);
return viewRef; return viewRef;

View File

@ -431,9 +431,10 @@ export function renderEmbeddedTemplate<T>(
previousOrParentNode = null !; previousOrParentNode = null !;
let cm: boolean = false; let cm: boolean = false;
if (viewNode == null) { if (viewNode == null) {
// TODO: revisit setting currentView when re-writing view containers
const view = createLView( const view = createLView(
-1, renderer, createTView(currentView.tView.directiveRegistry), template, context, -1, renderer, createTView(currentView && currentView.tView.directiveRegistry), template,
LViewFlags.CheckAlways); context, LViewFlags.CheckAlways);
viewNode = createLNode(null, LNodeType.View, null, view); viewNode = createLNode(null, LNodeType.View, null, view);
cm = true; cm = true;
} }
@ -443,7 +444,7 @@ export function renderEmbeddedTemplate<T>(
refreshDynamicChildren(); refreshDynamicChildren();
refreshDirectives(); refreshDirectives();
} finally { } finally {
leaveView(currentView !.parent !); leaveView(currentView && currentView !.parent !);
isParent = _isParent; isParent = _isParent;
previousOrParentNode = _previousOrParentNode; previousOrParentNode = _previousOrParentNode;
} }