Skip to content

Commit e3c1770

Browse files
committed
Support strictNullChecks and resetting the control
1 parent 2094b24 commit e3c1770

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
currentDigimon: string;
@@ -116,11 +116,7 @@ export class SelectDemo {
116116
}
117117

118118
setDrinkObjectByCopy(selectedDrink: {}) {
119-
if (selectedDrink) {
120-
this.currentDrinkObject = Object.assign({}, selectedDrink);
121-
} else {
122-
this.currentDrinkObject = undefined;
123-
}
119+
this.currentDrinkObject = selectedDrink ? {...selectedDrink} : undefined;
124120
}
125121

126122
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
@@ -714,6 +714,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
714714
const optionsArray = this.options.toArray();
715715

716716
const correspondingOption = optionsArray.find((option: MdOption) => {
717+
// Treat null as a special reset value.
718+
if (option.value === null) {
719+
return false;
720+
}
717721
try {
718722
return this._compareWith(option.value, value);
719723
} catch (error) {

0 commit comments

Comments
 (0)