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