chore: remove comment and unnecessary divs

This commit is contained in:
Michael Brevard 2024-06-13 01:11:17 +03:00 committed by GitHub
parent da1db599cc
commit 0b769781c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,6 @@ import { useObserver } from '#app/utils'
import { getFragmentHTML } from '#app/components/utils' import { getFragmentHTML } from '#app/components/utils'
import { useNuxtApp } from '#app/nuxt' import { useNuxtApp } from '#app/nuxt'
// todo find a better way to do it ?
function elementIsVisibleInViewport (el: Element) { function elementIsVisibleInViewport (el: Element) {
const { top, left, bottom, right } = el.getBoundingClientRect() const { top, left, bottom, right } = el.getBoundingClientRect()
const { innerHeight, innerWidth } = window const { innerHeight, innerWidth } = window
@ -65,9 +64,7 @@ export const createLazyNetworkClientPage = (componentLoader: Component) => {
inheritAttrs: false, inheritAttrs: false,
setup (_, { attrs }) { setup (_, { attrs }) {
if (import.meta.server) { if (import.meta.server) {
return () => h('div', {}, [ return () => h(componentLoader, attrs)
h(componentLoader, attrs),
])
} }
const nuxt = useNuxtApp() const nuxt = useNuxtApp()
const instance = getCurrentInstance()! const instance = getCurrentInstance()!
@ -86,9 +83,7 @@ export const createLazyNetworkClientPage = (componentLoader: Component) => {
idleHandle = null idleHandle = null
} }
}) })
return () => h('div', {}, [ return () => isIdle.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null
isIdle.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null,
])
}, },
}) })
} }