mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-03 22:34:21 +00:00
chore: remove comment and unnecessary divs
This commit is contained in:
parent
da1db599cc
commit
0b769781c5
@ -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,
|
|
||||||
])
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user