Skip to content

Commit

Permalink
Support strictNullChecks and resetting the control
Browse files Browse the repository at this point in the history
  • Loading branch information
ppham27 committed Jun 22, 2017
1 parent 45a8b6e commit 96a1be1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/demo-app/select/select-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SelectDemo {
pokemonDisabled = false;
showSelect = false;
currentDrink: string;
currentDrinkObject: {} = {value: 'tea-5', viewValue: 'Tea'};
currentDrinkObject: {}|undefined = {value: 'tea-5', viewValue: 'Tea'};
currentPokemon: string[];
currentPokemonFromGroup: string;
latestChangeEvent: MdSelectChange;
Expand Down Expand Up @@ -106,11 +106,7 @@ export class SelectDemo {
}

setDrinkObjectByCopy(selectedDrink: {}) {
if (selectedDrink) {
this.currentDrinkObject = Object.assign({}, selectedDrink);
} else {
this.currentDrinkObject = undefined;
}
this.currentDrinkObject = selectedDrink ? {...selectedDrink} : undefined;
}

compareDrinkObjectsByValue(d1: {value: string}, d2: {value: string}) {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
const optionsArray = this.options.toArray();

const correspondingOption = optionsArray.find((option: MdOption) => {
// Treat null as a special reset value.
if (option.value === null) {
return false;
}
try {
return this._compareWith(option.value, value);
} catch (error) {
Expand Down

0 comments on commit 96a1be1

Please sign in to comment.