Fixed bug introduced into transclusions for blank fields in #5736 (#5835)

new-json-store-area
Saq Imtiaz 2021-06-29 13:07:14 +02:00 zatwierdzone przez GitHub
rodzic 338b7c92a2
commit a6990128f1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -977,7 +977,7 @@ exports.getTextReferenceParserInfo = function(title,field,index,options) {
if(field === "title") { if(field === "title") {
parserInfo.sourceText = title; parserInfo.sourceText = title;
} else if(tiddler && tiddler.fields) { } else if(tiddler && tiddler.fields) {
parserInfo.sourceText = tiddler.fields[field] ? tiddler.fields[field].toString() : null; parserInfo.sourceText = tiddler.hasField(field) ? tiddler.fields[field].toString() : null;
} }
} else if(index) { } else if(index) {
this.getTiddlerText(title); // Force the tiddler to be lazily loaded this.getTiddlerText(title); // Force the tiddler to be lazily loaded

Wyświetl plik

@ -31,7 +31,7 @@ describe("Wiki.parseTextReference tests", function() {
modified: "201304152211"}); modified: "201304152211"});
wiki.addTiddler({ wiki.addTiddler({
title: "Tiddler Three", title: "Tiddler Three",
text: '{"oct":31,"nov":30,"dec":31}', text: '{"oct":31,"nov":30,"dec":31,"jan":""}',
tags: ["one","two"], tags: ["one","two"],
type: "application/json", type: "application/json",
modifier: "John", modifier: "John",
@ -41,7 +41,7 @@ describe("Wiki.parseTextReference tests", function() {
text: "The quick brown fox in $:/TiddlerTwo", text: "The quick brown fox in $:/TiddlerTwo",
tags: ["one"], tags: ["one"],
type: "text/vnd.tiddlywiki", type: "text/vnd.tiddlywiki",
authors: "Joe Bloggs", authors: "",
modifier: "JoeBloggs", modifier: "JoeBloggs",
modified: "201304152222"}); modified: "201304152222"});
// Add a plugin containing some shadow tiddlers // Add a plugin containing some shadow tiddlers
@ -68,7 +68,8 @@ describe("Wiki.parseTextReference tests", function() {
title: "Tiddler8", title: "Tiddler8",
text: "Tidd", text: "Tidd",
tags: ["one"], tags: ["one"],
"test-field": "JoeBloggs" "test-field": "JoeBloggs",
"myfield":""
} }
} }
}; };
@ -106,12 +107,20 @@ describe("Wiki.parseTextReference tests", function() {
expect(parseAndGetSource("MissingTiddler",null,"missing-index")).toEqual(null); expect(parseAndGetSource("MissingTiddler",null,"missing-index")).toEqual(null);
// Existing tiddler with non existent field // Existing tiddler with non existent field
expect(parseAndGetSource("TiddlerOne","missing-field")).toEqual(null); expect(parseAndGetSource("TiddlerOne","missing-field")).toEqual(null);
// Existing tiddler with blank field
expect(parseAndGetSource("TiddlerFour","authors")).toEqual("");
// Data tiddler with index specified // Data tiddler with index specified
expect(parseAndGetSource("Tiddler Three",null,"oct")).toEqual("31"); expect(parseAndGetSource("Tiddler Three",null,"oct")).toEqual("31");
// Data tiddler with blank index
expect(parseAndGetSource("Tiddler Three",null,"jan")).toEqual("");
// Data tiddler with non-existent index
expect(parseAndGetSource("Tiddler Three",null,"feb")).toEqual(null);
// Existing tiddler with a text field, type set to vnd.tiddlywiki // Existing tiddler with a text field, type set to vnd.tiddlywiki
expect(parseAndGetSource("TiddlerFour")).toEqual("The quick brown fox in $:/TiddlerTwo"); expect(parseAndGetSource("TiddlerFour")).toEqual("The quick brown fox in $:/TiddlerTwo");
// Existing subtiddler of a plugin // Existing subtiddler of a plugin
expect(parseAndGetSource("$:/ShadowPlugin","text",null,"Tiddler8")).toEqual("Tidd"); expect(parseAndGetSource("$:/ShadowPlugin","text",null,"Tiddler8")).toEqual("Tidd");
// Existing blank field of a subtiddler of a plugin
expect(parseAndGetSource("$:/ShadowPlugin","myfield",null,"Tiddler8")).toEqual("");
// Non-existent subtiddler of a plugin // Non-existent subtiddler of a plugin
expect(parseAndGetSource("$:/ShadowPlugin","text",null,"MyMissingTiddler")).toEqual(null); expect(parseAndGetSource("$:/ShadowPlugin","text",null,"MyMissingTiddler")).toEqual(null);
// Plain text tiddler // Plain text tiddler