LibWeb: Only delay "load" event for script elements that load something

We shouldn't delay the load event for scripts that we're completely
refusing to run anyway. Also, for scripts that have inline text content,
we don't need to delay them either, as they will become ready before
returning from "prepare script".

This makes the "load" event finally fire on lots of websites, including
Wikipedia. :^)
This commit is contained in:
Andreas Kling 2022-03-19 16:11:36 +01:00
parent c1f0d21bbe
commit cbd343dced
Notes: sideshowbarker 2024-07-17 17:07:07 +09:00
3 changed files with 5 additions and 7 deletions

View file

@ -2094,10 +2094,6 @@ void HTMLParser::handle_text(HTMLToken& token)
NonnullRefPtr<HTMLScriptElement> script = verify_cast<HTMLScriptElement>(current_node());
// The document's "load" event is delayed until every script becomes ready.
// See HTMLScriptElement internals for how readiness is determined.
script->begin_delaying_document_load_event({}, *m_document);
(void)m_stack_of_open_elements.pop();
m_insertion_mode = m_original_insertion_mode;
// Let the old insertion point have the same value as the current insertion point.