8
0
Просмотр исходного кода

Fixed a special case when converter returns nothing.

Piotrek Koszuliński 9 лет назад
Родитель
Сommit
c7960c10a7

+ 4 - 0
packages/ckeditor5-paragraph/src/paragraph.js

@@ -188,6 +188,10 @@ function autoparagraphParagraphLikeElements( doc, evt, data, consumable, convers
 
 // Merges subsequent paragraphs if they should be merged (see shouldMerge).
 function mergeSubsequentParagraphs( evt, data ) {
+	if ( !data.output ) {
+		return;
+	}
+
 	let node;
 
 	if ( isArray( data.output ) ) {

+ 11 - 0
packages/ckeditor5-paragraph/tests/paragraph.js

@@ -179,6 +179,17 @@ describe( 'Paragraph feature', () => {
 				// for a while
 				expect( stringifyModel( modelFragment ) ).to.equal( '<paragraph>foobarbom</paragraph>' );
 			} );
+
+			// This test was taken from the list package.
+			it( 'does not break when some converter returns nothing', () => {
+				editor.data.viewToModel.on( 'element:li', ( evt, data, consumable ) => {
+					consumable.consume( data.input, { name: true } );
+				}, { priority: 'highest' } );
+
+				const modelFragment = editor.data.parse( '<ul><li></li></ul>' );
+
+				expect( stringifyModel( modelFragment ) ).to.equal( '' );
+			} );
 		} );
 
 		describe( 'generic block converter (paragraph-like element handling)', () => {