11import { StringMap , Set } from 'angular2/src/facade/collection' ;
2+ import { isPresent } from 'angular2/src/facade/lang' ;
23
34const MOUSE_EVENT_PROPERTIES = [
45 "altKey" ,
@@ -41,10 +42,10 @@ export function serializeGenericEvent(e: Event): StringMap<string, any> {
4142}
4243
4344// TODO(jteplitz602): Allow users to specify the properties they need rather than always
44- // adding value #3374
45- export function serializeEventWithValue ( e : Event ) : StringMap < string , any > {
45+ // adding value and files #3374
46+ export function serializeEventWithTarget ( e : Event ) : StringMap < string , any > {
4647 var serializedEvent = serializeEvent ( e , EVENT_PROPERTIES ) ;
47- return addValue ( e , serializedEvent ) ;
48+ return addTarget ( e , serializedEvent ) ;
4849}
4950
5051export function serializeMouseEvent ( e : MouseEvent ) : StringMap < string , any > {
@@ -53,13 +54,17 @@ export function serializeMouseEvent(e: MouseEvent): StringMap<string, any> {
5354
5455export function serializeKeyboardEvent ( e : KeyboardEvent ) : StringMap < string , any > {
5556 var serializedEvent = serializeEvent ( e , KEYBOARD_EVENT_PROPERTIES ) ;
56- return addValue ( e , serializedEvent ) ;
57+ return addTarget ( e , serializedEvent ) ;
5758}
5859
5960// TODO(jteplitz602): #3374. See above.
60- function addValue ( e : Event , serializedEvent : StringMap < string , any > ) : StringMap < string , any > {
61+ function addTarget ( e : Event , serializedEvent : StringMap < string , any > ) : StringMap < string , any > {
6162 if ( NODES_WITH_VALUE . has ( ( < HTMLElement > e . target ) . tagName . toLowerCase ( ) ) ) {
62- serializedEvent [ 'target' ] = { 'value' : ( < HTMLInputElement > e . target ) . value } ;
63+ var target = < HTMLInputElement > e . target ;
64+ serializedEvent [ 'target' ] = { 'value' : target . value } ;
65+ if ( isPresent ( target . files ) ) {
66+ serializedEvent [ 'target' ] [ 'files' ] = target . files ;
67+ }
6368 }
6469 return serializedEvent ;
6570}
0 commit comments