@@ -17,13 +17,10 @@ Instructions:
1717
1818function tableSortJs ( testingTableSortJS = false , domDocumentWindow = document ) {
1919 function getHTMLTables ( ) {
20- if ( testingTableSortJS === true ) {
21- const getTagTable = domDocumentWindow . getElementsByTagName ( "table" ) ;
22- return [ getTagTable ] ;
23- } else {
24- const getTagTable = document . getElementsByTagName ( "table" ) ;
25- return [ getTagTable ] ;
26- }
20+ const getTagTable = ! testingTableSortJS
21+ ? document . getElementsByTagName ( "table" )
22+ : domDocumentWindow . getElementsByTagName ( "table" ) ;
23+ return [ getTagTable ] ;
2724 }
2825
2926 const [ getTagTable ] = getHTMLTables ( ) ;
@@ -35,12 +32,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
3532 }
3633
3734 function createMissingTableHead ( sortableTable ) {
38- let createTableHead ;
39- if ( testingTableSortJS === true ) {
40- createTableHead = domDocumentWindow . createElement ( "thead" ) ;
41- } else {
42- createTableHead = document . createElement ( "thead" ) ;
43- }
35+ let createTableHead = ! testingTableSortJS
36+ ? document . createElement ( "thead" )
37+ : domDocumentWindow . createElement ( "thead" ) ;
4438 createTableHead . appendChild ( sortableTable . rows [ 0 ] ) ;
4539 sortableTable . insertBefore ( createTableHead , sortableTable . firstChild ) ;
4640 }
@@ -50,7 +44,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
5044 createMissingTableHead ( sortableTable ) ;
5145 if ( sortableTable . querySelectorAll ( "tbody" ) . length > 1 ) {
5246 // don't select empty tbody that the browser creates
53- return sortableTable . querySelectorAll ( ' tbody:not(:nth-child(2))' ) ;
47+ return sortableTable . querySelectorAll ( " tbody:not(:nth-child(2))" ) ;
5448 } else {
5549 return sortableTable . querySelectorAll ( "tbody" ) ;
5650 }
@@ -244,19 +238,10 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
244238 const regexMinutesAndSeconds = / ^ ( \d + h ) ? \s ? ( \d + m ) ? \s ? ( \d + s ) ? $ / i;
245239 let columnOfTd = "" ;
246240 // TODO: github actions runtime didn't like textContent, tests didn't like innerText?
247- if ( testingTableSortJS ) {
248- columnOfTd = column . getColumn (
249- tr ,
250- column . spanSum ,
251- column . span
252- ) . textContent ;
253- } else {
254- columnOfTd = column . getColumn (
255- tr ,
256- column . spanSum ,
257- column . span
258- ) . innerText ;
259- }
241+ columnOfTd = column . getColumn ( tr , column . spanSum , column . span ) ;
242+ columnOfTd = testingTableSortJS
243+ ? columnOfTd . textContent
244+ : columnOfTd . innerText ;
260245 let match = columnOfTd . match ( regexMinutesAndSeconds ) ;
261246 let [ minutesInSeconds , hours , seconds ] = [ 0 , 0 , 0 ] ;
262247 let timeinSeconds = columnOfTd ;
0 commit comments