File tree 2 files changed +11
-1
lines changed
packages/rehype-dom-stringify/lib
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ function serialize(node) {
44
44
// Document.
45
45
if ( 'doctype' in node ) {
46
46
const doctype = node . doctype ? serialize ( node . doctype ) : ''
47
- const docelem = serialize ( node . documentElement )
47
+ const docelem = node . documentElement ? serialize ( node . documentElement ) : ''
48
48
return doctype + docelem
49
49
}
50
50
Original file line number Diff line number Diff line change @@ -125,6 +125,16 @@ test('rehype-dom-stringify', async function (t) {
125
125
)
126
126
} )
127
127
128
+ await t . test ( 'should support empty fragment' , async function ( ) {
129
+ assert . equal (
130
+ processor ( )
131
+ . data ( 'settings' , { fragment : true } )
132
+ . processSync ( '' )
133
+ . toString ( ) ,
134
+ ''
135
+ )
136
+ } )
137
+
128
138
await t . test ( 'should stringify a fragment' , async function ( ) {
129
139
assert . equal (
130
140
processor ( )
You can’t perform that action at this time.
0 commit comments