mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
fix(ssr): textarea keeps undefined/null values (#11121)
* fix(ssr): textarea keeps undefined/null values * refactor(ssr): Code review changes for null values in textareas
This commit is contained in:
parent
67825c24bc
commit
b8bd149d8a
@ -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 {
|
||||
@ -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()
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user