You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some tables, the Datatable extractor fails to remove the original header before appending a new <thead>
The problem is that tables in Sigarra are not consistent from HTML point of view. Some use the tr > th elements, others use the more structural tags thead, tbody, etc.
Note: If I understand it correctly, we need to ensure the presence of a <thead> otherwise the DataTables library won't work properly. The remaining of the table is not relevant. I.e., the body of the table can either be wrapped around a tbody or be listed in multiple tr elements.
So, I think we just need to handle the following cases:
Example with <thead>
<table>
... // <caption>, <colgroup> can appear here
<thead><tr>
... // one or more table rows
</thead>
... // one or multiple <tr> or <tbody> and lastly an optional <tfooter></table>
Interpretation: If we have a table > thead, then we don't have to do anything! The library should work just fine. We don't care about the table body structure.
Example with <tr>s only
<table>
... // <caption>, <colgroup> can appear here
<tr><th>...</th><th>...</th>
...
</tr></table>
Interpretation: If we happen to have table > tr > th, then we need to transform the table. We replace tr by a theader tag and that's it. To be more precise, we need to ensure that all direct childrens of the table row are table headers. Table headers can also be used for rows. I think it's enough to see if the first table row only has th childs, just to avoid iterating over all rows. I mean, does it make sense that a header appears in the middle of the table? Technically it works and browsers render it, but I can't imagine a use-case.
The previous code would ALWAYS insert a <thead> tag. However, some tables already have it and the final was duplicated headers. This fix checks wether a <thead> is present or not, and in case it's missing it makes a more robust search for a possible table header (which is not mandatory). If one is found, then is wrapped around a <thead> and inserted in the original table
Closes#78
The previous code would ALWAYS insert a <thead> tag. However, some tables already have it and the final was duplicated headers. This fix checks wether a <thead> is present or not, and in case it's missing it makes a more robust search for a possible table header (which is not mandatory). If one is found, then is wrapped around a <thead> and inserted in the original table
Closes#78
In some tables, the Datatable extractor fails to remove the original header before appending a new
<thead>
The problem is that tables in Sigarra are not consistent from HTML point of view. Some use the
tr > th
elements, others use the more structural tagsthead
,tbody
, etc.Note: If I understand it correctly, we need to ensure the presence of a
<thead>
otherwise the DataTables library won't work properly. The remaining of the table is not relevant. I.e., the body of the table can either be wrapped around atbody
or be listed in multipletr
elements.So, I think we just need to handle the following cases:
Example with
<thead>
Interpretation: If we have a
table > thead
, then we don't have to do anything! The library should work just fine. We don't care about the table body structure.Example with
<tr>
s onlyInterpretation: If we happen to have
table > tr > th
, then we need to transform the table. We replacetr
by atheader
tag and that's it. To be more precise, we need to ensure that all direct childrens of the table row are table headers. Table headers can also be used for rows. I think it's enough to see if the first table row only hasth
childs, just to avoid iterating over all rows. I mean, does it make sense that a header appears in the middle of the table? Technically it works and browsers render it, but I can't imagine a use-case.References:
The text was updated successfully, but these errors were encountered: