Skip to content

Commit d77ffd0

Browse files
mash-grazdomenic
andauthored
Implement customElements.getName()
Fixes #3640. Co-authored-by: Domenic Denicola <[email protected]>
1 parent ac385f9 commit d77ffd0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ class CustomElementRegistryImpl {
227227
return definition && definition.objectReference;
228228
}
229229

230+
// https://html.spec.whatwg.org/#dom-customelementregistry-getname
231+
getName(constructor) {
232+
const found = this._customElementDefinitions.find(entry => entry.objectReference === constructor.objectReference);
233+
return found ? found.name : null;
234+
}
235+
230236
// https://html.spec.whatwg.org/#dom-customelementregistry-whendefined
231237
whenDefined(name) {
232238
if (!isValidCustomElementName(name)) {

lib/jsdom/living/custom-elements/CustomElementRegistry.webidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
interface CustomElementRegistry {
33
[CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {});
44
any get(DOMString name);
5+
DOMString? getName(CustomElementConstructor constructor);
56
Promise<void> whenDefined(DOMString name);
67
[CEReactions] undefined upgrade(Node root);
78
};

test/web-platform-tests/to-run.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ webkit-pseudo-element.html: [fail, Unknown]
690690

691691
DIR: custom-elements
692692

693-
CustomElementRegistry-getName.html: [fail, Unknown]
694693
CustomElementRegistry.html:
695694
"customElements.define must get \"observedAttributes\" property on the constructor prototype when \"attributeChangedCallback\" is present": [fail, Unknown]
696695
"customElements.define must get four additional callbacks on the prototype if formAssociated is converted to true": [fail, formAssociated not fully implemented]

0 commit comments

Comments
 (0)