Skip to content

Commit

Permalink
fix: fix issue that caused select elements to get assigned wrong in…
Browse files Browse the repository at this point in the history
…itial value
  • Loading branch information
MrWolfZ committed Jan 17, 2018
1 parent 9163d74 commit d62ec81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## ngrx-forms Changelog

<a name="2.1.2"></a>
### 2.1.2

#### Bugfixes

* fix issue that caused `select` elements to get assigned wrong initial value, closes [#32](https://github.com/MrWolfZ/ngrx-forms/issues/32)

<a name="2.1.1"></a>
### 2.1.1

Expand Down
6 changes: 6 additions & 0 deletions src/view-adapter/select-multiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,10 @@ describe(NgrxSelectMultipleOption.name, () => {
it('should work if option is created without view adapter', () => {
expect(new NgrxSelectMultipleOption({} as any, {} as any, null as any)).toBeDefined();
});

it('ngOnInit should not change the element if no matching view adapter is injected', () => {
option = new NgrxSelectMultipleOption({} as any, renderer, null as any);
option.ngOnInit();
expect(renderer.setProperty).not.toHaveBeenCalled();
});
});
5 changes: 5 additions & 0 deletions src/view-adapter/select-multiple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ const NULL_VIEW_ADAPTER: NgrxSelectMultipleViewAdapter = {
updateOptionValue: () => void 0,
} as any;

const NULL_RENDERER: Renderer2 = {
setProperty: () => void 0,
} as any;

@Directive({
// tslint:disable-next-line:directive-selector
selector: 'option',
Expand All @@ -128,6 +132,7 @@ export class NgrxSelectMultipleOption implements OnInit, OnDestroy {
private renderer: Renderer2,
@Host() @Optional() private viewAdapter: NgrxSelectMultipleViewAdapter,
) {
this.renderer = viewAdapter ? renderer : NULL_RENDERER;
this.viewAdapter = viewAdapter || NULL_VIEW_ADAPTER;
this.id = this.viewAdapter.registerOption(this);
}
Expand Down

0 comments on commit d62ec81

Please sign in to comment.