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 Detect nested buttons
*/ */
ButtonWidget.prototype.isNestedButton = function() { ButtonWidget.prototype.isNestedButton = function() {
var pointer = this.parentWidget; var pointer = this.parentWidget,
depth = 0;
while(pointer) { while(pointer) {
if(pointer instanceof ButtonWidget) { if(pointer instanceof ButtonWidget) {
return true; // we allow 1 nested button
if(depth > 1) return true;
depth += 1;
} }
pointer = pointer.parentWidget; pointer = pointer.parentWidget;
} }

View File

@ -12,4 +12,4 @@ title: Output
+ +
title: ExpectedResult 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 \whitespace trim
<$button>Test Button <$button>Test Button
<$button>Invalid button <$button>Second button
</$button> </$button>
+ +
title: ExpectedResult 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>