mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibWeb: Implement the HTMLLinkElement.sheet
attribute
This returns the link element's associated style sheet.
This commit is contained in:
parent
db597843d6
commit
1821896ecf
Notes:
github-actions[bot]
2025-03-17 13:48:19 +00:00
Author: https://github.com/tcl3
Commit: 1821896ecf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3969
5 changed files with 26 additions and 1 deletions
|
@ -138,6 +138,12 @@ String HTMLLinkElement::media() const
|
||||||
return attribute(HTML::AttributeNames::media).value_or(String {});
|
return attribute(HTML::AttributeNames::media).value_or(String {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/cssom/#dom-linkstyle-sheet
|
||||||
|
GC::Ptr<CSS::CSSStyleSheet> HTMLLinkElement::sheet() const
|
||||||
|
{
|
||||||
|
return m_loaded_style_sheet;
|
||||||
|
}
|
||||||
|
|
||||||
bool HTMLLinkElement::has_loaded_icon() const
|
bool HTMLLinkElement::has_loaded_icon() const
|
||||||
{
|
{
|
||||||
return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data();
|
return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data();
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
void set_media(String);
|
void set_media(String);
|
||||||
String media() const;
|
String media() const;
|
||||||
|
|
||||||
|
GC::Ptr<CSS::CSSStyleSheet> sheet() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLLinkElement(DOM::Document&, DOM::QualifiedName);
|
HTMLLinkElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,4 @@ interface HTMLLinkElement : HTMLElement {
|
||||||
[CEReactions, Reflect] attribute DOMString target;
|
[CEReactions, Reflect] attribute DOMString target;
|
||||||
|
|
||||||
};
|
};
|
||||||
// FIXME: HTMLLinkElement includes LinkStyle;
|
HTMLLinkElement includes LinkStyle;
|
||||||
|
|
2
Tests/LibWeb/Text/expected/css/HTMLLinkElement-sheet.txt
Normal file
2
Tests/LibWeb/Text/expected/css/HTMLLinkElement-sheet.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
sheet property initial value: null
|
||||||
|
Sheet property after stylesheet loaded: [object CSSStyleSheet]
|
15
Tests/LibWeb/Text/input/css/HTMLLinkElement-sheet.html
Normal file
15
Tests/LibWeb/Text/input/css/HTMLLinkElement-sheet.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(done => {
|
||||||
|
const link = document.createElement("link");
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
document.head.appendChild(link);
|
||||||
|
println(`sheet property initial value: ${link.sheet}`);
|
||||||
|
link.href = "../valid.css";
|
||||||
|
link.onload = () => {
|
||||||
|
println(`Sheet property after stylesheet loaded: ${link.sheet}`);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue