|
|
@@ -589,44 +589,44 @@ export default class DowncastDispatcher {
|
|
|
* @private
|
|
|
*/
|
|
|
_mapChangesWithAutomaticReconversion( differ ) {
|
|
|
- const changes = differ.getChanges();
|
|
|
-
|
|
|
const itemsToReconvert = new Set();
|
|
|
+ const updated = [];
|
|
|
|
|
|
- const updated = changes
|
|
|
- .map( entry => {
|
|
|
- const element = getParentElementFromChange( entry );
|
|
|
-
|
|
|
- if ( !element ) {
|
|
|
- // Reconversion is done only on elements so skip text attribute changes.
|
|
|
- return entry;
|
|
|
- }
|
|
|
+ for ( const entry of differ.getChanges() ) {
|
|
|
+ const element = getParentElementFromChange( entry );
|
|
|
|
|
|
- let eventName;
|
|
|
+ if ( !element ) {
|
|
|
+ // Reconversion is done only on elements so skip text attribute changes.
|
|
|
+ updated.push( entry );
|
|
|
|
|
|
- if ( entry.type === 'attribute' ) {
|
|
|
- eventName = `attribute:${ entry.attributeKey }:${ element.name }`;
|
|
|
- } else {
|
|
|
- eventName = `${ entry.type }:${ entry.name }`;
|
|
|
- }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if ( this._isReconvertTriggerEvent( eventName, element.name ) ) {
|
|
|
- if ( itemsToReconvert.has( element ) ) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ let eventName;
|
|
|
|
|
|
- itemsToReconvert.add( element );
|
|
|
+ if ( entry.type === 'attribute' ) {
|
|
|
+ eventName = `attribute:${ entry.attributeKey }:${ element.name }`;
|
|
|
+ } else {
|
|
|
+ eventName = `${ entry.type }:${ entry.name }`;
|
|
|
+ }
|
|
|
|
|
|
- return {
|
|
|
- type: 'reconvert',
|
|
|
- element
|
|
|
- };
|
|
|
+ if ( this._isReconvertTriggerEvent( eventName, element.name ) ) {
|
|
|
+ if ( itemsToReconvert.has( element ) ) {
|
|
|
+ // Element is already reconverted, so skip this change.
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- return entry;
|
|
|
- } )
|
|
|
- // TODO: could be done in for...of loop or using reduce to not run double loop on big diffsets.
|
|
|
- .filter( entry => !!entry );
|
|
|
+ itemsToReconvert.add( element );
|
|
|
+
|
|
|
+ // Add special "reconvert" change.
|
|
|
+ updated.push( {
|
|
|
+ type: 'reconvert',
|
|
|
+ element
|
|
|
+ } );
|
|
|
+ } else {
|
|
|
+ updated.push( entry );
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return updated;
|
|
|
}
|