mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 06:31:27 +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 () => {
|
return () => {
|
||||||
const vnodes: VNode[] = []
|
const vnodes: VNode[] = new Array(1)
|
||||||
|
|
||||||
if (nuxtApp.ssrContext?.islandContext && slots.default) {
|
if (nuxtApp.ssrContext?.islandContext && slots.default) {
|
||||||
vnodes.push(h('div', {
|
vnodes[0] = h('div', {
|
||||||
'style': 'display: contents;',
|
'style': 'display: contents;',
|
||||||
'data-island-uid': '',
|
'data-island-uid': '',
|
||||||
'data-island-slot': props.name,
|
'data-island-slot': props.name,
|
||||||
}, {
|
}, {
|
||||||
// Teleport in slot to not be hydrated client-side with the staticVNode
|
// Teleport in slot to not be hydrated client-side with the staticVNode
|
||||||
default: () => [createVNode(Teleport, { to: `island-slot=${componentName};${props.name}` }, slots.default?.())],
|
default: () => [createVNode(Teleport, { to: `island-slot=${componentName};${props.name}` }, slots.default?.())],
|
||||||
}))
|
})
|
||||||
} else {
|
} else {
|
||||||
vnodes.push(h('div', {
|
vnodes[0] = h('div', {
|
||||||
'style': 'display: contents;',
|
'style': 'display: contents;',
|
||||||
'data-island-uid': '',
|
'data-island-uid': '',
|
||||||
'data-island-slot': props.name,
|
'data-island-slot': props.name,
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slots.fallback) {
|
if (slots.fallback) {
|
||||||
|
@ -89,7 +89,7 @@ export function vforToArray (source: any): any[] {
|
|||||||
if (import.meta.dev && !Number.isInteger(source)) {
|
if (import.meta.dev && !Number.isInteger(source)) {
|
||||||
console.warn(`The v-for range expect an integer value but got ${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++) {
|
for (let i = 0; i < source; i++) {
|
||||||
array[i] = i
|
array[i] = i
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user