LibWeb: Only react to link element attribute changes when BC connected

Link elements that aren't "browsing-context connected" should not
trigger a resource fetch when their attributes change.

This fixes an issue where we'd waste time by loading every style sheet
twice! :^)
This commit is contained in:
Andreas Kling 2024-04-26 09:29:27 +02:00
commit a4625e3943
Notes: sideshowbarker 2024-07-17 10:31:19 +09:00
3 changed files with 22 additions and 11 deletions

View file

@ -335,6 +335,13 @@ bool Node::is_connected() const
return shadow_including_root().is_document();
}
// https://html.spec.whatwg.org/multipage/infrastructure.html#browsing-context-connected
bool Node::is_browsing_context_connected() const
{
// A node is browsing-context connected when it is connected and its shadow-including root's browsing context is non-null.
return is_connected() && shadow_including_root().document().browsing_context();
}
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const
{