Ver código fonte

Docs: Minor tweak in a code sample.

Szymon Cofalik 8 anos atrás
pai
commit
1410baba8b
1 arquivos alterados com 3 adições e 5 exclusões
  1. 3 5
      packages/ckeditor5-engine/src/model/document.js

+ 3 - 5
packages/ckeditor5-engine/src/model/document.js

@@ -322,17 +322,15 @@ export default class Document {
 	 *			const changes = document.differ.getChanges();
 	 *
 	 *			// Check if the changes lead to an empty root in an editor.
-	 *			let applied = false;
-	 *
 	 *			for ( const entry of changes ) {
 	 *				if ( entry.type == 'remove' && entry.position.root.isEmpty ) {
 	 *					writer.insertElement( 'paragraph', entry.position.root, 0 );
 	 *
-	 *					applied = true;
+	 *					// It is fine to return early, even if multiple roots would need to be fixed.
+	 *					// All post-fixers will be fired again, so if there more empty roots, those will be fixed too.
+	 *					return true;
 	 *				}
 	 *			}
-	 *
-	 *			return applied;
 	 *		} );
 	 *
 	 * @param {Function} postFixer