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