-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lazyRoot
functionality for next/image
#33933
Merged
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ee0f879
fixed lazyRoot functionality
11koukou 5ce2331
Merge branch 'canary' into fixLazyroot
11koukou 42fcec3
Update packages/next/client/use-intersection.tsx
11koukou bf847d8
Update packages/next/client/use-intersection.tsx
11koukou cf70d1b
Update packages/next/client/use-intersection.tsx
11koukou 74f9d2b
Update packages/next/client/use-intersection.tsx
11koukou 021e79c
Update packages/next/client/use-intersection.tsx
11koukou 3d6d309
removed getKeyIndex
11koukou 7d9fb0d
fixed freeing observers' idList
11koukou 8a5c925
Merge branch 'canary' into fixLazyroot
11koukou c149504
fixed the test
11koukou 10d0758
Merge branch 'fixLazyroot' of https://github.com/11koukou/next.js int…
11koukou 13077c8
Merge branch 'canary' into fixLazyroot
11koukou 31e08a8
Merge branch 'canary' into fixLazyroot
11koukou 25658f1
Merge branch 'canary' into fixLazyroot
11koukou 73b9cc5
Merge branch 'canary' into fixLazyroot
styfle 07f87c2
Merge branch 'canary' into fixLazyroot
styfle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
test/integration/image-component/default/pages/lazy-noref.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can we remove from this array? This will grow unbounded as the number of images increases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was something that I was going to ask as well! Well let me work on it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I think about this problem more, the idea is that we need to know if the
root
prop has been seen before at a givenrootMargin
.So what about if we created nested maps? The first could be a WeakMap to
root
element and then we can nest therootMargin
.I think the WeakMap will automatically remove the reference when the DOM node is destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be an elegant solution indeed but the WeakMap can only have an object as a key. Passing an Html element as a key produces runtime error.
However in my latest push I simply implemented removing the entry from the idList just after the corresponding observer is deleted as well. Eventually when everything becomes visible both idList and observers' Map are empty.
Besides, idList would rarely grow too large as that would mean that every Image has a different lazyRoot and lazyBoundary combination.