Skip to content

Nested pre tag working exception in vue-template-compiler #12965

Open
@daysv

Description

@daysv

Version

2.7.14

Reproduction link

codepen.io/daysv/pen/JjaGLVP

Steps to reproduce

In pure html:
https://codepen.io/daysv/pen/yLxeKqj

Demo:

const compiler = require('vue-template-compiler')

const str = `<div v-pre>
1

2

<div style="padding-left: 20px">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
c
</div>
3
</div>`

const result = compiler.compile(str, { whitespace: 'condense' })
console.log(result.staticRenderFns)

What is expected?

with(this){return _c('pre',[_v("1\\n\\n2\\n\\n"),_c('pre',{staticStyle:{"padding-left":"20px"}},[_v("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa\\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\nc\\n")]),_v("\\n3\\n")])}

What is actually happening?

with(this){return _c('pre',[_v("1\\n\\n2\\n\\n"),_c('pre',{staticStyle:{"padding-left":"20px"}},[_v("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa\\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\nc\\n")]),_v(" 3 ")])}


bug here

let inPre = true;

// ....

if (platformIsPreTag(element.tag)) {
  inPre = false;
}

// ...

if (platformIsPreTag(element.tag)) {
  inPre = true; 
}

I think number should be used instead of boolean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions