Fix iframe re-loading when serving certain fixtures #358
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.
When serving either the
basic
or thetypescript
fixture locally (viabuild:basic && serve:basic
orbuild:typescript && serve:typescript
), each iframe would re-load on every code change. This shouldn't happen when usingparamType: 'hash'
because hash replacements typically don't cause page navigation.It turns out that the culprit was the default behaviour of the
serve
CLI. By default,cleanUrls
istrue
. This results in all requests for.html
files being redirected to the same path but without.html
(see screenshot). This was occurring for iframe updates, which point directly to/frame.html
, resulting in a navigation and full re-load of the frame.The fix is to exclude
/frame.html
from this behaviour by configuring this inside aserve.json
file in each fixture directory.It turns out the
themed
fixture already had aserve.json
configuration, but it was just blanket-disabling this behaviour for all paths, which doesn't really achieve anything, but it means that you have to explicitly navigate to/index.html
to get thethemed
fixture to load locally, which is annoying.Note
If you test this locally, you might still see the full re-load happening. This is probably due to your browser cache. Disabling it for the page, or forcing a full page reload should fix it.