-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updateElementMappings does not refresh attributes #4430
updateElementMappings does not refresh attributes #4430
Comments
This issue is a little more tricky. The For this issue, the important part of the it( 'should rerender element if its attribute was removed before rendering', () => {
const writer = new DowncastWriter();
// 1. Setup initial view/DOM.
viewRoot._appendChild( parse( '<container:p>1</container:p>' ) );
const viewP = viewRoot.getChild( 0 );
writer.setAttribute( 'data-placeholder', 'Body', viewP );
renderer.markToSync( 'children', viewRoot );
renderer.render();
expect( domRoot.innerHTML ).to.equal( '<p data-placeholder="Body">1</p>' );
// 2. Modify view.
writer.removeAttribute( 'data-placeholder', viewP );
viewRoot._removeChildren( 0, viewRoot.childCount );
viewRoot._appendChild( parse( '<container:p>1</container:p><container:p>2</container:p>' ) );
renderer.markToSync( 'attributes', viewP );
renderer.markToSync( 'children', viewRoot );
renderer.render();
expect( domRoot.innerHTML ).to.equal( '<p>1</p><p>2</p>' );
} ); This test fails on the 2nd
|
From the |
Fix: Marked reused element attributes to be rendered if replacing element was also marked. Closes #1560. Closes #1561.
The proposed solution from https://github.com/ckeditor/ckeditor5-engine/issues/1560#issuecomment-425950993, assumed that the attribute will be firstly removed and then the element is removed itself: writer.removeAttribute( 'data-placeholder', viewP );
viewRoot._removeChildren( 0, viewRoot.childCount ); However, in opposite cases, when element is firstly removed and then its attributes removed: viewRoot._removeChildren( 0, viewRoot.childCount );
writer.removeAttribute( 'data-placeholder', viewP ); the If we would like to solve this issue in the renderer, the only way is to compare attributes between view and DOM element or just mark all replaced elements to have its attributes updated. |
Other: Always update attributes of reused elements while rendering. Closes #1560.
This code:
https://github.com/ckeditor/ckeditor5-engine/blob/0821d9098b76c25fef577d6ccfe0c1324d0bc8ed/src/view/renderer.js#L317-L318
mark children of the remap element to be refreshed but do not map its attributes. It means that the DOM element may have old attributes after remapping.
The text was updated successfully, but these errors were encountered: