mirror of https://github.com/vuejs/core.git
parent
6958ec1b37
commit
121eb32fb0
|
@ -98,6 +98,17 @@ describe('ssr: renderAttrs', () => {
|
||||||
)
|
)
|
||||||
).toBe(` fooBar="ok"`)
|
).toBe(` fooBar="ok"`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('preserve name on svg elements', () => {
|
||||||
|
expect(
|
||||||
|
ssrRenderAttrs(
|
||||||
|
{
|
||||||
|
viewBox: 'foo'
|
||||||
|
},
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toBe(` viewBox="foo"`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('ssr: renderAttr', () => {
|
describe('ssr: renderAttr', () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { escapeHtml, stringifyStyle } from '@vue/shared'
|
import { escapeHtml, isSVGTag, stringifyStyle } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
normalizeClass,
|
normalizeClass,
|
||||||
normalizeStyle,
|
normalizeStyle,
|
||||||
|
@ -51,8 +51,8 @@ export function ssrRenderDynamicAttr(
|
||||||
return ``
|
return ``
|
||||||
}
|
}
|
||||||
const attrKey =
|
const attrKey =
|
||||||
tag && tag.indexOf('-') > 0
|
tag && (tag.indexOf('-') > 0 || isSVGTag(tag))
|
||||||
? key // preserve raw name on custom elements
|
? key // preserve raw name on custom elements and svg
|
||||||
: propsToAttrMap[key] || key.toLowerCase()
|
: propsToAttrMap[key] || key.toLowerCase()
|
||||||
if (isBooleanAttr(attrKey)) {
|
if (isBooleanAttr(attrKey)) {
|
||||||
return includeBooleanAttr(value) ? ` ${attrKey}` : ``
|
return includeBooleanAttr(value) ? ` ${attrKey}` : ``
|
||||||
|
|
Loading…
Reference in New Issue