button use tv-limit-nested-buttons variable if set

This commit is contained in:
pmario 2024-04-25 16:57:56 +02:00
parent 05f1ba20ca
commit bb9c991ce3
1 changed files with 11 additions and 8 deletions

View File

@ -17,6 +17,7 @@ var Widget = require("$:/core/modules/widgets/widget.js").widget;
var Popup = require("$:/core/modules/utils/dom/popup.js");
var ButtonWidget = function(parseTreeNode,options) {
options.hasDom = true;
this.initialise(parseTreeNode,options);
};
@ -56,14 +57,16 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
this.execute();
// Check "button in button". Return early with an error message
// This check also prevents fatal recursion errors using the transclusion widget
if(this.isNestedButton()) {
var domNode = this.document.createElement("span");
var textNode = this.document.createTextNode($tw.language.getString("Error/RecursiveButton"));
domNode.appendChild(textNode);
domNode.className = "tc-error";
parent.insertBefore(domNode,nextSibling);
this.domNodes.push(domNode);
return; // an error message
if(this.getVariable("tv-limit-nested-buttons") === "yes") {
if(this.isNestedButton()) {
var domNode = this.document.createElement("span");
var textNode = this.document.createTextNode($tw.language.getString("Error/RecursiveButton"));
domNode.appendChild(textNode);
domNode.className = "tc-error";
parent.insertBefore(domNode,nextSibling);
this.domNodes.push(domNode);
return; // an error message
}
}
// Create element
if(this.buttonTag && $tw.config.htmlUnsafeElements.indexOf(this.buttonTag) === -1) {