[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2024-06-15 05:53:03 +00:00 committed by GitHub
parent 0ab38fcd09
commit cf9a905993
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 10 deletions

View File

@ -38,6 +38,6 @@ export const createVisibleLoader = (opts: Partial<IntersectionObserverInit>) =>
/** /**
* A utility used to determine which events should trigger hydration in components with event-based delayed hydration. * A utility used to determine which events should trigger hydration in components with event-based delayed hydration.
* @param events an array of events that will be used to trigger the hydration * @param events an array of events that will be used to trigger the hydration
*/ */
export const createEventLoader = (events: Array<keyof HTMLElementEventMap>) => events export const createEventLoader = (events: Array<keyof HTMLElementEventMap>) => events

View File

@ -1,5 +1,5 @@
import { createStaticVNode, createVNode, defineComponent, getCurrentInstance, h, onBeforeUnmount, onMounted, ref } from 'vue' import { createStaticVNode, createVNode, defineComponent, getCurrentInstance, h, onBeforeUnmount, onMounted, ref } from 'vue'
import type { Component, Ref, ComponentInternalInstance } from 'vue' import type { Component, ComponentInternalInstance, Ref } from 'vue'
// import ClientOnly from '#app/components/client-only' // import ClientOnly from '#app/components/client-only'
import { getFragmentHTML } from '#app/components/utils' import { getFragmentHTML } from '#app/components/utils'
import { useNuxtApp } from '#app/nuxt' import { useNuxtApp } from '#app/nuxt'
@ -90,7 +90,7 @@ export const createLazyNetworkClientPage = (componentLoader: Component) => {
}) })
} }
const eventsMapper = new WeakMap<ComponentInternalInstance,(() => void)[]>() const eventsMapper = new WeakMap<ComponentInternalInstance, (() => void)[]>()
/* @__NO_SIDE_EFFECTS__ */ /* @__NO_SIDE_EFFECTS__ */
export const createLazyEventClientPage = (componentLoader: Component) => { export const createLazyEventClientPage = (componentLoader: Component) => {
return defineComponent({ return defineComponent({
@ -109,7 +109,7 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
events.forEach((event) => { events.forEach((event) => {
const handler = () => { const handler = () => {
isTriggered.value = true isTriggered.value = true
registeredEvents.forEach((remove) => remove()) registeredEvents.forEach(remove => remove())
eventsMapper.delete(instance) eventsMapper.delete(instance)
} }
instance.vnode.el?.addEventListener(event, handler) instance.vnode.el?.addEventListener(event, handler)
@ -118,10 +118,10 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
eventsMapper.set(instance, registeredEvents) eventsMapper.set(instance, registeredEvents)
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
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) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null
} },
}) })
} }

View File

@ -2676,7 +2676,7 @@ describe('lazy import components', () => {
expect(await page.locator('body').getByText('This shouldn\'t be visible at first with network!').all()).toHaveLength(1) expect(await page.locator('body').getByText('This shouldn\'t be visible at first with network!').all()).toHaveLength(1)
expect(await page.locator('body').getByText('This should be visible at first with viewport!').all()).toHaveLength(1) expect(await page.locator('body').getByText('This should be visible at first with viewport!').all()).toHaveLength(1)
expect(await page.locator('body').getByText('This should be visible at first with events!').all()).toHaveLength(1) expect(await page.locator('body').getByText('This should be visible at first with events!').all()).toHaveLength(1)
const component = await page.locator('#lazyevent'); const component = await page.locator('#lazyevent')
const rect = (await component.boundingBox())! const rect = (await component.boundingBox())!
await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2) await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2)
await page.waitForLoadState('networkidle') await page.waitForLoadState('networkidle')

View File

@ -2,4 +2,4 @@
<div> <div>
This shouldn't be visible at first with events! This shouldn't be visible at first with events!
</div> </div>
</template> </template>

View File

@ -2,4 +2,4 @@
<div> <div>
This should be visible at first with events! This should be visible at first with events!
</div> </div>
</template> </template>

View File

@ -3,7 +3,7 @@
<LazyNCompAll message="lazy-named-comp-all" /> <LazyNCompAll message="lazy-named-comp-all" />
<LazyNCompClient message="lazy-named-comp-client" /> <LazyNCompClient message="lazy-named-comp-client" />
<LazyNCompServer message="lazy-named-comp-server" /> <LazyNCompServer message="lazy-named-comp-server" />
<LazyEventDelayedEvent id="lazyevent"/> <LazyEventDelayedEvent id="lazyevent" />
<LazyIdleDelayedNetwork /> <LazyIdleDelayedNetwork />
<div style="height:3000px"> <div style="height:3000px">
This is a very tall div This is a very tall div