Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 5, 2022
1 parent d9912ae commit f2df42b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/next/client/use-intersection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Observer = {
elements: Map<Element, ObserveCallback>
}

const hasIntersectionObserver = typeof IntersectionObserver !== 'undefined'
const hasIntersectionObserver = typeof IntersectionObserver === 'function'

export function useIntersection<T extends Element>({
rootRef,
Expand Down
10 changes: 6 additions & 4 deletions test/integration/image-component/basic/pages/missing-observer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useLayoutEffect } from 'react'
import Image from 'next/image'
import Script from 'next/script'

const Lazy = () => {
useLayoutEffect(() => {
IntersectionObserver = null //eslint-disable-line
})
return (
<div>
<Script
id="IntersectionObserver-null"
strategy="beforeInteractive"
dangerouslySetInnerHTML={{ __html: 'IntersectionObserver = null' }}
/>
<p id="stubtext">
This is a page with one lazy-loaded image, to be used in the test for
browsers without intersection observer.
Expand Down

0 comments on commit f2df42b

Please sign in to comment.