Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

table-sort-js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table-sort-js - npm Package Compare versions

Comparing version 1.9.2 to 1.10.2

2

package.json
{
"name": "table-sort-js",
"version": "1.9.2",
"version": "1.10.2",
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -54,6 +54,7 @@ ![table-sort-js](https://img.shields.io/npm/v/table-sort-js)

| "data-sort" | Sort by [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), e.g <td data-sort="42"> |
| "onload-sort" | Sort column on loading of the page. Simulates a click from the user. (can only sort onload for one column) |
| "file-size-sort" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) |
| "disable-sort" | Disallow sorting the table by this specific column. |
| "alpha-sort" | Sort alphabetically (z11,z2); default is [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order) (z2,z11). |
| "punct-sort" | Sort punctuation; default ignores punctuation. |
| "disable-sort" | Disallow sorting the table by this specific column. |

@@ -60,0 +61,0 @@ #### Development:

@@ -38,22 +38,28 @@ /*

function makeTableSortable(sortableTable) {
function createMissingTableHead(sortableTable) {
let createTableHead;
let tableBody;
if (testingTableSortJS === true) {
createTableHead = domDocumentWindow.createElement("thead");
} else {
createTableHead = document.createElement("thead");
}
createTableHead.appendChild(sortableTable.rows[0]);
sortableTable.insertBefore(createTableHead, sortableTable.firstChild);
}
function getTableBody(sortableTable) {
if (sortableTable.getElementsByTagName("thead").length === 0) {
if (testingTableSortJS === true) {
createTableHead = domDocumentWindow.createElement("thead");
} else {
createTableHead = document.createElement("thead");
}
createTableHead.appendChild(sortableTable.rows[0]);
sortableTable.insertBefore(createTableHead, sortableTable.firstChild);
createMissingTableHead(sortableTable);
if (sortableTable.querySelectorAll("tbody").length > 1) {
tableBody = sortableTable.querySelectorAll("tbody")[1];
return sortableTable.querySelectorAll("tbody")[1];
} else {
tableBody = sortableTable.querySelector("tbody");
return sortableTable.querySelector("tbody");
}
} else {
tableBody = sortableTable.querySelector("tbody");
return sortableTable.querySelector("tbody");
}
}
function makeTableSortable(sortableTable) {
const tableBody = getTableBody(sortableTable);
const tableHead = sortableTable.querySelector("thead");

@@ -324,2 +330,6 @@ const tableHeadHeaders = tableHead.querySelectorAll("th");

});
let isOnloadSort = th.classList.contains("onload-sort");
if (isOnloadSort) {
th.click();
}
}

@@ -326,0 +336,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc