ssorallen / turbo-react

A JavaScript library that transitions between static HTML pages on navigation; no app server required.
https://turbo-react.herokuapp.com/
Apache License 2.0
273 stars 16 forks source link

Replace `replaceChild` monkeypatch #20

Open ssorallen opened 9 years ago

ssorallen commented 9 years ago

TurboReact monkeypatches document.documentElement.replaceChild because Turbolinks (at least prior to v3) provides no way to intervene in the replacement process.

Monkeypatching the DOM is a Bad Thing:registered: and needs to be removed before this can graduate from an experiment. This might mean a new API in Turbolinks or using the v3 partial replacement API.

elia commented 9 years ago

having specific events before and after the DOM node removal/replacement would be a good thing™ too

ssorallen commented 9 years ago

Could you explain more what you're looking for? Turbolinks fires custom events during its lifecycle of replacing the page that might give you the hooks you'd like:

  • page:before-unload the page has been parsed and is about to be changed
  • page:change the page has been changed to the new version (and on DOMContentLoaded)