Skip to content

Commit 30c6cca

Browse files
authored
Mark processed tables (#121)
* Update table-sort.js Make sure each table is processed once by adding the class name "table-processed". This prevents re-processing tables and attaching repeated arrows and click events in scenarios where new tables are dynamically added to a web page/application. Now, only new tables are made sortable. * Update table-sort.js
1 parent 028a473 commit 30c6cca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

public/table-sort.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
2626
const [getTagTable] = getHTMLTables();
2727
const columnIndexAndTableRow = {};
2828
for (let table of getTagTable) {
29-
if (table.classList.contains("table-sort")) {
29+
if (table.classList.contains("table-sort") && !table.classList.contains("table-processed")) {
3030
makeTableSortable(table);
3131
}
3232
}
@@ -113,7 +113,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
113113
}
114114
}
115115

116-
function makeTableSortable(sortableTable) {
116+
function makeTableSortable(sortableTable) {
117+
sortableTable.classList.add("table-processed");
117118
const table = {
118119
bodies: getTableBodies(sortableTable),
119120
theads: sortableTable.querySelectorAll("thead"),

0 commit comments

Comments
 (0)