Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/server-renderer/__tests__/render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,5 +1229,23 @@ function testRender(type: string, render: typeof renderToString) {
// during the render phase
expect(getterSpy).toHaveBeenCalledTimes(2)
})

test('props modifiers in render attrs', async () => {
const app = createApp({
setup() {
return () =>
h(
'div',
{
'^attr': 'attr',
'.prop': 'prop',
},
'Functional Component',
)
},
})
const html = await render(app)
expect(html).toBe(`<div attr="attr">Functional Component</div>`)
})
})
}
8 changes: 6 additions & 2 deletions packages/server-renderer/src/helpers/ssrRenderAttrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ export function ssrRenderAttrs(
tag?: string,
): string {
let ret = ''
for (const key in props) {
for (let key in props) {
if (
shouldIgnoreProp(key) ||
isOn(key) ||
(tag === 'textarea' && key === 'value')
(tag === 'textarea' && key === 'value') ||
// force as property (not rendered in SSR)
key.startsWith('.')
) {
continue
}
const value = props[key]
// force as attribute
if (key.startsWith('^')) key = key.slice(1)
if (key === 'class') {
ret += ` class="${ssrRenderClass(value)}"`
} else if (key === 'style') {
Expand Down
Loading