Merge branch 'button-in-button-fix' into dynamic-max-widget-tree-depth

This commit is contained in:
pmario 2024-04-19 10:41:59 +02:00
commit 1a5c05d2a9
3 changed files with 8 additions and 5 deletions

View File

@ -29,10 +29,13 @@ ButtonWidget.prototype = new Widget();
Detect nested buttons
*/
ButtonWidget.prototype.isNestedButton = function() {
var pointer = this.parentWidget;
var pointer = this.parentWidget,
depth = 0;
while(pointer) {
if(pointer instanceof ButtonWidget) {
return true;
// we allow 1 nested button
if(depth > 1) return true;
depth += 1;
}
pointer = pointer.parentWidget;
}

View File

@ -12,4 +12,4 @@ title: Output
+
title: ExpectedResult
<p><button class=""><span class="tc-error">Possible Recursive Error: Button in button is not allowed</span></button></p>
<p><button class=""><button class=""><button class=""><span class="tc-error">Possible Recursive Error: Button in button is not allowed</span></button></button></button></p>

View File

@ -7,9 +7,9 @@ title: Output
\whitespace trim
<$button>Test Button
<$button>Invalid button
<$button>Second button
</$button>
+
title: ExpectedResult
<p><button class="">Test Button<span class="tc-error">Possible Recursive Error: Button in button is not allowed</span></button></p>
<p><button class="">Test Button<button class="">Second button</button></button></p>