Skip to content
Permalink
Browse files
fix(ssr): respect case when rendering dynamic attrs on svg
fix #6755
  • Loading branch information
yyx990803 committed Sep 27, 2022
1 parent 6958ec1 commit 121eb32fb0a21cf9988d788cfad1b4249b15997b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
@@ -98,6 +98,17 @@ describe('ssr: renderAttrs', () => {
)
).toBe(` fooBar="ok"`)
})

test('preserve name on svg elements', () => {
expect(
ssrRenderAttrs(
{
viewBox: 'foo'
},
'svg'
)
).toBe(` viewBox="foo"`)
})
})

describe('ssr: renderAttr', () => {
@@ -1,4 +1,4 @@
import { escapeHtml, stringifyStyle } from '@vue/shared'
import { escapeHtml, isSVGTag, stringifyStyle } from '@vue/shared'
import {
normalizeClass,
normalizeStyle,
@@ -51,8 +51,8 @@ export function ssrRenderDynamicAttr(
return ``
}
const attrKey =
tag && tag.indexOf('-') > 0
? key // preserve raw name on custom elements
tag && (tag.indexOf('-') > 0 || isSVGTag(tag))
? key // preserve raw name on custom elements and svg
: propsToAttrMap[key] || key.toLowerCase()
if (isBooleanAttr(attrKey)) {
return includeBooleanAttr(value) ? ` ${attrKey}` : ``

0 comments on commit 121eb32

Please sign in to comment.