瀏覽代碼

Changed: use iterators and generators the way they should be used.

Szymon Cofalik 9 年之前
父節點
當前提交
34fe707ca6
共有 1 個文件被更改,包括 4 次插入9 次删除
  1. 4 9
      packages/ckeditor5-engine/src/treemodel/nodelist.js

+ 4 - 9
packages/ckeditor5-engine/src/treemodel/nodelist.js

@@ -189,15 +189,10 @@ export default class NodeList {
 	/**
 	 * Node list iterator.
 	 */
-	[ Symbol.iterator ]() {
-		let i = 0;
-
-		return {
-			next: () => ( {
-				done: i == this.length,
-				value: this.get( i++ )
-			} )
-		};
+	*[ Symbol.iterator ]() {
+		for ( let i = 0; i < this.length; i++ ) {
+			yield this.get( i );
+		}
 	}
 
 	/**