aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Cirkel <keithamus@users.noreply.github.com>2024-07-07 16:22:57 +0100
committerGitHub <noreply@github.com>2024-07-07 15:22:57 +0000
commitdb4cba4d6d0f1a26009967d17ffdf30157a81b5e (patch)
treea3ebca63653b0bef3b8b66af599b641610ff2d26
parent816359583c55ced698ed450d644d82a6d25213c9 (diff)
downloadservo-db4cba4d6d0f1a26009967d17ffdf30157a81b5e.tar.gz
servo-db4cba4d6d0f1a26009967d17ffdf30157a81b5e.zip
Add customElements.getName (#32715)
* Add customElements.getName * rebaseline
-rw-r--r--components/script/dom/customelementregistry.rs10
-rw-r--r--components/script/dom/webidls/CustomElementRegistry.webidl2
-rw-r--r--tests/wpt/meta-legacy-layout/html/dom/idlharness.https.html.ini3
-rw-r--r--tests/wpt/meta/custom-elements/CustomElementRegistry-getName.html.ini9
-rw-r--r--tests/wpt/meta/html/dom/idlharness.https.html.ini3
5 files changed, 12 insertions, 15 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index 44c99457073..d1dfa4754fe 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -561,6 +561,16 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
}
}
+ /// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-getname>
+ fn GetName(&self, constructor: Rc<CustomElementConstructor>) -> Option<DOMString> {
+ self.definitions
+ .borrow()
+ .0
+ .values()
+ .find(|definition| definition.constructor == constructor)
+ .map(|definition| DOMString::from(definition.name.to_string()))
+ }
+
/// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-whendefined>
#[allow(unsafe_code)]
fn WhenDefined(&self, name: DOMString, comp: InRealm) -> Rc<Promise> {
diff --git a/components/script/dom/webidls/CustomElementRegistry.webidl b/components/script/dom/webidls/CustomElementRegistry.webidl
index 8f9347296a9..be3d19b1cdd 100644
--- a/components/script/dom/webidls/CustomElementRegistry.webidl
+++ b/components/script/dom/webidls/CustomElementRegistry.webidl
@@ -14,6 +14,8 @@ interface CustomElementRegistry {
any get(DOMString name);
+ DOMString? getName(CustomElementConstructor constructor);
+
Promise<CustomElementConstructor> whenDefined(DOMString name);
[CEReactions] undefined upgrade(Node root);
diff --git a/tests/wpt/meta-legacy-layout/html/dom/idlharness.https.html.ini b/tests/wpt/meta-legacy-layout/html/dom/idlharness.https.html.ini
index 42842a8ddc9..6cff25386a5 100644
--- a/tests/wpt/meta-legacy-layout/html/dom/idlharness.https.html.ini
+++ b/tests/wpt/meta-legacy-layout/html/dom/idlharness.https.html.ini
@@ -1610,9 +1610,6 @@
[VisibilityStateEntry interface: attribute duration]
expected: FAIL
- [CustomElementRegistry interface: operation getName(CustomElementConstructor)]
- expected: FAIL
-
[Navigation interface: existence and properties of interface object]
expected: FAIL
diff --git a/tests/wpt/meta/custom-elements/CustomElementRegistry-getName.html.ini b/tests/wpt/meta/custom-elements/CustomElementRegistry-getName.html.ini
deleted file mode 100644
index cb43c25dc3a..00000000000
--- a/tests/wpt/meta/custom-elements/CustomElementRegistry-getName.html.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[CustomElementRegistry-getName.html]
- [customElements.getName must return null when the registry does not contain an entry with the given constructor]
- expected: FAIL
-
- [customElements.getName returns the name of the entry with the given constructor when there is a matching entry.]
- expected: FAIL
-
- [customElements.getName returns the name of the entry with the given customized built in constructor when there is a matching entry.]
- expected: FAIL
diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini
index ddfd998c546..f4c3673aaab 100644
--- a/tests/wpt/meta/html/dom/idlharness.https.html.ini
+++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini
@@ -1490,9 +1490,6 @@
[ImageBitmap interface: attribute height]
expected: FAIL
- [CustomElementRegistry interface: operation getName(CustomElementConstructor)]
- expected: FAIL
-
[Navigation interface: existence and properties of interface object]
expected: FAIL