datatable: previous commit was reverted, but apply the usable parts - jscancer … | |
git clone git://git.codemadness.org/jscancer | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d5d0f00c5141d8df1bcdb7d659a7ee553d3c6ec4 | |
parent c1bcedb1c1fc7c5869121f632a5c2ce5c369ae4a | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Thu, 17 Aug 2017 19:04:57 +0200 | |
datatable: previous commit was reverted, but apply the usable parts | |
The previous commit used cloneNode which had undefined behaviour in | |
this case. | |
Diffstat: | |
M datatable/datatable.js | 26 ++++++++------------------ | |
1 file changed, 8 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/datatable/datatable.js b/datatable/datatable.js | |
@@ -8,16 +8,10 @@ function datatable_sort_default(x, y) { | |
} | |
function datatable_init(el) { | |
- var thead = el.getElementsByTagName("thead"); | |
- if (!thead.length) | |
- return null; | |
- var tbody = el.getElementsByTagName("tbody"); | |
- if (!tbody.length) | |
- return null; | |
- var ths = thead[0].children[0].children; | |
- if (!ths.length) | |
- return null; | |
- var cols = []; | |
+ var thead = el.tHead, | |
+ tbody = el.tBodies[0]; | |
+ var ths = thead.children[0].children, | |
+ cols = []; | |
for (var i = 0; i < ths.length; i++) | |
cols.push({ | |
filterable: ["1", "true"].indexOf(ths[i].getAttribute(… | |
@@ -27,9 +21,9 @@ function datatable_init(el) { | |
}); | |
var d = { | |
table: el, | |
- thead: thead[0], | |
+ thead: thead, | |
ths: ths, | |
- tbody: tbody[0], | |
+ tbody: tbody, | |
cols: cols, | |
sort: [], // sort options: [colidx, order (ASC = 0, DESC = 1)… | |
lazyscroll: ["1", "true"].indexOf(el.getAttribute("data-lazysc… | |
@@ -40,9 +34,7 @@ function datatable_init(el) { | |
if (d.lazyscroll) { | |
var bodytable = document.createElement("table"); | |
bodytable.className = el.className; | |
- bodytable.setAttribute("cellspacing", "0"); | |
- bodytable.setAttribute("cellpadding", "0"); | |
- bodytable.setAttribute("border", "0"); | |
+ bodytable.cellSpacing = bodytable.cellPadding = bodytable.bord… | |
var tr = document.createElement("tr"); | |
for (var i = 0; i < ths.length; i++) { | |
@@ -62,9 +54,7 @@ function datatable_init(el) { | |
elthead.appendChild(tr); | |
var headerstable = document.createElement("table"); | |
- headerstable.setAttribute("cellspacing", "0"); | |
- headerstable.setAttribute("cellpadding", "0"); | |
- headerstable.setAttribute("border", "0"); | |
+ headerstable.cellSpacing = headerstable.cellPadding = headerst… | |
headerstable.className = el.className; | |
headerstable.appendChild(elthead); | |