This repository was archived by the owner on Oct 13, 2025. It is now read-only.
iAPI Router: Fix initial page initialization #3
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.
What?
Prevents an empty page when revisiting the initial page with full-site, client-side navigation enabled.
Required for the release of a proof of concept WooCommerce store that features full-page client-side navigation.
Why?
To fix this issue (pointed out by @SantosGuillamot).
The issue is that
@wordpress/interactivity-routerconsumes the initialVdom private prop exposed by@wordpress/interactivitysynchronously while that property is set asynchronously.That's not a problem when
@wordpress/interactivity-routeris dynamically imported, like in the region-based, client-side navigation.However, for full-site, client-side navigation, the
@wordpress/interactivity-routermodule is enqueued from the beginning and executed before@wordpress/interactivityhas finished executing the init function. This means thatinitialVdomis not available, leading to an empty body serialized for the initial page.How?
This approach makes the
initfunction to return a promise that is awaited before consuming theinitialVdomprop from the router module.