@@ -307,7 +307,9 @@ export function downcastRemoveRow() {
307
307
} , { priority : 'higher' } ) ;
308
308
}
309
309
310
- // Renames a table cell in the view to a given element name.
310
+ // Renames an existing table cell in the view to a given element name.
311
+ //
312
+ // **Note** This method will not do anything if a view table cell was not yet converted.
311
313
//
312
314
// @param {module:engine/model/element~Element } tableCell
313
315
// @param {String } desiredCellElementName
@@ -316,6 +318,11 @@ export function downcastRemoveRow() {
316
318
function renameViewTableCell ( tableCell , desiredCellElementName , conversionApi , asWidget ) {
317
319
const viewCell = conversionApi . mapper . toViewElement ( tableCell ) ;
318
320
321
+ // View cell might be not yet converted - skip it as it will be properly created by cell converter later on.
322
+ if ( ! viewCell ) {
323
+ return ;
324
+ }
325
+
319
326
let renamedCell ;
320
327
321
328
if ( asWidget ) {
@@ -486,6 +493,8 @@ function removeTableSectionIfEmpty( sectionName, tableElement, conversionApi ) {
486
493
487
494
// Moves view table rows associated with passed model rows to the provided table section element.
488
495
//
496
+ // **Note** This method will skip not converted table rows.
497
+ //
489
498
// @param {Array.<module:engine/model/element~Element> } rowsToMove
490
499
// @param {module:engine/view/element~Element } viewTableSection
491
500
// @param {Object } conversionApi
@@ -494,7 +503,10 @@ function moveViewRowsToTableSection( rowsToMove, viewTableSection, conversionApi
494
503
for ( const tableRow of rowsToMove ) {
495
504
const viewTableRow = conversionApi . mapper . toViewElement ( tableRow ) ;
496
505
497
- conversionApi . writer . move ( ViewRange . createOn ( viewTableRow ) , ViewPosition . createAt ( viewTableSection , offset ) ) ;
506
+ // View table row might be not yet converted - skip it as it will be properly created by cell converter later on.
507
+ if ( viewTableRow ) {
508
+ conversionApi . writer . move ( ViewRange . createOn ( viewTableRow ) , ViewPosition . createAt ( viewTableSection , offset ) ) ;
509
+ }
498
510
}
499
511
}
500
512
0 commit comments