Explorar o código

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

Szymon Cofalik %!s(int64=9) %!d(string=hai) anos
pai
achega
34fe707ca6
Modificáronse 1 ficheiros con 4 adicións e 9 borrados
  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 );
+		}
 	}
 
 	/**