Skip to content
Closed
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
21 changes: 20 additions & 1 deletion modules/angular2/src/facade/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,26 @@ export function iterateListLike(obj, fn: Function) {
}
}


// Safari and Internet Explorer do not support the iterable parameter to the
// Set constructor. We work around that by manually adding the items.
var createSetFromList: {(lst: List<any>): Set<any>} = (function() {
var test = new Set([1, 2, 3]);
if (test.size === 3) {
return function createSetFromList(lst: List<any>): Set<any> { return new Set(lst); };
} else {
return function createSetAndPopulateFromList(lst: List<any>): Set<any> {
var res = new Set(lst);
if (res.size !== lst.length) {
for (var i = 0; i < lst.length; i++) {
res.add(lst[i]);
}
}
return res;
};
}
})();
export class SetWrapper {
static createFromList<T>(lst: List<T>): Set<T> { return new Set(lst); }
static createFromList<T>(lst: List<T>): Set<T> { return createSetFromList(lst); }
static has<T>(s: Set<T>, key: T): boolean { return s.has(key); }
}