aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorJason Tsai <git@pews.dev>2025-06-07 16:00:02 +0900
committerGitHub <noreply@github.com>2025-06-07 07:00:02 +0000
commit47f9fbd8c70a017237634d9942ee3ed9a8cd15c5 (patch)
tree8bf86c51f3d88fa726933aa11448eff90b475e7d /components
parent352e4bfcf1ac90c6aeecd42c1ef1e9ca832b2013 (diff)
downloadservo-47f9fbd8c70a017237634d9942ee3ed9a8cd15c5.tar.gz
servo-47f9fbd8c70a017237634d9942ee3ed9a8cd15c5.zip
feat(script): add `Supports()` to `htmlscriptelement` (#37313)
Add static method `Supports` to `HTMLScriptElement`. Part of #37262 Testing: relative WPT tests should become `PASS` Signed-off-by: Jason Tsai <git@pews.dev>
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/htmlscriptelement.rs8
-rw-r--r--components/script_bindings/webidls/HTMLScriptElement.webidl2
2 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 421ff11d189..b3005b181da 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -70,6 +70,7 @@ use crate::dom::performanceresourcetiming::InitiatorType;
use crate::dom::trustedscript::TrustedScript;
use crate::dom::trustedscripturl::TrustedScriptURL;
use crate::dom::virtualmethods::VirtualMethods;
+use crate::dom::window::Window;
use crate::fetch::create_a_potential_cors_request;
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
use crate::realms::enter_realm;
@@ -1526,6 +1527,13 @@ impl HTMLScriptElementMethods<crate::DomTypeHolder> for HTMLScriptElement {
.SetTextContent(Some(DOMString::from(value)), can_gc);
Ok(())
}
+
+ /// <https://html.spec.whatwg.org/multipage/#dom-script-supports>
+ fn Supports(_window: &Window, type_: DOMString) -> bool {
+ // The type argument has to exactly match these values,
+ // we do not perform an ASCII case-insensitive match.
+ matches!(type_.str(), "classic" | "module" | "importmap")
+ }
}
#[derive(Clone, Copy)]
diff --git a/components/script_bindings/webidls/HTMLScriptElement.webidl b/components/script_bindings/webidls/HTMLScriptElement.webidl
index 2c7b398b7e3..a21ae6007c4 100644
--- a/components/script_bindings/webidls/HTMLScriptElement.webidl
+++ b/components/script_bindings/webidls/HTMLScriptElement.webidl
@@ -32,6 +32,8 @@ interface HTMLScriptElement : HTMLElement {
[CEReactions]
attribute DOMString referrerPolicy;
+ static boolean supports(DOMString type);
+
// also has obsolete members
};