LibWeb+IDLGenerators: Support nullable union types

This commit is contained in:
Luke Wilde 2026-02-17 14:57:03 +00:00 committed by Sam Atkins
parent 500ca417ce
commit cfd795f907
Notes: github-actions[bot] 2026-03-25 13:21:41 +00:00
39 changed files with 146 additions and 128 deletions

View file

@ -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, thiss 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()));