@@ -45,6 +45,8 @@ public sealed class RenderTreeBuilder : IDisposable
45
45
/// <param name="elementName">A value representing the type of the element.</param>
46
46
public void OpenElement ( int sequence , string elementName )
47
47
{
48
+ CompletePendingNamedSubmitEvent ( ) ;
49
+
48
50
// We are entering a new scope, since we track the "duplicate attributes" per
49
51
// element/component we might need to clean them up now.
50
52
if ( _hasSeenAddMultipleAttributes )
@@ -64,11 +66,7 @@ public void OpenElement(int sequence, string elementName)
64
66
/// </summary>
65
67
public void CloseElement ( )
66
68
{
67
- if ( _pendingNamedSubmitEvent is { } pendingNamedSubmitEvent )
68
- {
69
- AddNamedEvent ( pendingNamedSubmitEvent . Sequence , "onsubmit" , pendingNamedSubmitEvent . AssignedName ) ;
70
- _pendingNamedSubmitEvent = default ;
71
- }
69
+ CompletePendingNamedSubmitEvent ( ) ;
72
70
73
71
var indexOfEntryBeingClosed = _openElementIndices . Pop ( ) ;
74
72
@@ -82,6 +80,16 @@ public void CloseElement()
82
80
_entries . Buffer [ indexOfEntryBeingClosed ] . ElementSubtreeLengthField = _entries . Count - indexOfEntryBeingClosed ;
83
81
}
84
82
83
+ // TODO: Remove this once Razor supports @onsubmit:name
84
+ private void CompletePendingNamedSubmitEvent ( )
85
+ {
86
+ if ( _pendingNamedSubmitEvent is { } pendingNamedSubmitEvent )
87
+ {
88
+ AddNamedEvent ( pendingNamedSubmitEvent . Sequence , "onsubmit" , pendingNamedSubmitEvent . AssignedName ) ;
89
+ _pendingNamedSubmitEvent = default ;
90
+ }
91
+ }
92
+
85
93
/// <summary>
86
94
/// Appends a frame representing markup content.
87
95
/// </summary>
@@ -592,6 +600,8 @@ public void SetKey(object? value)
592
600
593
601
private void OpenComponentUnchecked ( int sequence , [ DynamicallyAccessedMembers ( Component ) ] Type componentType )
594
602
{
603
+ CompletePendingNamedSubmitEvent ( ) ;
604
+
595
605
// We are entering a new scope, since we track the "duplicate attributes" per
596
606
// element/component we might need to clean them up now.
597
607
if ( _hasSeenAddMultipleAttributes )
0 commit comments