Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
daysv opened this issue Feb 21, 2023 · 0 comments
Open

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

daysv opened this issue Feb 21, 2023 · 0 comments

Comments

@daysv
Copy link

daysv commented Feb 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant