alternate rows background inconsistency fix
This commit is contained in:
parent
521d02c374
commit
2cc28e8072
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.6.38 - Starter</title>
|
||||
<title>tablefilter v0.6.39 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.6.38</h1>
|
||||
<h1>tablefilter v0.6.39</h1>
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.6.38",
|
||||
"version": "0.6.39",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Feature} from '../feature';
|
||||
import {addClass, removeClass} from '../dom';
|
||||
import {defaultsStr} from '../settings';
|
||||
import {bound} from '../event';
|
||||
|
||||
/**
|
||||
* Rows with alternating background color for improved readability
|
||||
|
@ -41,10 +42,9 @@ export class AlternateRows extends Feature {
|
|||
|
||||
// Subscribe to events
|
||||
this.emitter.on(['row-processed', 'row-paged'],
|
||||
(tf, rowIndex, arrIndex, isValid) =>
|
||||
this.processRow(rowIndex, arrIndex, isValid));
|
||||
bound(this.processRowHandler, this));
|
||||
this.emitter.on(['column-sorted', 'rows-changed'],
|
||||
() => this.processAll());
|
||||
bound(this.processAll, this));
|
||||
|
||||
/** @inherited */
|
||||
this.initialized = true;
|
||||
|
@ -116,6 +116,11 @@ export class AlternateRows extends Feature {
|
|||
removeClass(rows[idx], this.evenCss);
|
||||
}
|
||||
|
||||
/** @private */
|
||||
processRowHandler(tf, rowIndex, arrIndex, isValid) {
|
||||
this.processRow(rowIndex, arrIndex, isValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all alternating backgrounds
|
||||
*/
|
||||
|
@ -129,10 +134,9 @@ export class AlternateRows extends Feature {
|
|||
|
||||
// Unsubscribe to events
|
||||
this.emitter.off(['row-processed', 'row-paged'],
|
||||
(tf, rowIndex, arrIndex, isValid) =>
|
||||
this.processRow(rowIndex, arrIndex, isValid));
|
||||
bound(this.processRowHandler, this));
|
||||
this.emitter.off(['column-sorted', 'rows-changed'],
|
||||
() => this.processAll());
|
||||
bound(this.processAll, this));
|
||||
|
||||
this.initialized = false;
|
||||
}
|
||||
|
|
|
@ -1657,7 +1657,7 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
emitter.emit('row-processed', this, k,
|
||||
this.validRowsIndex.length, isMatch);
|
||||
this.validRowsIndex.length - 1, isMatch);
|
||||
},
|
||||
// continue condition
|
||||
(row) => row.cells.length !== this.nbCells
|
||||
|
|
|
@ -91,8 +91,8 @@ test('Clear filters', function() {
|
|||
tf.clearFilters();
|
||||
tf.filter();
|
||||
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 3, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 4, 'Even bg removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 4, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 3, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Set background on a row', function() {
|
||||
|
@ -242,42 +242,6 @@ test('Can handle `row-paged` event', function() {
|
|||
altRows.processRow = processRow;
|
||||
});
|
||||
|
||||
test('Can handle `column-sorted` event', function() {
|
||||
// setup
|
||||
var processAll = altRows.processAll;
|
||||
var hit = 0;
|
||||
altRows.processAll = function() {
|
||||
hit++;
|
||||
};
|
||||
|
||||
// act
|
||||
altRows.init();
|
||||
tf.emitter.emit('column-sorted');
|
||||
|
||||
// assert
|
||||
deepEqual(hit, 1, 'processAll called');
|
||||
|
||||
altRows.processAll = processAll;
|
||||
});
|
||||
|
||||
test('Can handle `rows-changed` event', function() {
|
||||
// setup
|
||||
var processAll = altRows.processAll;
|
||||
var hit = 0;
|
||||
altRows.processAll = function() {
|
||||
hit++;
|
||||
};
|
||||
|
||||
// act
|
||||
altRows.init();
|
||||
tf.emitter.emit('rows-changed');
|
||||
|
||||
// assert
|
||||
deepEqual(hit, 1, 'processAll called');
|
||||
|
||||
altRows.processAll = processAll;
|
||||
});
|
||||
|
||||
module('Grid layout');
|
||||
test('Grid layout: initialising alternating rows', function() {
|
||||
tf.destroy();
|
||||
|
@ -309,8 +273,8 @@ test('Grid layout: clear filters', function() {
|
|||
tf.clearFilters();
|
||||
tf.filter();
|
||||
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 3, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 4, 'Even bg removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 4, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 3, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Grid layout: set background on a row', function() {
|
||||
|
|
Loading…
Reference in New Issue