Skip to content

Commit

Permalink
Bug: Fix classes on <tr> not being sorted with the respective <tr>. (#89
Browse files Browse the repository at this point in the history
)
  • Loading branch information
LeeWannacott committed May 18, 2023
1 parent 58397c9 commit 5697bc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>Manual testing of table sort js</h1>
<th>dates in dd/mm/yyyy</th>
</tr>
</thead>
<tr>
<tr class="table-row-1">
<td>Franklin</td>
<td>Benjamin</td>
<td>1706/1/17</td>
Expand All @@ -30,7 +30,7 @@ <h1>Manual testing of table sort js</h1>
<td>10b</td>
<td>17/6/1978</td>
</tr>
<tr>
<tr class="table-row-2">
<td>da Vinci</td>
<td>Zarlo</td>
<td>1452/4/15</td>
Expand Down
15 changes: 8 additions & 7 deletions public/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
const dataAttributeTd = tr.querySelectorAll("td").item(columnIndex)
.dataset.sort;
columnData.push(`${dataAttributeTd}#${i}`);
columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
columnIndexAndTableRow[columnData[i]] = tr.outerHTML;
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
timeinSeconds = hours + minutesInSeconds + seconds;
}
columnData.push(`${timeinSeconds}#${i}`);
columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
columnIndexAndTableRow[columnData[i]] = tr.outerHTML;
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -244,7 +244,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
);
}
columnData.push(`${numberToSort}#${i}`);
columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
columnIndexAndTableRow[columnData[i]] = tr.outerHTML;
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -302,7 +302,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}
if (tdTextContent.trim() !== "") {
if (isFileSize) {
fileSizeColumnTextAndRow[columnData[i]] = tr.innerHTML;
fileSizeColumnTextAndRow[columnData[i]] = tr.outerHTML;
}
// These classes already handle pushing to column and setting the tr html.
if (
Expand All @@ -314,12 +314,12 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
!isSortDateMonthDayYear
) {
columnData.push(`${tdTextContent}#${i}`);
columnIndexAndTableRow[`${tdTextContent}#${i}`] = tr.innerHTML;
columnIndexAndTableRow[`${tdTextContent}#${i}`] = tr.outerHTML;
}
} else {
// Fill in blank table cells dict key with filler value.
columnData.push(`${fillValue}#${i}`);
columnIndexAndTableRow[`${fillValue}#${i}`] = tr.innerHTML;
columnIndexAndTableRow[`${fillValue}#${i}`] = tr.outerHTML;
}
}

Expand Down Expand Up @@ -386,6 +386,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}
}


function updateTable(tableProperties) {
const { tableRows, columnData, isFileSize } = tableProperties;
for (let [i, tr] of tableRows.entries()) {
Expand Down Expand Up @@ -423,7 +424,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
tr.querySelectorAll("td").item(columnIndex).innerHTML =
fileSizeInBytesHTML;
} else if (!isFileSize) {
tr.innerHTML = columnIndexAndTableRow[columnData[i]];
tr.outerHTML = columnIndexAndTableRow[columnData[i]];
}
}
}
Expand Down

0 comments on commit 5697bc8

Please sign in to comment.