mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
LibWeb+IDLGenerators: Support nullable union types
This commit is contained in:
parent
500ca417ce
commit
cfd795f907
Notes:
github-actions[bot]
2026-03-25 13:21:41 +00:00
Author: https://github.com/Lubrsi
Commit: cfd795f907
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8534
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
39 changed files with 146 additions and 128 deletions
|
|
@ -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()));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue