Fix handling of {!!title} in a filter with no currentTiddler

Fixes #6721
This commit is contained in:
jeremy@jermolene.com 2022-06-14 08:33:47 +01:00
parent 8e64e21039
commit 35b0833e0c
2 changed files with 3 additions and 1 deletions

View File

@ -50,7 +50,7 @@ exports.getTextReference = function(textRef,defaultText,currTiddlerTitle) {
if(tr.field) {
var tiddler = this.getTiddler(title);
if(tr.field === "title") { // Special case so we can return the title of a non-existent tiddler
return title;
return title || defaultText;
} else if(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) {
return tiddler.getFieldString(tr.field);
} else {

View File

@ -621,6 +621,8 @@ Tests the filtering mechanism.
});
it("should handle indirect operands", function() {
expect(wiki.filterTiddlers("[{!!missing}]").join(",")).toBe("");
expect(wiki.filterTiddlers("[{!!title}]").join(",")).toBe("");
expect(wiki.filterTiddlers("[prefix{Tiddler8}] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
expect(wiki.filterTiddlers("[modifier{Tiddler8!!test-field}] +[sort[title]]").join(",")).toBe("TiddlerOne");
var fakeWidget = {wiki: wiki, getVariable: function() {return "Tiddler Three";}};