mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): handle multi-line slots in islands (#24212)
This commit is contained in:
parent
bb533f8d25
commit
c3cf55d963
@ -97,7 +97,7 @@ function isBinding (attr: string): boolean {
|
||||
|
||||
function getBindings (bindings: Record<string, string>, vfor?: [string, string]): string {
|
||||
if (Object.keys(bindings).length === 0) { return '' }
|
||||
const content = Object.entries(bindings).filter(b => b[0] !== '_bind').map(([name, value]) => isBinding(name) ? `${name.slice(1)}: ${value}` : `${name}: \`${value}\``).join(',')
|
||||
const content = Object.entries(bindings).filter(b => b[0] && b[0] !== '_bind').map(([name, value]) => isBinding(name) ? `${name.slice(1)}: ${value}` : `${name}: \`${value}\``).join(',')
|
||||
const data = bindings._bind ? `mergeProps(${bindings._bind}, { ${content} })` : `{ ${content} }`
|
||||
if (!vfor) {
|
||||
return `:nuxt-ssr-slot-data="JSON.stringify([${data}])"`
|
||||
|
@ -34,6 +34,10 @@ describe('islandTransform - server and island components', () => {
|
||||
<slot />
|
||||
|
||||
<slot name="named" :some-data="someData" />
|
||||
<slot
|
||||
name="other"
|
||||
:some-data="someData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -48,6 +52,7 @@ describe('islandTransform - server and island components', () => {
|
||||
<div style=\\"display: contents;\\" nuxt-ssr-slot-name=\\"default\\" />
|
||||
|
||||
<div style=\\"display: contents;\\" nuxt-ssr-slot-name=\\"named\\" :nuxt-ssr-slot-data=\\"JSON.stringify([{ some-data: someData }])\\"/>
|
||||
<div style=\\"display: contents;\\" nuxt-ssr-slot-name=\\"other\\" :nuxt-ssr-slot-data=\\"JSON.stringify([{ some-data: someData }])\\"/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang=\\"ts\\">
|
||||
|
Loading…
Reference in New Issue
Block a user