@@ -77,6 +77,17 @@ describe('htm', () => {
7777 expect ( html `< a href =${ 'foo' } / > ` ) . toEqual ( { tag : 'a' , props : { href : 'foo' } , children : [ ] } ) ;
7878 } ) ;
7979
80+ test ( 'slash in the middle of tag name or property name self-closes the element' , ( ) => {
81+ expect ( html `< ab /ba prop=value> ` ) . toEqual ( { tag : 'ab' , props : null , children : [ ] } ) ;
82+ expect ( html `< abba pr /op=value > ` ) . toEqual ( { tag : 'abba' , props : { pr : true } , children : [ ] } ) ;
83+ } ) ;
84+
85+ test ( 'slash in a property value does not self-closes the element, unless followed by >' , ( ) => {
86+ expect ( html `< abba prop =val/ue > </ /> ` ) . toEqual ( { tag : 'abba' , props : { prop : 'val/ue' } , children : [ ] } ) ;
87+ expect ( html `< abba prop =value/ > ` ) . toEqual ( { tag : 'abba' , props : { prop : 'value' } , children : [ ] } ) ;
88+ expect ( html `< abba prop =value/ > </ /> ` ) . toEqual ( { tag : 'abba' , props : { prop : 'value/' } , children : [ ] } ) ;
89+ } ) ;
90+
8091 test ( 'two props with dynamic values' , ( ) => {
8192 function onClick ( e ) { }
8293 expect ( html `< a href =${ 'foo' } onClick =${ onClick } /> ` ) . toEqual ( { tag : 'a' , props : { href : 'foo' , onClick } , children : [ ] } ) ;
@@ -86,6 +97,8 @@ describe('htm', () => {
8697 expect ( html `< a href ="before${ 'foo' } after " /> ` ) . toEqual ( { tag : 'a' , props : { href : 'beforefooafter' } , children : [ ] } ) ;
8798 expect ( html `< a href =${ 1 } ${ 1 } / > ` ) . toEqual ( { tag : 'a' , props : { href : '11' } , children : [ ] } ) ;
8899 expect ( html `< a href =${ 1 } between ${ 1 } /> ` ) . toEqual ( { tag : 'a' , props : { href : '1between1' } , children : [ ] } ) ;
100+ expect ( html `< a href =/before/${ 'foo' } /after /> ` ) . toEqual ( { tag : 'a' , props : { href : '/before/foo/after' } , children : [ ] } ) ;
101+ expect ( html `< a href =/before/${ 'foo' } / > ` ) . toEqual ( { tag : 'a' , props : { href : '/before/foo' } , children : [ ] } ) ;
89102 } ) ;
90103
91104 test ( 'spread props' , ( ) => {
0 commit comments