jerrylow / basictable

Basic Table jQuery or Vanilla JS plugin for simple responsive tables.
MIT License
127 stars 57 forks source link

Add thead > td support #24

Open iamrobert opened 2 years ago

iamrobert commented 2 years ago

Hi Jerry,

Great library.

With our CMS, it has a weird output for the tables as:

thead > tr > td

Do you think adding this line to your library would help make it more accessible?

      if (this.options.header) {
        let format = "";
        if (table.querySelectorAll("thead tr th").length) {
          format = "thead th";
        //Added Support
        } else if (table.querySelectorAll("thead tr td").length) {
           format = "thead td";
        } else if (table.querySelectorAll("tbody tr th").length) {
          format = "tbody tr th";
        } else if (table.querySelectorAll("th").length) {
          format = "tr:first th";
        } else {
          format = "tr:first td";
        }

Cheers,

Robert

jerrylow commented 2 years ago

Hey @iamrobert the last condition should have taken care of this. What structure is your CMS outputting? Here's a sample I quickly mocked up: https://jsfiddle.net/owL2brd8/