Skip to content

Commit b576c36

Browse files
committed
Support strictNullChecks and resetting the control
1 parent b1bb030 commit b576c36

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/demo-app/select/select-demo.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class SelectDemo {
1616
pokemonDisabled = false;
1717
showSelect = false;
1818
currentDrink: string;
19-
currentDrinkObject: {} = {value: 'tea-5', viewValue: 'Tea'};
19+
currentDrinkObject: {}|undefined = {value: 'tea-5', viewValue: 'Tea'};
2020
currentPokemon: string[];
2121
currentPokemonFromGroup: string;
2222
latestChangeEvent: MdSelectChange;
@@ -106,11 +106,7 @@ export class SelectDemo {
106106
}
107107

108108
setDrinkObjectByCopy(selectedDrink: {}) {
109-
if (selectedDrink) {
110-
this.currentDrinkObject = Object.assign({}, selectedDrink);
111-
} else {
112-
this.currentDrinkObject = undefined;
113-
}
109+
this.currentDrinkObject = selectedDrink ? {...selectedDrink} : undefined;
114110
}
115111

116112
compareDrinkObjectsByValue(d1: {value: string}, d2: {value: string}) {

src/lib/select/select.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
623623
const optionsArray = this.options.toArray();
624624

625625
const correspondingOption = optionsArray.find((option: MdOption) => {
626+
// Treat null as a special reset value.
627+
if (option.value === null) {
628+
return false;
629+
}
626630
try {
627631
return this._compareWith(option.value, value);
628632
} catch (error) {

0 commit comments

Comments
 (0)