diff --git a/src/platforms/web/server/modules/style.js b/src/platforms/web/server/modules/style.js index 4d32562823..4c7c2bbbad 100644 --- a/src/platforms/web/server/modules/style.js +++ b/src/platforms/web/server/modules/style.js @@ -23,7 +23,8 @@ export function genStyle (style: Object): string { function normalizeValue(key: string, value: any): string { if ( typeof value === 'string' || - (typeof value === 'number' && noUnitNumericStyleProps[key]) + (typeof value === 'number' && noUnitNumericStyleProps[key]) || + value === 0 ) { return `${key}:${value};` } else { diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 75bcc8cb1f..975197b6c1 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -1529,13 +1529,14 @@ describe('SSR: renderToString', () => { data: { style: { opacity: 0, // valid, opacity is unit-less - top: 0, // invalid, top requires unit + top: 0, // valid, top requires unit but 0 is allowed + left: 10, // invalid, left requires a unit marginTop: '10px' // valid } } }, result => { expect(result).toContain( - '
' + '
' ) done() })