@@ -1644,6 +1644,54 @@ describe('compiler: parse', () => {
16441644 } )
16451645 } )
16461646
1647+ test ( 'self-closing v-pre' , ( ) => {
1648+ const ast = baseParse (
1649+ `<div v-pre/>\n<div :id="foo"><Comp/>{{ bar }}</div>`
1650+ )
1651+ // should not affect siblings after it
1652+ const divWithoutPre = ast . children [ 1 ] as ElementNode
1653+ expect ( divWithoutPre . props ) . toMatchObject ( [
1654+ {
1655+ type : NodeTypes . DIRECTIVE ,
1656+ name : `bind` ,
1657+ arg : {
1658+ type : NodeTypes . SIMPLE_EXPRESSION ,
1659+ isStatic : true ,
1660+ content : `id`
1661+ } ,
1662+ exp : {
1663+ type : NodeTypes . SIMPLE_EXPRESSION ,
1664+ isStatic : false ,
1665+ content : `foo`
1666+ } ,
1667+ loc : {
1668+ source : `:id="foo"` ,
1669+ start : {
1670+ line : 2 ,
1671+ column : 6
1672+ } ,
1673+ end : {
1674+ line : 2 ,
1675+ column : 15
1676+ }
1677+ }
1678+ }
1679+ ] )
1680+ expect ( divWithoutPre . children [ 0 ] ) . toMatchObject ( {
1681+ type : NodeTypes . ELEMENT ,
1682+ tagType : ElementTypes . COMPONENT ,
1683+ tag : `Comp`
1684+ } )
1685+ expect ( divWithoutPre . children [ 1 ] ) . toMatchObject ( {
1686+ type : NodeTypes . INTERPOLATION ,
1687+ content : {
1688+ type : NodeTypes . SIMPLE_EXPRESSION ,
1689+ content : `bar` ,
1690+ isStatic : false
1691+ }
1692+ } )
1693+ } )
1694+
16471695 test ( 'end tags are case-insensitive.' , ( ) => {
16481696 const ast = baseParse ( '<div>hello</DIV>after' )
16491697 const element = ast . children [ 0 ] as ElementNode
@@ -1884,6 +1932,15 @@ foo
18841932 )
18851933 } )
18861934
1935+ it ( 'self-closing pre tag' , ( ) => {
1936+ const ast = baseParse ( `<pre/><span>\n foo bar</span>` , {
1937+ isPreTag : tag => tag === 'pre'
1938+ } )
1939+ const elementAfterPre = ast . children [ 1 ] as ElementNode
1940+ // should not affect the <span> and condense its whitepsace inside
1941+ expect ( ( elementAfterPre . children [ 0 ] as TextNode ) . content ) . toBe ( ` foo bar` )
1942+ } )
1943+
18871944 it ( 'should NOT condense whitespaces in RCDATA text mode' , ( ) => {
18881945 const ast = baseParse ( `<textarea>Text:\n foo</textarea>` , {
18891946 getTextMode : ( { tag } ) =>
0 commit comments