mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 23:03:50 +00:00
fix init problems
This commit is contained in:
parent
838c4639a0
commit
04f9477ec7
@ -12,8 +12,8 @@ Button widget
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/* String: Maximum -relative- permitted depth of the widget tree for recursion detection */
|
||||
var MAX_WIDGET_TREE_DEPTH_RELATIVE = "50";
|
||||
/* Maximum -relative- permitted depth of the widget tree for recursion detection */
|
||||
var MAX_WIDGET_TREE_DEPTH_RELATIVE = 50;
|
||||
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
|
||||
@ -26,7 +26,7 @@ var ButtonWidget = function(parseTreeNode,options) {
|
||||
if(!this.hasVariable("tv-button","true")) {
|
||||
this.setVariable("tv-button", "true");
|
||||
// set "local" max depth to a relative value, so nesting in higher levels is possible
|
||||
this.setVariable("tv-UNSAFE-max-widget-tree-depth", this.getAncestorCount() + MAX_WIDGET_TREE_DEPTH_RELATIVE);
|
||||
this.setVariable("tv-UNSAFE-max-widget-tree-depth", this.getAncestorCount() + MAX_WIDGET_TREE_DEPTH_RELATIVE + "");
|
||||
// allow users to debug the info
|
||||
this.setVariable("tv-ancestors", this.getAncestorCount() + "");
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ Widget base class
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/* String: Maximum permitted depth of the widget tree for recursion detection */
|
||||
var MAX_WIDGET_TREE_DEPTH = "1000";
|
||||
/* Maximum permitted depth of the widget tree for recursion detection */
|
||||
var MAX_WIDGET_TREE_DEPTH = 1000;
|
||||
|
||||
/*
|
||||
Create a widget object for a parse tree node
|
||||
@ -481,7 +481,7 @@ Widget.prototype.getAncestorCount = function() {
|
||||
this.ancestorCount = this.parentWidget.getAncestorCount() + 1;
|
||||
} else {
|
||||
this.ancestorCount = 0;
|
||||
this.setVariable("tv-UNSAFE-max-widget-tree-depth", MAX_WIDGET_TREE_DEPTH);
|
||||
this.setVariable("tv-UNSAFE-max-widget-tree-depth", MAX_WIDGET_TREE_DEPTH + "");
|
||||
}
|
||||
}
|
||||
return this.ancestorCount;
|
||||
@ -493,10 +493,9 @@ Make child widgets correspondng to specified parseTreeNodes
|
||||
Widget.prototype.makeChildWidgets = function(parseTreeNodes,options) {
|
||||
options = options || {};
|
||||
this.children = [];
|
||||
var self = this,
|
||||
maxWidgetTreeDepth = $tw.utils.getInt(this.variables["tv-UNSAFE-max-widget-tree-depth"].value, MAX_WIDGET_TREE_DEPTH);
|
||||
var self = this;
|
||||
// Check for too much recursion
|
||||
if(this.getAncestorCount() > maxWidgetTreeDepth) {
|
||||
if(this.getAncestorCount() > $tw.utils.getInt(this.variables["tv-UNSAFE-max-widget-tree-depth"].value, MAX_WIDGET_TREE_DEPTH + "")) {
|
||||
this.children.push(this.makeChildWidget({type: "error", attributes: {
|
||||
"$message": {type: "string", value: this.getAncestorCount() + " - " + $tw.language.getString("Error/RecursiveTransclusion")}
|
||||
}}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user