mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
perf: pre-allocated array teleport island + utils
This commit is contained in:
parent
944e758daf
commit
cca39cd535
@ -35,23 +35,23 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
return () => {
|
||||
const vnodes: VNode[] = []
|
||||
const vnodes: VNode[] = new Array(1)
|
||||
|
||||
if (nuxtApp.ssrContext?.islandContext && slots.default) {
|
||||
vnodes.push(h('div', {
|
||||
vnodes[0] = h('div', {
|
||||
'style': 'display: contents;',
|
||||
'data-island-uid': '',
|
||||
'data-island-slot': props.name,
|
||||
}, {
|
||||
// Teleport in slot to not be hydrated client-side with the staticVNode
|
||||
default: () => [createVNode(Teleport, { to: `island-slot=${componentName};${props.name}` }, slots.default?.())],
|
||||
}))
|
||||
})
|
||||
} else {
|
||||
vnodes.push(h('div', {
|
||||
vnodes[0] = h('div', {
|
||||
'style': 'display: contents;',
|
||||
'data-island-uid': '',
|
||||
'data-island-slot': props.name,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
if (slots.fallback) {
|
||||
|
@ -89,7 +89,7 @@ export function vforToArray (source: any): any[] {
|
||||
if (import.meta.dev && !Number.isInteger(source)) {
|
||||
console.warn(`The v-for range expect an integer value but got ${source}.`)
|
||||
}
|
||||
const array: number[] = []
|
||||
const array: number[] = new Array(source)
|
||||
for (let i = 0; i < source; i++) {
|
||||
array[i] = i
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user