@@ -10,6 +10,7 @@ import {
1010 Fragment ,
1111 h ,
1212 isVNode ,
13+ ref ,
1314 Text ,
1415 type VNode ,
1516 type VNodeArrayChildren ,
@@ -422,6 +423,49 @@ describe('addProps', () => {
422423 expect ( fragment [ 0 ] ) . toBe ( spanNode )
423424 expect ( spanNode . props ) . toBe ( null )
424425 } )
426+
427+ it ( 'addProps - 8259' , ( ) => {
428+ let count = 0
429+
430+ const spanRef = ref ( )
431+ const otherRef = ref ( )
432+ const spanNode = h ( 'span' , { ref : spanRef , class : 'bold' , style : 'color: red' } )
433+ const startNodes = [ spanNode ]
434+
435+ const nodes = addProps ( startNodes , ( ) => {
436+ count ++
437+
438+ return {
439+ ref : otherRef ,
440+ class : 'large' ,
441+ style : 'line-height: 1'
442+ }
443+ } )
444+
445+ expect ( count ) . toBe ( 1 )
446+
447+ expect ( nodes ) . toHaveLength ( 1 )
448+
449+ const newNode = nodes [ 0 ] as VNode
450+ const props = newNode . props
451+
452+ expect ( props ?. class ) . toBe ( 'bold large' )
453+ expect ( props ?. style . color ) . toBe ( 'red' )
454+ expect ( props ?. style [ 'line-height' ] ) . toBe ( '1' )
455+
456+ const mergedRef = newNode . ref
457+
458+ expect ( Array . isArray ( mergedRef ) ) . toBe ( true )
459+ expect ( mergedRef ) . toHaveLength ( 2 )
460+
461+ // Keep TS happy...
462+ if ( Array . isArray ( mergedRef ) ) {
463+ const refs = mergedRef . map ( ( { r } ) => r )
464+
465+ expect ( refs . includes ( spanRef ) ) . toBe ( true )
466+ expect ( refs . includes ( otherRef ) ) . toBe ( true )
467+ }
468+ } )
425469} )
426470
427471describe ( 'replaceChildren' , ( ) => {
0 commit comments