LibWeb: Clear stylesheet pointer when disabling link element

This fixes a crash when enabling an already disabled link element.
Fixes a crash when changing mdbook themes.
This commit is contained in:
Gingeh 2025-02-01 15:47:02 +11:00 committed by Tim Ledbetter
parent 1bd73184da
commit 59ba2fb2ee
Notes: github-actions[bot] 2025-02-01 08:12:45 +00:00
3 changed files with 17 additions and 1 deletions

View file

@ -166,8 +166,10 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
m_explicitly_enabled = true;
if (m_relationship & Relationship::Stylesheet) {
if (name == HTML::AttributeNames::disabled && m_loaded_style_sheet)
if (name == HTML::AttributeNames::disabled && m_loaded_style_sheet) {
document_or_shadow_root_style_sheets().remove_a_css_style_sheet(*m_loaded_style_sheet);
m_loaded_style_sheet = nullptr;
}
// https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet:fetch-and-process-the-linked-resource
// The appropriate times to fetch and process this type of link are: