fix(sfc): inherit parent scopeId on child rooot (#756)

This commit is contained in:
hareku
2020-02-21 22:44:13 +09:00
committed by GitHub
parent 1b9b235663
commit 9547c2b93d
5 changed files with 41 additions and 3 deletions

View File

@@ -562,7 +562,7 @@ describe('ssr: renderToString', () => {
}
expect(await renderToString(h(Parent))).toBe(
`<div data-v-child><span data-v-test data-v-child-s>slot</span></div>`
`<div data-v-test data-v-child><span data-v-test data-v-child-s>slot</span></div>`
)
})
})

View File

@@ -26,6 +26,14 @@ describe('ssr: renderAttrs', () => {
).toBe(` id="foo" title="bar"`)
})
test('empty value attrs', () => {
expect(
ssrRenderAttrs({
'data-v-abc': ''
})
).toBe(` data-v-abc`)
})
test('escape attrs', () => {
expect(
ssrRenderAttrs({

View File

@@ -53,7 +53,9 @@ export function ssrRenderDynamicAttr(
if (isBooleanAttr(attrKey)) {
return value === false ? `` : ` ${attrKey}`
} else if (isSSRSafeAttrName(attrKey)) {
return ` ${attrKey}="${escapeHtml(value)}"`
return value === ''
? ` ${attrKey}`
: ` ${attrKey}="${escapeHtml(value)}"`
} else {
console.warn(
`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`