mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 08:03:21 +00:00
LibWeb: Add textContent attribute of HTMLScriptElement for TrustedTypes
This commit is contained in:
parent
f65dca1b53
commit
6b9c44390f
Notes:
github-actions[bot]
2025-09-16 08:58:51 +00:00
Author: https://github.com/tete17
Commit: 6b9c44390f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6058
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
4 changed files with 42 additions and 10 deletions
|
@ -678,6 +678,33 @@ WebIDL::ExceptionOr<void> HTMLScriptElement::set_src(TrustedTypes::TrustedScript
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#the-textContent-idl-attribute
|
||||
Variant<GC::Root<TrustedTypes::TrustedScript>, Utf16String, Empty> HTMLScriptElement::text_content() const
|
||||
{
|
||||
// 1. Return the result of running get text content with this.
|
||||
return descendant_text_content();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#the-textContent-idl-attribute
|
||||
WebIDL::ExceptionOr<void> HTMLScriptElement::set_text_content(TrustedTypes::TrustedScriptOrString text)
|
||||
{
|
||||
// 1. Let value be the result of calling Get Trusted Type compliant string with
|
||||
// TrustedScript, this’s relevant global object, the given value, HTMLScriptElement textContent, and script.
|
||||
auto const value = TRY(TrustedTypes::get_trusted_type_compliant_string(
|
||||
TrustedTypes::TrustedTypeName::TrustedScript,
|
||||
HTML::relevant_global_object(*this),
|
||||
text,
|
||||
TrustedTypes::InjectionSink::HTMLScriptElementtextContent,
|
||||
TrustedTypes::Script.to_string()));
|
||||
|
||||
// 2. Set this’s script text value to value.
|
||||
m_script_text = value;
|
||||
|
||||
// 3. Run set text content with this and value.
|
||||
string_replace_all(value);
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-async
|
||||
bool HTMLScriptElement::async() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue