aurelia / hot-module-reload

Core functionality for Aurelia's hot-module-reolad (HMR) capabilities, which is shared by all loaders and tools.
MIT License
25 stars 8 forks source link

Hidden Views do not reload #1

Open niieani opened 7 years ago

niieani commented 7 years ago

This includes Views which are conditionally hidden (e.g. with if.bind), not the ones that are simply not shown (hidden via CSS).

To reproduce:

  1. hide a View so that it's removed from the DOM
  2. change the template of that View
  3. unhide the View

The View will still contain old data, and its ViewFactory and template fragment will be out of date with the module, thus any further HMR on that Element will fail until the View is fully re-created (e.g. by switching routes).

To fix this we'll need to switch the way we traverse Controllers in search for Views matching a given template. We need to match all the Views, whether they're attached and present in the DOM or not.

If that still does not make it possible to access all the created View instances, we can think of alternative solutions, such as storing old fragments, or tracking Views with afterCreated hook and then replacing the ViewFactories in a beforeBind hook. However, this would not be a great solution because this would cause a memory-leak, as the memory consumption of the site would grow with every hot-reload of any View.