File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,13 +118,7 @@ function processAttributes(
118118 }
119119
120120 // Handle boolean attributes: {bool} -> {":bool": "true"}
121- if (
122- handleBoolean &&
123- ! key . startsWith ( ':' ) &&
124- ! key . startsWith ( '#' ) &&
125- ! key . startsWith ( '.' ) &&
126- ( ! value || value === 'true' || value === '' )
127- ) {
121+ if ( handleBoolean && ! key . startsWith ( ':' ) && ! key . startsWith ( '#' ) && ! key . startsWith ( '.' ) && value === 'true' ) {
128122 attrs [ `:${ key } ` ] = 'true'
129123 continue
130124 }
Original file line number Diff line number Diff line change @@ -204,6 +204,25 @@ describe('streaming mode', () => {
204204 expect ( alert [ 0 ] ) . toBe ( 'alert' )
205205 } )
206206
207+ it ( 'keeps auto-closed empty string attributes as strings' , async ( ) => {
208+ const parse = createParse ( )
209+ const result = await parse ( '::callout{color="info" icon' , { streaming : true } )
210+ const callout = result . nodes [ 0 ] as ComarkElement
211+
212+ expect ( callout [ 0 ] ) . toBe ( 'callout' )
213+ expect ( callout [ 1 ] ) . toMatchObject ( { color : 'info' , ':icon' : 'true' } )
214+ } )
215+
216+ it ( 'keeps auto-closed empty string attributes as strings' , async ( ) => {
217+ const parse = createParse ( )
218+ const result = await parse ( '::callout{color="info" icon="' , { streaming : true } )
219+ const callout = result . nodes [ 0 ] as ComarkElement
220+
221+ expect ( callout [ 0 ] ) . toBe ( 'callout' )
222+ expect ( callout [ 1 ] ) . toMatchObject ( { color : 'info' , icon : '' } )
223+ expect ( callout [ 1 ] ) . not . toHaveProperty ( ':icon' )
224+ } )
225+
207226 it ( 'caches nodes before MDC components' , async ( ) => {
208227 const parse = createParse ( )
209228
You can’t perform that action at this time.
0 commit comments