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(ssr): textarea keeps undefined/null values #11121

Merged
merged 2 commits into from
Sep 21, 2020
Merged
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: 2 additions & 2 deletions src/platforms/web/server/modules/dom-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import VNode from 'core/vdom/vnode'
import { renderAttr } from './attrs'
import { isDef, isUndef, extend } from 'shared/util'
import { isDef, isUndef, extend, toString } from 'shared/util'
import { propsToAttrMap, isRenderableAttr } from '../util'

export default function renderDOMProps (node: VNodeWithData): string {
Expand All @@ -28,7 +28,7 @@ export default function renderDOMProps (node: VNodeWithData): string {
} else if (key === 'textContent') {
setText(node, props[key], false)
} else if (key === 'value' && node.tag === 'textarea') {
setText(node, props[key], false)
setText(node, toString(props[key]), false)
} else {
// $flow-disable-line (WTF?)
const attr = propsToAttrMap[key] || key.toLowerCase()
Expand Down
19 changes: 19 additions & 0 deletions test/ssr/ssr-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,25 @@ describe('SSR: renderToString', () => {

renderToString(vueInstance, err => done(err))
})

it('undefined v-model with textarea', done => {
renderVmWithOptions({
render (h) {
return h('div', [
h('textarea', {
domProps: {
value: null
}
})
])
}
}, result => {
expect(result).toContain(
'<div data-server-rendered="true"><textarea></textarea></div>'
)
done()
})
})
})

function renderVmWithOptions (options, cb) {
Expand Down