Skip to content

Commit

Permalink
Make customElements.whenDefined() resolve with the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Mar 27, 2021
1 parent c5d13bb commit b36d418
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 759 deletions.
Expand Up @@ -208,7 +208,7 @@ class CustomElementRegistryImpl {
}

if (this._whenDefinedPromiseMap[name] !== undefined) {
this._whenDefinedPromiseMap[name].resolve(undefined);
this._whenDefinedPromiseMap[name].resolve(ctor);
delete this._whenDefinedPromiseMap[name];
}
}
Expand All @@ -228,9 +228,9 @@ class CustomElementRegistryImpl {
));
}

const alreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
const alreadyRegistered = this._customElementDefinitions.find(entry => entry.name === name);
if (alreadyRegistered) {
return Promise.resolve();
return Promise.resolve(alreadyRegistered.objectReference);
}

if (this._whenDefinedPromiseMap[name] === undefined) {
Expand Down
9 changes: 8 additions & 1 deletion test/web-platform-tests/to-run.yaml
Expand Up @@ -110,7 +110,14 @@ window-screen-width.html: [fail, Test not applicable - no output device]

DIR: custom-elements

CustomElementRegistry.html: [fail, webidl2js doesn't deal well with tests using Proxies to verify properties access]
CustomElementRegistry.html:
'customElements.define must get "prototype", "disabledFeatures", and "formAssociated" property of the constructor': [fail, formAssociated not implemented]
'customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present': [fail, formAssociated not implemented]
'customElements.define must rethrow an exception thrown while getting formAssociated on the constructor prototype': [fail, formAssociated not implemented]
'customElements.define must get four additional callbacks on the prototype if formAssociated is converted to true': [fail, formAssociated not implemented]
'customElements.define must rethrow an exception thrown while getting additional formAssociated callbacks on the constructor prototype': [fail, formAssociated not implemented]
'customElements.whenDefined must return a promise for a valid custom element name': [fail, Unknown]
'customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype")': [fail, Not supported]
Document-createElement.html: [fail, :defined is not defined and throws]
HTMLElement-attachInternals.html: [fail, Not implemented]
HTMLElement-constructor.html: [fail, webidl2js doesn't deal well with tests using Proxies to verify properties access]
Expand Down

0 comments on commit b36d418

Please sign in to comment.