Skip to content

Commit

Permalink
fix: ssr-string static include \n case html's style parse faied (fix: v…
Browse files Browse the repository at this point in the history
  • Loading branch information
869288142 committed Oct 19, 2021
1 parent ddfa1ee commit a23744a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/optimizing-compiler/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function genStyleSegments (
vShowExpression: ?string
): Array<StringSegment> {
if (staticStyle && !styleBinding && !vShowExpression) {
return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle)}` }]
return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle.replace(/\n/g, ''))}` }];
} else {
return [{
type: EXPRESSION,
Expand Down
18 changes: 18 additions & 0 deletions test/ssr/ssr-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,24 @@ describe('SSR: renderToString', () => {
})
})

it('only static style and not v-show ', done => {
renderVmWithOptions({
template: ` <div
style="
margin-top:
0px;width: 24px;
height: 16px;
vertical-align: text-bottom;
fill: #bfbfc3;"
></div>`,
}, result => {
expect(result).toContain(
'<div data-server-rendered="true" style="width:24px;height:16px;vertical-align:text-bottom;fill:#bfbfc3;"></div>'
)
done()
})
})

function renderVmWithOptions (options, cb) {
renderToString(new Vue(options), (err, res) => {
expect(err).toBeNull()
Expand Down

0 comments on commit a23744a

Please sign in to comment.