Procházet zdrojové kódy

Added code comments.

Kuba Niegowski před 5 roky
rodič
revize
16a1e0bf70

+ 4 - 0
packages/ckeditor5-engine/src/model/model.js

@@ -812,6 +812,7 @@ export default class Model {
 	 * Fixes all empty roots.
 	 *
 	 * @protected
+	 * @param {module:engine/model/writer~Writer} writer The model writer.
 	 * @returns {Boolean} `true` if any change has been applied, `false` otherwise.
 	 */
 	_autoparagraphEmptyRoots( writer ) {
@@ -825,6 +826,9 @@ export default class Model {
 				if ( schema.checkChild( root, 'paragraph' ) ) {
 					writer.insertElement( 'paragraph', root );
 
+					// Other roots will get fixed in the next post-fixer round. Those will be triggered
+					// in the same batch no matter if this method was triggered by the post-fixing or not
+					// (the above insertElement call will trigger the post-fixers).
 					return true;
 				}
 			}

+ 1 - 1
packages/ckeditor5-engine/tests/controller/datacontroller.js

@@ -155,7 +155,7 @@ describe( 'DataController', () => {
 
 			const viewFragment = new ViewDocumentFragment( viewDocument, [ parseView( 'foo' ) ] );
 
-			// Model fragment in root.
+			// Model fragment in root (note that it is auto-paragraphed because $text is not allowed directly in $root).
 			expect( stringify( data.toModel( viewFragment ) ) ).to.equal( '<paragraph>foo</paragraph>' );
 
 			// Model fragment in inline root.