@@ -318,9 +318,6 @@ function getHeartCol(row) {
318318 td = tds [ 1 ] ;
319319 }
320320 if ( td !== null ) {
321- if ( td . children . length ) {
322- return td . children [ 0 ] ;
323- }
324321 return td ;
325322 }
326323
@@ -397,11 +394,10 @@ function toggle(id, show, mobile)
397394 } ) ;
398395}
399396
400- function addHeart ( rank , row , id , isFav , mobile )
397+ function getHeartTd ( rank , row , id , isFav , mobile )
401398{
402- var heartCol = getHeartCol ( row ) ;
403399 var iconClass = isFav ? "fas fa-heart" : "far fa-heart" ;
404- return heartCol . innerHTML + " <span class=\"heart " + iconClass + "\" onclick=\"toggle(" + id + "," + ( isFav ? "false" : "true" ) + "," + mobile + ")\"></span>" ;
400+ return "<td class=\"scoreaf heart\"> <span class=\"heart " + iconClass + "\" onclick=\"toggle(" + id + "," + ( isFav ? "false" : "true" ) + "," + mobile + ")\"></span></td >" ;
405401}
406402
407403function initFavouriteTeams ( )
@@ -432,7 +428,9 @@ function initFavouriteTeams()
432428 for ( var i = 0 ; i < favTeams . length ; i ++ ) {
433429 if ( teamname === favTeams [ i ] ) {
434430 found = true ;
435- heartCol . innerHTML = addHeart ( rank , scoreboard [ j ] , teamIndex , found , mobile ) ;
431+ let heartTd = getHeartTd ( rank , scoreboard [ j ] , teamIndex , found , mobile ) ;
432+ // Insert td after heartCol
433+ heartCol . insertAdjacentHTML ( 'afterend' , heartTd ) ;
436434 toAdd [ cntFound ] = scoreboard [ j ] . cloneNode ( true ) ;
437435 if ( mobile ) {
438436 toAddMobile [ cntFound ] = scoreboard [ j + 1 ] . cloneNode ( true ) ;
@@ -455,7 +453,8 @@ function initFavouriteTeams()
455453 }
456454 }
457455 if ( ! found ) {
458- heartCol . innerHTML = addHeart ( rank , scoreboard [ j ] , teamIndex , found , mobile ) ;
456+ let heartTd = getHeartTd ( rank , scoreboard [ j ] , teamIndex , found , mobile ) ;
457+ heartCol . insertAdjacentHTML ( 'afterend' , heartTd ) ;
459458 }
460459 if ( rank !== "" ) {
461460 lastRank = rank ;
0 commit comments