diff --git a/packages/ckeditor5-engine/src/controller/datacontroller.js b/packages/ckeditor5-engine/src/controller/datacontroller.js
index 6090707dd9f..358637a3ea4 100644
--- a/packages/ckeditor5-engine/src/controller/datacontroller.js
+++ b/packages/ckeditor5-engine/src/controller/datacontroller.js
@@ -208,7 +208,7 @@ export default class DataController {
* @param {Object} [options] Additional configuration passed to the conversion process.
* @returns {String} Output data.
*/
- stringify( modelElementOrFragment, options ) {
+ stringify( modelElementOrFragment, options = {} ) {
// Model -> view.
const viewDocumentFragment = this.toView( modelElementOrFragment, options );
@@ -224,11 +224,11 @@ export default class DataController {
*
* @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} modelElementOrFragment
* Element or document fragment whose content will be converted.
- * @param {Object} [options] Additional configuration that will be available through
+ * @param {Object} [options={}] Additional configuration that will be available through
* {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi#options} during the conversion process.
* @returns {module:engine/view/documentfragment~DocumentFragment} Output view DocumentFragment.
*/
- toView( modelElementOrFragment, options ) {
+ toView( modelElementOrFragment, options = {} ) {
const viewDocument = this.viewDocument;
const viewWriter = this._viewWriter;
diff --git a/packages/ckeditor5-engine/tests/controller/datacontroller.js b/packages/ckeditor5-engine/tests/controller/datacontroller.js
index e31176bde86..9ba1ccea34e 100644
--- a/packages/ckeditor5-engine/tests/controller/datacontroller.js
+++ b/packages/ckeditor5-engine/tests/controller/datacontroller.js
@@ -376,41 +376,34 @@ describe( 'DataController', () => {
} );
describe( 'get()', () => {
- it( 'should get paragraph with text', () => {
+ beforeEach( () => {
schema.register( 'paragraph', { inheritAllFrom: '$block' } );
- setData( model, '
foo
' ); expect( data.get( { trim: 'empty' } ) ).to.equal( 'foo
' ); } ); it( 'should trim empty paragraph by default', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); setData( model, '' ); } ); it( 'should get two paragraphs', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); setData( model, '
foo
bar
' ); expect( data.get( { trim: 'empty' } ) ).to.equal( 'foo
bar
' ); } ); @@ -424,20 +417,15 @@ describe( 'DataController', () => { } ); it( 'should get paragraphs without bold', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); setData( model, 'foobar
' ); expect( data.get( { trim: 'empty' } ) ).to.equal( 'foobar
' ); } ); it( 'should get paragraphs with bold', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); setData( model, 'foobar
' ); @@ -445,13 +433,11 @@ describe( 'DataController', () => { } ); it( 'should get root name as a parameter', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); schema.extend( '$text', { allowIn: '$root' } ); setData( model, 'foo
' ); @@ -466,8 +452,6 @@ describe( 'DataController', () => { } ); it( 'should allow to provide additional options for retrieving data - insert conversion', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); - data.downcastDispatcher.on( 'insert:paragraph', ( evt, data, conversionApi ) => { conversionApi.consumable.consume( data.item, 'insert' ); @@ -487,7 +471,7 @@ describe( 'DataController', () => { } ); it( 'should allow to provide additional options for retrieving data - attribute conversion', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block', allowAttributes: [ 'foo' ] } ); + schema.extend( 'paragraph', { allowAttributes: [ 'foo' ] } ); downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } ); data.downcastDispatcher.on( 'attribute:foo', ( evt, data, conversionApi ) => { @@ -509,9 +493,6 @@ describe( 'DataController', () => { } ); it( 'should allow to provide additional options for retrieving data - addMarker conversion', () => { - schema.register( 'paragraph', { inheritAllFrom: '$block' } ); - downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } ); - data.downcastDispatcher.on( 'addMarker', ( evt, data, conversionApi ) => { if ( conversionApi.options.skipMarker ) { return; @@ -540,6 +521,15 @@ describe( 'DataController', () => { expect( data.get( { skipMarker: false } ) ).to.equal( 'f
foo
' ); } ); + + it( 'should pass default options value to converters', () => { + data.downcastDispatcher.on( 'insert:paragraph', ( evt, data, conversionApi ) => { + expect( conversionApi.options ).to.deep.equal( {} ); + } ); + + setData( model, '