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