Skip to content

Commit

Permalink
fix(host): don't override input changes
Browse files Browse the repository at this point in the history
fix #31
  • Loading branch information
Netanel Basal committed Jun 26, 2018
1 parent 9b8b256 commit 054a3c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/app/auto-focus.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, ElementRef, Input } from '@angular/core';
import { Directive, ElementRef, Input } from "@angular/core";

@Directive({
selector: '[datoAutoFocus]'
selector: "[datoAutoFocus]"
})
export class AutoFocusDirective {
@Input()
Expand All @@ -12,4 +12,6 @@ export class AutoFocusDirective {
}

public constructor(private host: ElementRef) {}
}

method() {}
}
5 changes: 4 additions & 1 deletion src/lib/src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ export function createHostComponentFactory<C, H = HostComponent>(options: Specta
spectatorWithHost.element = spectatorWithHost.debugElement.nativeElement;
}

if (detectChanges) {
spectatorWithHost.hostFixture.detectChanges();
}

if (initialInputs) {
spectatorWithHost.setInput(initialInputs);
}

if (detectChanges) {
spectatorWithHost.hostFixture.detectChanges();
/** Detect changes on the component - useful for onPushComponents */
spectatorWithHost.detectComponentChanges();
}
Expand Down

0 comments on commit 054a3c2

Please sign in to comment.