1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-12 12:59:57 +00:00

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

This commit is contained in:
Saq Imtiaz 2021-06-29 13:07:14 +02:00 committed by GitHub
parent 338b7c92a2
commit a6990128f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -977,7 +977,7 @@ exports.getTextReferenceParserInfo = function(title,field,index,options) {
if(field === "title") {
parserInfo.sourceText = title;
} 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) {
this.getTiddlerText(title); // Force the tiddler to be lazily loaded

View File

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