phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
317 stars 90 forks source link

Use window.parent instead of window.top for reload #92

Closed lewisf closed 5 years ago

lewisf commented 5 years ago

Using window.parent allows live reload to work if the application we're working on is embedded within an iframe in another site.

This is common in the case of widgets.

It was mentioned in #72 that "in some cases it's good that we are refreshing whole page instead of iframe's content" but I'm struggling to think of when it makes sense to refresh the whole page instead of just the thing that has changed (or maybe I just haven't run into that case)?

josevalim commented 5 years ago

:heart: :green_heart: :blue_heart: :yellow_heart: :purple_heart:

chrismccord commented 5 years ago

@josevalim we used window.top for a good reason, and I believe you were the one that changed it from parent to top originally, with a comment like – "don't ask me why I know this about iframe" :D. So there is good reason it was like this before, but I don't remember why. Maybe IE support?

lewisf commented 5 years ago

Care to share the wisdom around this?

I'll just fork this during development, but would love to know why window.top is preferred!

josevalim commented 5 years ago

We can’t recall but this is bound to break some stuff. I think the best way to go is to make it an option on the Elixir side of things and then choose it dyncamically on the JS sides. You can see how the Elixir side injects some variables in JS. This way we can support both accordingly. --

José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D