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
print-window-tiddler
Jermolene 2014-12-11 17:49:17 +00:00
rodzic 156d3bc692
commit 42dba113cc
2 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -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);
}
});
}

Wyświetl plik

@ -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);
}
});