mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-21 10:13:18 +00:00
allow 1 nested button. button in button in button will return an error
This commit is contained in:
parent
9f4f76d4c8
commit
49208cf056
@ -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;
|
||||
}
|
||||
|
@ -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>
|
@ -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>
|
Loading…
x
Reference in New Issue
Block a user