Skip to content
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

Implement Preloader with Mutation Observer #1206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link
Contributor

Remove all external calls to preloadOnLoadLinksForView. In its place, introduce a new AttributeObserver to monitor all elements within a scope that:

  • added the [data-turbo-preload] attribute
  • connected with the [data-turbo-preload] attribute
  • connected with children that have the [data-turbo-preload] attribute

The details of this observation are abstracted into the AttributeObserver, which will notify its delegate whenever those conditions are met. The delegate is responsible for responding to those conditions. For example, the Preloader ensures that the element is an <a> element, and that the element matches the expectations of its own delegate (the Session instance).

Remove all external calls to `preloadOnLoadLinksForView`. In its place,
introduce a new `AttributeObserver` to monitor all elements within a
scope that:

* added the `[data-turbo-preload]` attribute
* connected with the `[data-turbo-preload]` attribute
* connected with children that have the `[data-turbo-preload]`
  attribute

The details of this observation are abstracted into the
`AttributeObserver`, which will notify its delegate whenever those
conditions are met. The delegate is responsible for responding to those
conditions. For example, the `Preloader` ensures that the element is an
`<a>` element, and that the element matches the expectations of **its**
own delegate (the `Session` instance).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant