-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
fix: the first LF following pre and textarea tag should be ignored, fix #5992 #6022
Conversation
src/compiler/parser/html-parser.js
Outdated
@@ -59,6 +59,10 @@ const decodingMap = { | |||
const encodedAttr = /&(?:lt|gt|quot|amp);/g | |||
const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g | |||
|
|||
// #5992 | |||
const ignoreFirstLFTagList = makeMap('pre,textarea', true) | |||
const isIgnoreFirstLf = (tag, html) => tag && ignoreFirstLFTagList(tag.toLowerCase()) && html[0] === '\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need to call toLowerCase()
here, and it seems <textarea>
will never reach to this function since isPlainTextElement('textarea')
equals true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- html5 tag names are case-insensitive, so we use lower case to compare
- isIgnoreFirstLf will be invoked when in textarea parse https://github.com/vuejs/vue/pull/6022/files#diff-084898b8c9f6d4d2833b18312180ef8fR172
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It'll call
toLowerCase()
when passing true tomakeMap
as the second param. - I didn't notice those changes starting from line 172, my fault😂.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks, I missed it, I'll update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The naming is much better, thanks 😆 |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
fix #5992