@@ -117,8 +117,9 @@ func (a *transformer) isFragmentNode(n ast.Node) bool {
117
117
118
118
func (a * transformer ) Transform (node * ast.Document , reader text.Reader , pc parser.Context ) {
119
119
var attributes []ast.Node
120
+ var solitaryAttributeNodes []ast.Node
120
121
if a .cfg .Attribute .Block {
121
- attributes = make ([]ast.Node , 0 , 500 )
122
+ attributes = make ([]ast.Node , 0 , 100 )
122
123
}
123
124
ast .Walk (node , func (node ast.Node , entering bool ) (ast.WalkStatus , error ) {
124
125
if ! entering {
@@ -141,8 +142,7 @@ func (a *transformer) Transform(node *ast.Document, reader text.Reader, pc parse
141
142
attributes = append (attributes , node )
142
143
return ast .WalkSkipChildren , nil
143
144
} else {
144
- // remove attributes node
145
- node .Parent ().RemoveChild (node .Parent (), node )
145
+ solitaryAttributeNodes = append (solitaryAttributeNodes , node )
146
146
}
147
147
}
148
148
@@ -161,6 +161,11 @@ func (a *transformer) Transform(node *ast.Document, reader text.Reader, pc parse
161
161
// remove attributes node
162
162
attr .Parent ().RemoveChild (attr .Parent (), attr )
163
163
}
164
+
165
+ // Remove any solitary attribute nodes.
166
+ for _ , n := range solitaryAttributeNodes {
167
+ n .Parent ().RemoveChild (n .Parent (), n )
168
+ }
164
169
}
165
170
166
171
func (a * transformer ) generateAutoID (n ast.Node , reader text.Reader , pc parser.Context ) {
0 commit comments