mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Add innerText attribute of HTMLScriptElement for TrustedTypes
This commit is contained in:
parent
6b9c44390f
commit
f7c05013c7
Notes:
github-actions[bot]
2025-09-16 08:58:42 +00:00
Author: https://github.com/tete17
Commit: f7c05013c7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6058
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
5 changed files with 34 additions and 1 deletions
|
|
@ -219,6 +219,8 @@ protected:
|
|||
void set_inert(bool inert) { m_inert = inert; }
|
||||
void set_subtree_inertness(bool is_inert);
|
||||
|
||||
[[nodiscard]] Utf16String get_the_text_steps();
|
||||
|
||||
private:
|
||||
virtual bool is_html_element() const final { return true; }
|
||||
|
||||
|
|
@ -229,7 +231,6 @@ private:
|
|||
virtual void did_receive_focus() override;
|
||||
virtual void did_lose_focus() override;
|
||||
|
||||
[[nodiscard]] Utf16String get_the_text_steps();
|
||||
GC::Ref<DOM::DocumentFragment> rendered_text_fragment(Utf16View const& input);
|
||||
|
||||
GC::Ptr<DOM::NodeList> m_labels;
|
||||
|
|
|
|||
|
|
@ -705,6 +705,33 @@ WebIDL::ExceptionOr<void> HTMLScriptElement::set_text_content(TrustedTypes::Trus
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#the-innerText-idl-attribute
|
||||
TrustedTypes::TrustedScriptOrString HTMLScriptElement::inner_text()
|
||||
{
|
||||
// 1. Return the result of running get text content with this.
|
||||
return get_the_text_steps();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#the-innerText-idl-attribute
|
||||
WebIDL::ExceptionOr<void> HTMLScriptElement::set_inner_text(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 innerText, and script.
|
||||
auto const value = TRY(TrustedTypes::get_trusted_type_compliant_string(
|
||||
TrustedTypes::TrustedTypeName::TrustedScript,
|
||||
HTML::relevant_global_object(*this),
|
||||
text,
|
||||
TrustedTypes::InjectionSink::HTMLScriptElementinnerText,
|
||||
TrustedTypes::Script.to_string()));
|
||||
|
||||
// 2. Set this’s script text value to value.
|
||||
m_script_text = value;
|
||||
|
||||
// 3. Run set the inner text steps with this and value.
|
||||
HTMLElement::set_inner_text(value);
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-async
|
||||
bool HTMLScriptElement::async() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ public:
|
|||
Variant<GC::Root<TrustedTypes::TrustedScript>, Utf16String, Empty> text_content() const;
|
||||
WebIDL::ExceptionOr<void> set_text_content(TrustedTypes::TrustedScriptOrString);
|
||||
|
||||
TrustedTypes::TrustedScriptOrString inner_text();
|
||||
WebIDL::ExceptionOr<void> set_inner_text(TrustedTypes::TrustedScriptOrString);
|
||||
|
||||
[[nodiscard]] bool async() const;
|
||||
void set_async(bool);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ interface HTMLScriptElement : HTMLElement {
|
|||
[CEReactions] attribute (TrustedScript or Utf16DOMString) text;
|
||||
[CEReactions] attribute (TrustedScriptURL or Utf16USVString) src;
|
||||
[CEReactions] attribute (TrustedScript or Utf16DOMString)? textContent;
|
||||
[CEReactions] attribute (TrustedScript or Utf16DOMString) innerText;
|
||||
|
||||
static boolean supports(DOMString type);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue