Skip to content

Commit

Permalink
fix: do not set the id attribute for input[type=radio] form elements
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWolfZ committed Apr 22, 2018
1 parent 36ccaa3 commit cbfd654
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ This release requires TypeScript >=2.8.0 for the conditional type support.
* add `notEqualTo` validation function ([851a1ed](https://github.com/MrWolfZ/ngrx-forms/commit/851a1ed))
* enhance all form state reducers to match type signature for `ActionReducer` (they will still throw an error if the state is `undefined`) ([f3b5fea](https://github.com/MrWolfZ/ngrx-forms/commit/f3b5fea))

#### Bugfixes

* do not set the `id` attribute for `input[type=radio]` form elements, closes [#63](https://github.com/MrWolfZ/ngrx-forms/issues/63)

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

Expand Down
5 changes: 5 additions & 0 deletions src/control/e2e.spec/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ describe(RadioTestComponent.name, () => {
expect(element2.name).toBe(newId);
});

it('should not set the id of any element', () => {
expect(element1.id).not.toBe(INITIAL_STATE.id);
expect(element2.id).not.toBe(INITIAL_STATE.id);
});

it('should select the correct option initially', () => {
expect(element2.checked).toBe(true);
});
Expand Down
8 changes: 6 additions & 2 deletions src/view-adapter/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ function isAndroid(): boolean {
}

// tslint:disable:directive-class-suffix
// tslint:disable:directive-selector

// TODO: since this directive has a side-effect (setting the element's id attribute)
// it should not blacklist other types of inputs but instead it should somehow figure
// out whether it is the "active" view adapter and only perform its side effects if it
// is active
@Directive({
// tslint:disable-next-line:directive-selector
selector: 'input:not([type=checkbox])[ngrxFormControlState],textarea[ngrxFormControlState]',
selector: 'input:not([type=checkbox]):not([type=number]):not([type=radio]):not([type=range])[ngrxFormControlState],textarea[ngrxFormControlState]',
providers: [{
provide: NGRX_FORM_VIEW_ADAPTER,
useExisting: forwardRef(() => NgrxDefaultViewAdapter),
Expand Down

0 comments on commit cbfd654

Please sign in to comment.