perf: avoid wrapping client vnode in dynamic vnode

This commit is contained in:
Michael Brevard 2024-06-18 12:45:23 +03:00 committed by GitHub
parent b36d0b484e
commit 0f79d798e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,7 +51,7 @@ export const createLazyIOComponent = (componentLoader: Component) => {
}) })
return () => { return () => {
return h('div', { ref: el }, [ return h('div', { ref: el }, [
isIntersecting.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null, isIntersecting.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1) : null,
]) ])
} }
}, },
@ -85,7 +85,7 @@ export const createLazyNetworkComponent = (componentLoader: Component) => {
idleHandle = null idleHandle = null
} }
}) })
return () => isIdle.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null return () => isIdle.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1) : null
}, },
}) })
} }
@ -123,7 +123,7 @@ export const createLazyEventComponent = (componentLoader: Component) => {
registeredEvents?.forEach(remove => remove()) registeredEvents?.forEach(remove => remove())
eventsMapper.delete(instance) eventsMapper.delete(instance)
}) })
return () => isTriggered.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null return () => isTriggered.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1) : null
}, },
}) })
} }