зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1829335 - Add customElements.getName. r=smaug
This adds the new customElements.getName method which takes a constructor and returns string if the definition has been registered, otherwise null. Differential Revision: https://phabricator.services.mozilla.com/D181646
This commit is contained in:
Родитель
d011b4ba61
Коммит
b2af7cafb3
|
@ -1195,6 +1195,19 @@ void CustomElementRegistry::Get(
|
|||
aRetVal.SetAsCustomElementConstructor() = data->mConstructor;
|
||||
}
|
||||
|
||||
void CustomElementRegistry::GetName(JSContext* aCx,
|
||||
CustomElementConstructor& aConstructor,
|
||||
nsAString& aResult) {
|
||||
CustomElementDefinition* aDefinition =
|
||||
LookupCustomElementDefinition(aCx, aConstructor.CallableOrNull());
|
||||
|
||||
if (aDefinition) {
|
||||
aDefinition->mType->ToString(aResult);
|
||||
} else {
|
||||
aResult.SetIsVoid(true);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CustomElementRegistry::WhenDefined(
|
||||
const nsAString& aName, ErrorResult& aRv) {
|
||||
// Define a function that lazily creates a Promise and perform some action on
|
||||
|
|
|
@ -557,6 +557,9 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
|
|||
void Get(const nsAString& name,
|
||||
OwningCustomElementConstructorOrUndefined& aRetVal);
|
||||
|
||||
void GetName(JSContext* aCx, CustomElementConstructor& aConstructor,
|
||||
nsAString& aResult);
|
||||
|
||||
already_AddRefed<Promise> WhenDefined(const nsAString& aName,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ DOMInterfaces = {
|
|||
},
|
||||
|
||||
'CustomElementRegistry': {
|
||||
'implicitJSContext': ['define'],
|
||||
'implicitJSContext': ['define', 'getName'],
|
||||
},
|
||||
|
||||
'DebuggerNotification': {
|
||||
|
|
|
@ -11,6 +11,7 @@ interface CustomElementRegistry {
|
|||
[ChromeOnly, Throws]
|
||||
undefined setElementCreationCallback(DOMString name, CustomElementCreationCallback callback);
|
||||
(CustomElementConstructor or undefined) get(DOMString name);
|
||||
DOMString? getName(CustomElementConstructor constructor);
|
||||
[Throws]
|
||||
Promise<CustomElementConstructor> whenDefined(DOMString name);
|
||||
[CEReactions] undefined upgrade(Node root);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
[CustomElementRegistry.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
|
Загрузка…
Ссылка в новой задаче