Skip to content

[labs/observers] IntersectionController.observe should restore the observed target on reconnect #2902

Closed

Description

@e111077

Description

If you init an IntersectionController with a target (oldTarget), and then observe another target with IntersectionController.observe(newTarget) (meaning to override oldTarget), if the host is disconnected then reconnected, then oldTarget is the only target that is observed and not newTarget.

Steps to Reproduce

  1. Init an intersectionObserver with a target
  2. call IntersectionObserver.observe with a new target
  3. disconnect the custom element
  4. reconnect the custom element
  5. note that the instersectionController is only being called with the old target

Live Reproduction Link

https://lit.dev/playground/#gist=92c47a7579efd223f8490988e6f47efb

  • Scroll up and down to see the log update
  • Observe the targets being observed
  • click the Disconnect the CE button
  • click the Reconnect the CE button
  • scroll around again and observe only outsideDiv is being called

Expected Results

After reconnect, target: intendedTarget should be logged.

Personally I think there should be a way to unobserve the constructor's target, but if not, calling this.observe(A) should re-observe on element A on host reconnect

Actual Results

After reconnect, only target: oldTarget is logged.

Activity

  1. changed the title [-][labs/observers] IntersectionController.observe should restore the observed target on reconnect[/-] [+][@lit-labs/observers] IntersectionController.observe should restore the observed target on reconnect[/+] on May 14, 2022
  2. changed the title [-][@lit-labs/observers] IntersectionController.observe should restore the observed target on reconnect[/-] [+][labs/observers] IntersectionController.observe should restore the observed target on reconnect[/+] on Jun 16, 2022
  3. moved this to 📋 Triaged in Lit Project Boardon Jun 16, 2022
  4. moved this from 📋 Triaged to 🤔 In Review in Lit Project Boardon Sep 30, 2022
  5. Repository owner moved this from 🤔 In Review to ✅ Done in Lit Project Boardon Oct 4, 2022
  6. added a commit that references this issue on Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions