Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/compiler-ssr/src/transforms/ssrTransformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
createSimpleExpression(`"value" in ${tempId}`, false),
createSimpleExpression(`${tempId}.value`, false),
createSimpleExpression(
existingText ? existingText.content : ``,
existingText
? `${existingText.content[0] === '\n' ? '\n' : ''}${existingText.content}`
: ``,
true,
),
false,
Expand Down
8 changes: 8 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,14 @@ describe('SSR hydration', () => {
expect(`Hydration attribute mismatch`).toHaveBeenWarned()
})

test('<textarea> with newlines at the beginning', async () => {
const html = await renderToString(
createSSRApp({ template: '<textarea>\n</textarea>' }),
)
mountWithHydration(html, () => h('textarea', null, '\n'))
expect(`Hydration text content mismatch`).not.toHaveBeenWarned()
})

test('boolean attr handling', () => {
mountWithHydration(`<input />`, () => h('input', { readonly: false }))
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
Expand Down