From 42dba113ccdb18d7e76ac7a773c7dca532207007 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 11 Dec 2014 17:49:17 +0000 Subject: [PATCH] Adjust field and has filter handling of missing tiddlers Now `[!field:name[value]]` and `[!has[name]` will treat missing tiddlers as not having the specified field --- core/modules/filters/field.js | 4 ++++ core/modules/filters/has.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/modules/filters/field.js b/core/modules/filters/field.js index 949cb217e..f85df5c0d 100644 --- a/core/modules/filters/field.js +++ b/core/modules/filters/field.js @@ -26,6 +26,8 @@ exports.field = function(source,operator,options) { if(text !== null && !operator.regexp.exec(text)) { results.push(title); } + } else { + results.push(title); } }); } else { @@ -35,6 +37,8 @@ exports.field = function(source,operator,options) { if(text !== null && text !== operator.operand) { results.push(title); } + } else { + results.push(title); } }); } diff --git a/core/modules/filters/has.js b/core/modules/filters/has.js index 87e9953ec..9a82f3111 100644 --- a/core/modules/filters/has.js +++ b/core/modules/filters/has.js @@ -19,7 +19,7 @@ exports.has = function(source,operator,options) { var results = []; if(operator.prefix === "!") { source(function(tiddler,title) { - if(tiddler && (!$tw.utils.hop(tiddler.fields,operator.operand) || tiddler.fields[operator.operand] === "")) { + if(!tiddler || (tiddler && (!$tw.utils.hop(tiddler.fields,operator.operand) || tiddler.fields[operator.operand] === ""))) { results.push(title); } });