File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
modules/angular2/src/facade Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,26 @@ export function iterateListLike(obj, fn: Function) {
233233 }
234234}
235235
236+
237+ // Safari and Internet Explorer do not support the iterable parameter to the
238+ // Set constructor. We work around that by manually adding the items.
239+ var createSetFromList : { ( lst : List < any > ) : Set < any > } = ( function ( ) {
240+ var test = new Set ( [ 1 , 2 , 3 ] ) ;
241+ if ( test . size === 3 ) {
242+ return function createSetFromList ( lst : List < any > ) : Set < any > { return new Set ( lst ) ; } ;
243+ } else {
244+ return function createSetAndPopulateFromList ( lst : List < any > ) : Set < any > {
245+ var res = new Set ( lst ) ;
246+ if ( res . size !== lst . length ) {
247+ for ( var i = 0 ; i < lst . length ; i ++ ) {
248+ res . add ( lst [ i ] ) ;
249+ }
250+ }
251+ return res ;
252+ } ;
253+ }
254+ } ) ( ) ;
236255export class SetWrapper {
237- static createFromList < T > ( lst : List < T > ) : Set < T > { return new Set ( lst ) ; }
256+ static createFromList < T > ( lst : List < T > ) : Set < T > { return createSetFromList ( lst ) ; }
238257 static has < T > ( s : Set < T > , key : T ) : boolean { return s . has ( key ) ; }
239258}
You can’t perform that action at this time.
0 commit comments