@@ -194,6 +194,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
194194 return function ( vals , table ) {
195195 let result = [ ] ;
196196 let spanners = [ ] ;
197+ let auto = { } ;
197198 table . forEach ( function ( row ) {
198199 row . forEach ( function ( cell ) {
199200 if ( ( cell [ colSpan ] || 1 ) > 1 ) {
@@ -217,12 +218,20 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
217218 let col = cell [ x ] ;
218219 let existingWidth = result [ col ] ;
219220 let editableCols = typeof vals [ col ] === 'number' ? 0 : 1 ;
220- for ( let i = 1 ; i < span ; i ++ ) {
221- existingWidth += 1 + result [ col + i ] ;
222- if ( typeof vals [ col + i ] !== 'number' ) {
223- editableCols ++ ;
221+ if ( typeof existingWidth === 'number' ) {
222+ for ( let i = 1 ; i < span ; i ++ ) {
223+ existingWidth += 1 + result [ col + i ] ;
224+ if ( typeof vals [ col + i ] !== 'number' ) {
225+ editableCols ++ ;
226+ }
227+ }
228+ } else {
229+ existingWidth = desiredWidth === 'desiredWidth' ? cell . desiredWidth - 1 : 1 ;
230+ if ( ! auto [ col ] || auto [ col ] < existingWidth ) {
231+ auto [ col ] = existingWidth ;
224232 }
225233 }
234+
226235 if ( cell [ desiredWidth ] > existingWidth ) {
227236 let i = 0 ;
228237 while ( editableCols > 0 && cell [ desiredWidth ] > existingWidth ) {
@@ -237,7 +246,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
237246 }
238247 }
239248
240- Object . assign ( vals , result ) ;
249+ Object . assign ( vals , result , auto ) ;
241250 for ( let j = 0 ; j < vals . length ; j ++ ) {
242251 vals [ j ] = Math . max ( forcedMin , vals [ j ] || 0 ) ;
243252 }
0 commit comments