Skip to content

Commit

Permalink
fix: Run the IndexHtmlRequestListener after the whole page is complete (
Browse files Browse the repository at this point in the history
#16786)

This ensures you can overwrite all parts of the index page in listeners
  • Loading branch information
Artur- authored May 12, 2023
1 parent e7b70e8 commit 508d8ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ public boolean synchronizedHandleRequest(VaadinSession session,

redirectToOldBrowserPageWhenNeeded(indexDocument);

// modify the page based on registered IndexHtmlRequestListener:
service.modifyIndexHtmlResponse(indexHtmlResponse);

if (!config.isProductionMode()) {
// Ensure no older tools incorrectly detect a bundle as production
// mode
Expand All @@ -170,6 +167,10 @@ public boolean synchronizedHandleRequest(VaadinSession session,
addLicenseChecker(indexDocument);
}

// this invokes any custom listeners and should be run when the whole
// page is constructed
service.modifyIndexHtmlResponse(indexHtmlResponse);

try {
response.getOutputStream()
.write(indexDocument.html().getBytes(UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void bootstrapListener_addListener_responseIsModified()
.toString(StandardCharsets.UTF_8.name());
Document document = Jsoup.parse(indexHtml);
Elements scripts = document.head().getElementsByTag("script");
int expectedScripts = 4;
int expectedScripts = 2;
Assert.assertEquals(expectedScripts, scripts.size());
Assert.assertEquals("testing.1",
scripts.get(expectedScripts - 2).attr("src"));
Expand Down

0 comments on commit 508d8ff

Please sign in to comment.