diff --git a/packages/ckeditor5-engine/src/view/element.js b/packages/ckeditor5-engine/src/view/element.js index 0a0e36ec0d2..b88e75c729d 100644 --- a/packages/ckeditor5-engine/src/view/element.js +++ b/packages/ckeditor5-engine/src/view/element.js @@ -608,6 +608,9 @@ export default class Element extends Node { // is changed by e.g. toWidget() function from ckeditor5-widget. Perhaps this should be one of custom props. cloned.getFillerOffset = this.getFillerOffset; + // Clone unsafe attributes list. + cloned._unsafeAttributesToRender = this._unsafeAttributesToRender; + return cloned; } diff --git a/packages/ckeditor5-engine/tests/view/renderer.js b/packages/ckeditor5-engine/tests/view/renderer.js index 0809b129882..2ea380f8fc3 100644 --- a/packages/ckeditor5-engine/tests/view/renderer.js +++ b/packages/ckeditor5-engine/tests/view/renderer.js @@ -4062,7 +4062,7 @@ describe( 'Renderer', () => { expect( normalizeHtml( domRoot.innerHTML ) ).to.equal( '
foo
' ); } ); - it( 'should rename attributes that can affect editing pipeline unless permitted when the element was created', () => { + it( 'should rename attributes that can affect editing pipeline unless permitted when the container element was created', () => { view.change( writer => { const containerElement = writer.createContainerElement( 'p', { onclick: 'foo', @@ -4083,6 +4083,27 @@ describe( 'Renderer', () => { ); } ); + it( 'should rename attributes that can affect editing pipeline unless permitted when an attribute element was created', () => { + view.change( writer => { + const attributeElement = writer.createAttributeElement( 'span', { + onclick: 'foo', + onkeydown: 'bar' + }, { + renderUnsafeAttributes: [ 'onclick' ] + } ); + + writer.insert( writer.createPositionAt( view.document.getRoot(), 'start' ), writer.createText( 'baz' ) ); + writer.wrap( writer.createRangeIn( view.document.getRoot() ), attributeElement ); + } ); + + view.forceRender(); + + expect( getViewData( view ) ).to.equal( 'baz' ); + expect( normalizeHtml( domRoot.innerHTML ) ).to.equal( + 'baz' + ); + } ); + it( 'should rename attributes that can not be rendered in the editing pipeline', () => { setViewData( view, '