This repository has been archived by the owner on Jul 28, 2018. It is now read-only.
Attach affected nodes to lifecycle events #537
Merged
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.
Problem:
… attaches duplicate event handlers on every partial replacement (since the body didn't change).
Same with
page:load
.Turbolinks.replace()
doesn't trigger thepage:load
event, even though it's inserting new elements into the DOM (which people may want to transform the same way they do on normal page loads).What this PR does:
Attach affected nodes to the
page:before-unload
,page:change
andpage:load
events.The above snippet could be rewritten as follow:
Fire
page:load
inTurbolinks.replace()
(passing the loaded nodes).Docs soon.
cc @dhh