Sfoglia il codice sorgente

Do not convert `todoListChecked` attribute on non-todo list item.

Oskar Wróbel 6 anni fa
parent
commit
d83be89806

+ 6 - 0
packages/ckeditor5-list/src/todolistconverters.js

@@ -262,6 +262,12 @@ export function modelViewChangeType( onCheckedChange ) {
  */
 export function modelViewChangeChecked( onCheckedChange ) {
 	return ( evt, data, conversionApi ) => {
+		// Do not convert `todoListChecked` attribute when todo list item has changed to other list item.
+		// This attribute will be removed by the model post fixer.
+		if ( data.item.getAttribute( 'listType' ) != 'todo' ) {
+			return;
+		}
+
 		if ( !conversionApi.consumable.consume( data.item, 'attribute:todoListChecked' ) ) {
 			return;
 		}

+ 8 - 2
packages/ckeditor5-list/tests/todolistediting.js

@@ -312,11 +312,17 @@ describe( 'TodoListEditing', () => {
 		} );
 
 		it( 'should remove todoListChecked attribute when checked todoListItem is changed to regular list item', () => {
-			setModelData( model, '<listItem listType="todo" listIndent="0" todoListChecked="true">fo[]o</listItem>' );
+			setModelData( model,
+				'<listItem listType="todo" listIndent="0">f[oo</listItem>' +
+				'<listItem listType="todo" listIndent="0" todoListChecked="true">fo]o</listItem>'
+			);
 
 			editor.execute( 'bulletedList' );
 
-			expect( getModelData( model ) ).to.equal( '<listItem listIndent="0" listType="bulleted">fo[]o</listItem>' );
+			expect( getModelData( model ) ).to.equal(
+				'<listItem listIndent="0" listType="bulleted">f[oo</listItem>' +
+				'<listItem listIndent="0" listType="bulleted">fo]o</listItem>'
+			);
 		} );
 
 		it( 'should be overwritable', () => {