Bug 1595050 - Update spec comment in CustomElementRegistry::Define to reflect the latest spec; r=smaug
authorEdgar Chen <echen@mozilla.com>
Fri, 08 Nov 2019 13:18:53 +0000
changeset 501704 c9769928194867af402830fae75ce4290289f9c1
parent 501703 c73a5bc0e22516c832a374fd0ebf9d6dec3c7886
child 501705 2f19e7b646e0a52fa855b75c868f0a3f3a990ad3
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1595050
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1595050 - Update spec comment in CustomElementRegistry::Define to reflect the latest spec; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D52348
dom/base/CustomElementRegistry.cpp
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -692,17 +692,17 @@ bool CustomElementRegistry::JSObjectToAt
         return false;
       }
     }
   }
 
   return true;
 }
 
-// https://html.spec.whatwg.org/multipage/scripting.html#element-definition
+// https://html.spec.whatwg.org/commit-snapshots/b48bb2238269d90ea4f455a52cdf29505aff3df0/#dom-customelementregistry-define
 void CustomElementRegistry::Define(
     JSContext* aCx, const nsAString& aName,
     CustomElementConstructor& aFunctionConstructor,
     const ElementDefinitionOptions& aOptions, ErrorResult& aRv) {
   JS::Rooted<JSObject*> constructor(aCx, aFunctionConstructor.CallableOrNull());
 
   // We need to do a dynamic unwrap in order to throw the right exception.  We
   // could probably avoid that if we just threw MSG_NOT_CONSTRUCTOR if unwrap
@@ -848,59 +848,58 @@ void CustomElementRegistry::Define(
   bool disableShadow = false;
   {  // Set mIsCustomDefinitionRunning.
     /**
      * 9. Set this CustomElementRegistry's element definition is running flag.
      */
     AutoSetRunningFlag as(this);
 
     /**
-     * 10.1. Let prototype be Get(constructor, "prototype"). Rethrow any
+     * 14.1. Let prototype be Get(constructor, "prototype"). Rethrow any
      * exceptions.
      */
     // The .prototype on the constructor passed could be an "expando" of a
     // wrapper. So we should get it from wrapper instead of the underlying
     // object.
     JS::Rooted<JS::Value> prototype(aCx);
     if (!JS_GetProperty(aCx, constructor, "prototype", &prototype)) {
       aRv.NoteJSContextException(aCx);
       return;
     }
 
     /**
-     * 10.2. If Type(prototype) is not Object, then throw a TypeError exception.
+     * 14.2. If Type(prototype) is not Object, then throw a TypeError exception.
      */
     if (!prototype.isObject()) {
       aRv.ThrowTypeError<MSG_NOT_OBJECT>(
           NS_LITERAL_STRING("constructor.prototype"));
       return;
     }
 
     /**
-     * 10.3. Let lifecycleCallbacks be a map with the four keys
+     * 14.3. Let lifecycleCallbacks be a map with the four keys
      *       "connectedCallback", "disconnectedCallback", "adoptedCallback", and
      *       "attributeChangedCallback", each of which belongs to an entry whose
      *       value is null. The 'getCustomInterface' callback is also included
      *       for chrome usage.
-     * 10.4. For each of the four keys callbackName in lifecycleCallbacks:
+     * 14.4. For each of the four keys callbackName in lifecycleCallbacks:
      *       1. Let callbackValue be Get(prototype, callbackName). Rethrow any
      *          exceptions.
      *       2. If callbackValue is not undefined, then set the value of the
      *          entry in lifecycleCallbacks with key callbackName to the result
      *          of converting callbackValue to the Web IDL Function callback
      * type. Rethrow any exceptions from the conversion.
      */
     if (!callbacksHolder->Init(aCx, prototype)) {
       aRv.NoteJSContextException(aCx);
       return;
     }
 
     /**
-     * 10.5. Let observedAttributes be an empty sequence<DOMString>.
-     * 10.6. If the value of the entry in lifecycleCallbacks with key
+     * 14.5. If the value of the entry in lifecycleCallbacks with key
      *       "attributeChangedCallback" is not null, then:
      *       1. Let observedAttributesIterable be Get(constructor,
      *          "observedAttributes"). Rethrow any exceptions.
      *       2. If observedAttributesIterable is not undefined, then set
      *          observedAttributes to the result of converting
      *          observedAttributesIterable to a sequence<DOMString>. Rethrow
      *          any exceptions from the conversion.
      */
@@ -934,26 +933,26 @@ void CustomElementRegistry::Define(
       // 14.10. Set disableShadow to true if disabledFeaturesSequence contains
       //        "shadow".
       disableShadow = disabledFeatures.Contains(
           static_cast<nsStaticAtom*>(nsGkAtoms::shadow));
     }
   }  // Unset mIsCustomDefinitionRunning
 
   /**
-   * 11. Let definition be a new custom element definition with name name,
+   * 15. Let definition be a new custom element definition with name name,
    *     local name localName, constructor constructor, prototype prototype,
    *     observed attributes observedAttributes, and lifecycle callbacks
    *     lifecycleCallbacks.
    */
   // Associate the definition with the custom element.
   RefPtr<nsAtom> localNameAtom(NS_Atomize(localName));
 
   /**
-   * 12. Add definition to this CustomElementRegistry.
+   * 16. Add definition to this CustomElementRegistry.
    */
   if (!mConstructors.put(constructorUnwrapped, nameAtom)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   RefPtr<CustomElementDefinition> definition = new CustomElementDefinition(
       nameAtom, localNameAtom, nameSpaceID, &aFunctionConstructor,
@@ -962,22 +961,22 @@ void CustomElementRegistry::Define(
 
   CustomElementDefinition* def = definition.get();
   mCustomDefinitions.Put(nameAtom, definition.forget());
 
   MOZ_ASSERT(mCustomDefinitions.Count() == mConstructors.count(),
              "Number of entries should be the same");
 
   /**
-   * 13. 14. 15. Upgrade candidates
+   * 17. 18. 19. Upgrade candidates
    */
   UpgradeCandidates(nameAtom, def, aRv);
 
   /**
-   * 16. If this CustomElementRegistry's when-defined promise map contains an
+   * 20. If this CustomElementRegistry's when-defined promise map contains an
    *     entry with key name:
    *     1. Let promise be the value of that entry.
    *     2. Resolve promise with undefined.
    *     3. Delete the entry with key name from this CustomElementRegistry's
    *        when-defined promise map.
    */
   RefPtr<Promise> promise;
   mWhenDefinedPromiseMap.Remove(nameAtom, getter_AddRefs(promise));