mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-08 00:42:28 +02:00
Merge pull request #784 from koalyptus/769-refine-empty-cell-logic
769 refine empty nonempty operators logic
This commit is contained in:
commit
3e763efac9
|
@ -14,7 +14,7 @@
|
||||||
"keyword-spacing": ["error", { "after": true, "before": true }],
|
"keyword-spacing": ["error", { "after": true, "before": true }],
|
||||||
"max-depth": [2, 7],
|
"max-depth": [2, 7],
|
||||||
"max-statements": [2, 133],
|
"max-statements": [2, 133],
|
||||||
"complexity": [2, 42],
|
"complexity": [2, 45],
|
||||||
"no-unused-vars": 2,
|
"no-unused-vars": 2,
|
||||||
"no-eval": 2,
|
"no-eval": 2,
|
||||||
"no-underscore-dangle": 0,
|
"no-underscore-dangle": 0,
|
||||||
|
|
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.7.1 - Starter</title>
|
<title>tablefilter v0.7.2 - Starter</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>tablefilter v0.7.1</h1>
|
<h1>tablefilter v0.7.2</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
dist/tablefilter/tablefilter.js
vendored
2
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tablefilter",
|
"name": "tablefilter",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2",
|
||||||
"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": {
|
||||||
|
|
|
@ -1785,11 +1785,11 @@ export class TableFilter {
|
||||||
}
|
}
|
||||||
//empty
|
//empty
|
||||||
else if (hasEM) {
|
else if (hasEM) {
|
||||||
occurence = !cell.hasChildNodes();
|
occurence = !cell.hasChildNodes() || isEmpty(cellValue);
|
||||||
}
|
}
|
||||||
//non-empty
|
//non-empty
|
||||||
else if (hasNM) {
|
else if (hasNM) {
|
||||||
occurence = cell.hasChildNodes();
|
occurence = cell.hasChildNodes() && !isEmpty(cellValue);
|
||||||
} else {
|
} else {
|
||||||
occurence = contains(term, cellValue,
|
occurence = contains(term, cellValue,
|
||||||
this.isExactMatch(colIdx), this.caseSensitive);
|
this.isExactMatch(colIdx), this.caseSensitive);
|
||||||
|
@ -1875,11 +1875,11 @@ export class TableFilter {
|
||||||
}
|
}
|
||||||
//empty
|
//empty
|
||||||
else if (hasEM) {
|
else if (hasEM) {
|
||||||
occurence = !cell.hasChildNodes();
|
occurence = !cell.hasChildNodes() || isEmpty(cellValue);
|
||||||
}
|
}
|
||||||
//non-empty
|
//non-empty
|
||||||
else if (hasNM) {
|
else if (hasNM) {
|
||||||
occurence = cell.hasChildNodes();
|
occurence = cell.hasChildNodes() && !isEmpty(cellValue);
|
||||||
} else {
|
} else {
|
||||||
// If numeric type data, perform a strict equality test and
|
// If numeric type data, perform a strict equality test and
|
||||||
// fallback to unformatted number string comparison
|
// fallback to unformatted number string comparison
|
||||||
|
|
|
@ -72,7 +72,14 @@
|
||||||
tf.clearFilters();
|
tf.clearFilters();
|
||||||
tf.setFilterValue(4, '[empty]');
|
tf.setFilterValue(4, '[empty]');
|
||||||
tf.filter();
|
tf.filter();
|
||||||
deepEqual(tf.getValidRows().length, 0, 'No matches expected');
|
var filteredData = tf.getFilteredData();
|
||||||
|
|
||||||
|
deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
||||||
|
deepEqual(
|
||||||
|
filteredData[0],
|
||||||
|
[6, ['Adelaide', 'Perth', '2781', '3.1', '']],
|
||||||
|
'Expected row data'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Non-empty operator - [nonempty]', function() {
|
test('Non-empty operator - [nonempty]', function() {
|
||||||
|
@ -96,7 +103,7 @@
|
||||||
tf.setFilterValue(4, '[nonempty]');
|
tf.setFilterValue(4, '[nonempty]');
|
||||||
tf.filter();
|
tf.filter();
|
||||||
|
|
||||||
deepEqual(tf.getValidRows().length, 7, 'Expected number of matches');
|
deepEqual(tf.getValidRows().length, 6, 'Expected number of matches');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Or operator - ||', function() {
|
test('Or operator - ||', function() {
|
||||||
|
|
Loading…
Reference in a new issue