Sfoglia il codice sorgente

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

Szymon Cofalik 9 anni fa
parent
commit
34fe707ca6
1 ha cambiato i file con 4 aggiunte e 9 eliminazioni
  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 );
+		}
 	}
 
 	/**