mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-10-26 06:49:12 +03:00
LibWeb: Allow moving StyleSheets between documents without falling apart
We have to unregister link element stylesheets from the old document's StyleSheetList when moving them into a new document. This makes it possible to load GitHub contributor graphs. :^)
This commit is contained in:
parent
511e411def
commit
8e56367092
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8e56367092 Pull-request: https://github.com/SerenityOS/serenity/pull/24061
@ -0,0 +1,3 @@
|
||||
Sheets in old doc: 0
|
||||
Sheets in new doc: 1
|
||||
PASS (didn't crash)
|
@ -0,0 +1,11 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
let doc = new DOMParser().parseFromString(`<link rel="stylesheet" href="data:text/css,div{}">`, `text/html`);
|
||||
let link = doc.head.firstChild;
|
||||
document.head.appendChild(link);
|
||||
test(() => {
|
||||
println("Sheets in old doc: " + doc.styleSheets.length)
|
||||
println("Sheets in new doc: " + document.styleSheets.length)
|
||||
println("PASS (didn't crash)");
|
||||
})
|
||||
</script>
|
@ -46,6 +46,15 @@ void HTMLLinkElement::initialize(JS::Realm& realm)
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLinkElement);
|
||||
}
|
||||
|
||||
void HTMLLinkElement::removed_from(Node* old_parent)
|
||||
{
|
||||
Base::removed_from(old_parent);
|
||||
if (m_loaded_style_sheet) {
|
||||
document_or_shadow_root_style_sheets().remove_a_css_style_sheet(*m_loaded_style_sheet);
|
||||
m_loaded_style_sheet = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLLinkElement::inserted()
|
||||
{
|
||||
HTMLElement::inserted();
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
virtual ~HTMLLinkElement() override;
|
||||
|
||||
virtual void inserted() override;
|
||||
virtual void removed_from(Node* old_parent) override;
|
||||
|
||||
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
||||
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
||||
|
Loading…
Reference in New Issue
Block a user