Skip to content

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

@e111077

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions