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

fix: the first LF following pre and textarea tag should be ignored, fix #5992 #6022

Merged
merged 5 commits into from
Jul 10, 2017

Conversation

defcc
Copy link
Member

@defcc defcc commented Jul 3, 2017

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
fix #5992

@@ -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'
Copy link
Member

@javoski javoski Jul 3, 2017

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.

Copy link
Member Author

@defcc defcc Jul 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. html5 tag names are case-insensitive, so we use lower case to compare
  2. isIgnoreFirstLf will be invoked when in textarea parse https://github.com/vuejs/vue/pull/6022/files#diff-084898b8c9f6d4d2833b18312180ef8fR172

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It'll call toLowerCase() when passing true to makeMap as the second param.
  2. I didn't notice those changes starting from line 172, my fault😂.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@yyx990803 yyx990803 merged commit 4d68079 into vuejs:dev Jul 10, 2017
@defcc
Copy link
Member Author

defcc commented Jul 11, 2017

The naming is much better, thanks 😆

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

Successfully merging this pull request may close these issues.

ssr unexpected hydration bailout with <pre> tag
4 participants