1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:57:44 +00:00

LibWeb: Expose barebones CSSStyleDeclaration to JavaScript

You can now access an element's inline style via Element.style.
The interface is not very capable yet though. :^)
This commit is contained in:
Andreas Kling 2021-03-13 22:39:55 +01:00
parent 0759f54bd3
commit 33e3f0c71f
9 changed files with 43 additions and 2 deletions

View file

@ -380,4 +380,11 @@ void Element::set_shadow_root(RefPtr<ShadowRoot> shadow_root)
invalidate_style();
}
NonnullRefPtr<CSS::CSSStyleDeclaration> Element::style_for_bindings()
{
if (!m_inline_style)
m_inline_style = CSS::CSSStyleDeclaration::create({});
return *m_inline_style;
}
}

View file

@ -92,6 +92,8 @@ public:
const CSS::CSSStyleDeclaration* inline_style() const { return m_inline_style; }
NonnullRefPtr<CSS::CSSStyleDeclaration> style_for_bindings();
// FIXME: innerHTML also appears on shadow roots. https://w3c.github.io/DOM-Parsing/#dom-innerhtml
String inner_html() const;
void set_inner_html(StringView);

View file

@ -23,4 +23,6 @@ interface Element : Node {
readonly attribute Element? nextElementSibling;
readonly attribute Element? previousElementSibling;
[ImplementedAs=style_for_bindings] readonly attribute CSSStyleDeclaration style;
};