1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-05-23 17:54:06 +00:00

Fix problem with checkbox widget and missing tiddlers

The newly added invertTag code was crashing if the tiddler doesn’t
exist.
This commit is contained in:
Jermolene 2015-07-02 17:33:51 +01:00
parent 8b7aad11c0
commit 3a7e29674b

View File

@ -95,11 +95,12 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
fallbackFields = {text: ""}, fallbackFields = {text: ""},
newFields = {title: this.checkboxTitle}, newFields = {title: this.checkboxTitle},
hasChanged = false, hasChanged = false,
tagCheck = false; tagCheck = false,
hasTag = tiddler && tiddler.hasTag(this.checkboxTag);
if(this.checkboxTag && this.checkboxInvertTag === "yes") { if(this.checkboxTag && this.checkboxInvertTag === "yes") {
tagCheck = tiddler.hasTag(this.checkboxTag) === checked; tagCheck = hasTag === checked;
} else { } else {
tagCheck = tiddler.hasTag(this.checkboxTag) !== checked; tagCheck = hasTag !== checked;
} }
// Set the tag if specified // Set the tag if specified
if(this.checkboxTag && (!tiddler || tagCheck)) { if(this.checkboxTag && (!tiddler || tagCheck)) {