1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-28 23:10:46 +00:00

Make is[variable] and variables[] operators resilient to fake widgets

This commit is contained in:
jeremy@jermolene.com 2022-05-26 08:23:54 +01:00
parent e2d45e176a
commit 45b7b4bc6d
2 changed files with 11 additions and 5 deletions

View File

@ -19,13 +19,13 @@ exports.variable = function(source,prefix,options) {
var results = [];
if(prefix === "!") {
source(function(tiddler,title) {
if(!(title in options.widget.variables)) {
if(options.widget.getVariable(title) === undefined) {
results.push(title);
}
});
} else {
source(function(tiddler,title) {
if(title in options.widget.variables) {
if(options.widget.getVariable(title) !== undefined) {
results.push(title);
}
});

View File

@ -16,10 +16,16 @@ Filter operator for returning the names of the active variables
Export our filter function
*/
exports.variables = function(source,operator,options) {
var names = [];
for(var variable in options.widget.variables) {
var names = [],
widget = options.widget;
while(widget && !widget.hasOwnProperty("variables")) {
widget = widget.parentWidget;
}
if(widget && widget.variables) {
for(var variable in widget.variables) {
names.push(variable);
}
}
return names.sort();
};