Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ function _extractId(valueString: string): string {

/**
* The accessor for writing a value and listening to changes on a select element.
*
* Note: We have to listen to the 'change' event because 'input' events aren't fired
* for selects in Firefox and IE:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1024350
* https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4660045/
*
*/
@Directive({
selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
host: {'(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()'},
host: {'(change)': 'onChange($event.target.value)', '(blur)': 'onTouched()'},
providers: [SELECT_VALUE_ACCESSOR]
})
export class SelectControlValueAccessor implements ControlValueAccessor {
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/test/common/forms/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export function main() {
expect(sfOption.nativeElement.selected).toBe(true);

select.nativeElement.value = "NYC";
dispatchEvent(select.nativeElement, "input");
dispatchEvent(select.nativeElement, "change");

expect(fixture.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
expect(sfOption.nativeElement.selected).toBe(false);
Expand Down Expand Up @@ -480,7 +480,7 @@ export function main() {
expect(nycOption.nativeElement.selected).toBe(true);

select.nativeElement.value = "2: Object";
dispatchEvent(select.nativeElement, "input");
dispatchEvent(select.nativeElement, "change");
fixture.detectChanges();
TimerWrapper.setTimeout(() => {
expect(testComp.selectedCity['name']).toEqual("Buffalo");
Expand Down