mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-23 15:36:52 +00:00
The !has[tags]
filter didn't work because tags
field is an array (#4643)
* The `!has[tags]` filter didn't work because "tags" is an array The negated `has` filter only considered empty strings, but not empty arrays (such as the `tags` field). * Add tests for `has` filter operator with array-like fields (tags, list)
This commit is contained in:
parent
9c22537b4e
commit
6570561d4e
@ -52,13 +52,13 @@ exports.has = function(source,operator,options) {
|
||||
else {
|
||||
if(invert) {
|
||||
source(function(tiddler,title) {
|
||||
if(!tiddler || !$tw.utils.hop(tiddler.fields,operator.operand) || (tiddler.fields[operator.operand] === "")) {
|
||||
if(!tiddler || !$tw.utils.hop(tiddler.fields,operator.operand) || (tiddler.fields[operator.operand].length === 0)) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && !(tiddler.fields[operator.operand] === "" || tiddler.fields[operator.operand].length === 0)) {
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && (tiddler.fields[operator.operand].length !== 0)) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
|
@ -317,6 +317,8 @@ function runTests(wiki) {
|
||||
it("should handle the has operator", function() {
|
||||
expect(wiki.filterTiddlers("[has[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
||||
expect(wiki.filterTiddlers("[!has[modified]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one");
|
||||
expect(wiki.filterTiddlers("[has[tags]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
||||
expect(wiki.filterTiddlers("[!has[tags]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one");
|
||||
});
|
||||
|
||||
it("should handle the has:field operator", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user