diff --git a/src/converters.js b/src/converters.js
index 0b1a725..cea90a5 100644
--- a/src/converters.js
+++ b/src/converters.js
@@ -602,13 +602,15 @@ export function modelChangePostFixer( model, writer ) {
// In case of renamed element.
const item = entry.position.nodeAfter;
- if ( item.hasAttribute( 'indent' ) ) {
+ // Only remove 'indent' attribute from items that doesn't allow such attribute. #103
+ if ( item.hasAttribute( 'indent' ) && !model.schema.checkAttribute( item, 'indent' ) ) {
writer.removeAttribute( 'indent', item );
applied = true;
}
- if ( item.hasAttribute( 'type' ) ) {
+ // Only remove 'type' attribute from items that doesn't allow such attribute. #103
+ if ( item.hasAttribute( 'type' ) && !model.schema.checkAttribute( item, 'type' ) ) {
writer.removeAttribute( 'type', item );
applied = true;
diff --git a/tests/listediting.js b/tests/listediting.js
index e57fe8d..0cff6dd 100644
--- a/tests/listediting.js
+++ b/tests/listediting.js
@@ -45,6 +45,13 @@ describe( 'ListEditing', () => {
view = editor.editing.view;
viewDoc = view.document;
viewRoot = viewDoc.getRoot();
+
+ model.schema.register( 'foo', {
+ allowWhere: '$block',
+ allowAttributes: [ 'indent', 'type' ],
+ isBlock: true,
+ isObject: true
+ } );
} );
} );
@@ -3279,6 +3286,22 @@ describe( 'ListEditing', () => {
expect( getModelData( model, { withoutSelection: true } ) ).to.equal( expectedModel );
} );
+
+ it( 'should not remove attributes from elements that allows that attributes', () => {
+ const modelBefore =
+ 'a' +
+ 'b' +
+ '';
+
+ const expectedModel =
+ 'a' +
+ 'b' +
+ '';
+
+ setModelData( model, modelBefore );
+
+ expect( getModelData( model, { withoutSelection: true } ) ).to.equal( expectedModel );
+ } );
} );
} );