mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-07 19:52:55 +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:
parent
1bd73184da
commit
59ba2fb2ee
Notes:
github-actions[bot]
2025-02-01 08:12:45 +00:00
Author: https://github.com/Gingeh
Commit: 59ba2fb2ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3423
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 17 additions and 1 deletions
|
@ -166,8 +166,10 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
|
||||||
m_explicitly_enabled = true;
|
m_explicitly_enabled = true;
|
||||||
|
|
||||||
if (m_relationship & Relationship::Stylesheet) {
|
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);
|
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
|
// 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:
|
// 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>
|
Loading…
Add table
Add a link
Reference in a new issue