mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibWeb: Make parser <script> elements delay the document load event
This commit is contained in:
parent
fc2a255c72
commit
65e0f8184d
2 changed files with 8 additions and 0 deletions
|
@ -31,6 +31,10 @@ HTMLScriptElement::~HTMLScriptElement()
|
|||
void HTMLScriptElement::set_parser_document(Badge<HTMLParser>, DOM::Document& document)
|
||||
{
|
||||
m_parser_document = document;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#concept-script-script
|
||||
// The user agent must delay the load event of the element's node document until the script is ready.
|
||||
m_document_load_event_delayer.emplace(document);
|
||||
}
|
||||
|
||||
void HTMLScriptElement::set_non_blocking(Badge<HTMLParser>, bool non_blocking)
|
||||
|
@ -437,6 +441,7 @@ void HTMLScriptElement::prepare_script()
|
|||
void HTMLScriptElement::script_became_ready()
|
||||
{
|
||||
m_script_ready = true;
|
||||
m_document_load_event_delayer.clear();
|
||||
if (!m_script_ready_callback)
|
||||
return;
|
||||
m_script_ready_callback();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/Scripting/Script.h>
|
||||
|
||||
|
@ -63,6 +64,8 @@ private:
|
|||
Function<void()> m_script_ready_callback;
|
||||
|
||||
RefPtr<Script> m_script;
|
||||
|
||||
Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue