mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibWeb+IDLGenerators: Support nullable union types
This commit is contained in:
Notes:
github-actions[bot]
2026-03-25 13:21:41 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/cfd795f907f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8534 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/tcl3
@@ -770,14 +770,21 @@ Variant<GC::Root<TrustedTypes::TrustedScript>, Utf16String, Empty> HTMLScriptEle
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#the-textContent-idl-attribute
|
||||
WebIDL::ExceptionOr<void> HTMLScriptElement::set_text_content(TrustedTypes::TrustedScriptOrString text)
|
||||
WebIDL::ExceptionOr<void> HTMLScriptElement::set_text_content(TrustedTypes::NullableTrustedScriptOrString text)
|
||||
{
|
||||
// NOTE: We still require this from the base implementation.
|
||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||
// The textContent setter steps are to, if the given value is null, act as if it was the empty string instead, and then run set text content with this and the given value.
|
||||
TrustedTypes::TrustedScriptOrString non_null_text = text.has<Empty>()
|
||||
? ""_utf16
|
||||
: text.downcast<TrustedTypes::TrustedScriptOrString>();
|
||||
|
||||
// 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.
|
||||
// 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,
|
||||
non_null_text,
|
||||
TrustedTypes::InjectionSink::HTMLScriptElement_textContent,
|
||||
TrustedTypes::Script.to_string()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user