mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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:
@@ -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:
|
||||
|
||||
1
Tests/LibWeb/Text/expected/link-re-enable-crash.txt
Normal file
1
Tests/LibWeb/Text/expected/link-re-enable-crash.txt
Normal file
@@ -0,0 +1 @@
|
||||
PASS (didn't crash)
|
||||
13
Tests/LibWeb/Text/input/link-re-enable-crash.html
Normal file
13
Tests/LibWeb/Text/input/link-re-enable-crash.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="include.js"></script>
|
||||
<link rel="stylesheet" href="valid.css">
|
||||
<script>
|
||||
test(() => {
|
||||
const link = document.querySelector("link");
|
||||
link.onload = () => {
|
||||
link.disabled = true;
|
||||
link.disabled = false;
|
||||
println("PASS (didn't crash)");
|
||||
};
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user