Skip to content

Commit

Permalink
Merge pull request #5400 from glen-84/issue-698
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer authored Feb 6, 2023
2 parents b9a39af + 144a79f commit e879672
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3060,8 +3060,9 @@
} );

// If widget did not have data-cke-widget attribute before upcasting remove it.
if ( widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' )
if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) {
delete widgetElement.attributes[ 'data-widget' ];
}
}
}
// Nested editable.
Expand Down Expand Up @@ -3117,7 +3118,16 @@
if ( !retElement )
retElement = widgetElement;

toBe.wrapper.replaceWith( retElement );
// In some edge cases (especially applying formating
// at the boundary of the inline editable) the widget
// is going to be duplicated (split in half).
// In that case there won't be a retElement
// and we can safely remove such doppelganger widget (#698).
if ( retElement ) {
toBe.wrapper.replaceWith( retElement );
} else {
toBe.wrapper.remove();
}
}
}, null, null, 13 );

Expand Down

0 comments on commit e879672

Please sign in to comment.