Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle interrupts in table row #1818

Merged
merged 1 commit into from
Aug 15, 2024
Merged

Handle interrupts in table row #1818

merged 1 commit into from
Aug 15, 2024

Conversation

alexcoco
Copy link
Member

@alexcoco alexcoco commented Aug 15, 2024

tablerow behaves very similarly to a for loop but does not handle interrupts. Interrupts in the BlockBody of a Tablerow tag will stop rendering the block body but will continue to loop through the entire collection, even with pending interrupts. This is because Tablerow does not check for and pop interrupts.

The effect of this is the full collection will be iterated and it's possible, if the first node in the Tablerow's body is a continue or break, that the interrupts keep stacking (since BlockBody only checks interrupts after rendering the node). This behaviour can lead to causing outer loops to prematurely exit due to stacked/leaked interrupts.

In this PR, I propose we treat Tablerow like a loop which means it needs to pop and handle interrupts. continue interrupts are popped but ignored because we still want to output the appropriate </tr> strings before continuing to the next iteration.

This is a small behaviour change that would shift handling interrupts inside Tablerow bodies to the Tablerow itself instead of a For loop that may enclose it. That said, I believe this is the more expected behaviour.

)
end

def test_table_row_does_not_leak_interrupts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output before my changes:

"<tr class=\"row1\">
<td class=\"col1\"></td><td class=\"col2\"></td><td class=\"col3\"></td></tr>
"

You can see that all three table row iterations occur and the outer loops are exited.

@alexcoco alexcoco merged commit ac91d31 into main Aug 15, 2024
11 checks passed
@alexcoco alexcoco deleted the tablerow-interrupt branch August 15, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants