diff --git a/modules/angular2/src/facade/collection.es6 b/modules/angular2/src/facade/collection.es6 index 87660e5950..70e392f8d2 100644 --- a/modules/angular2/src/facade/collection.es6 +++ b/modules/angular2/src/facade/collection.es6 @@ -93,9 +93,9 @@ export class ListWrapper { static map(array, fn) { return array.map(fn); } - static forEach(array, fn) { - for(var p of array) { - fn(p); + static forEach(array:List, fn:Function) { + for (var i = 0; i < array.length; i++) { + fn(array[i]); } } static push(array, el) { @@ -198,8 +198,16 @@ export function isListLikeIterable(obj):boolean { } export function iterateListLike(obj, fn:Function) { - for (var item of obj) { - fn(item); + if (ListWrapper.isList(obj)) { + for (var i = 0; i < obj.length; i++) { + fn(obj[i]); + } + } else { + var iterator = obj[Symbol.iterator](); + var item; + while (!((item = iterator.next()).done)) { + fn(item.value); + } } } diff --git a/modules/rtts_assert/src/rtts_assert.es6 b/modules/rtts_assert/src/rtts_assert.es6 index 6c4e3991b5..1ef8afef42 100644 --- a/modules/rtts_assert/src/rtts_assert.es6 +++ b/modules/rtts_assert/src/rtts_assert.es6 @@ -259,8 +259,8 @@ var number = type.number = define('number', function(value) { function arrayOf(...types) { return assert.define('array of ' + types.map(prettyPrint).join('/'), function(value) { if (assert(value).is(Array)) { - for (var item of value) { - assert(item).is(...types); + for (var i = 0; i < value.length; i++) { + assert(value[i]).is(...types); } } }); @@ -270,7 +270,8 @@ function structure(definition) { var properties = Object.keys(definition); return assert.define('object with properties ' + properties.join(', '), function(value) { if (assert(value).is(Object)) { - for (var property of properties) { + for (var i = 0; i < properties.length; i++) { + var property = properties[i]; assert(value[property]).is(definition[property]); } } @@ -318,8 +319,8 @@ function assert(value) { // var errors = [] var allErrors = []; var errors; - - for (var type of types) { + for (var i = 0; i < types.length; i++) { + var type = types[i]; errors = []; if (isType(value, type, errors)) {