Bug 1466833 - Upgrade the <xul:deck> inside of search-one-offs at the beginning of the XBL constructor;r=timdream draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 21 Jun 2018 17:31:41 -0700
changeset 809442 1287445f2740dfe6a3ed5bdf273bb2b4b91b213c
parent 809377 27e90ec610a4c8f6b2a73d79cb1a4df38e822e6a
push id113678
push userbgrinstead@mozilla.com
push dateFri, 22 Jun 2018 03:58:05 +0000
reviewerstimdream
bugs1466833, 1470242
milestone62.0a1
Bug 1466833 - Upgrade the <xul:deck> inside of search-one-offs at the beginning of the XBL constructor;r=timdream Right now, a XBL <constructor> runs before Custom Elements inside of its <content> get upgraded. This leads to unexpected behavior where deck.selectedIndex = N causes selectedIndex to get set as an expando property on the DOM node rather than running the setter defined by the Custom Element. Once the Custom Element does finally get upgraded, the selectedIndex getter and setter don't get attached since there's an expando property with the same name. This isn't a case we want to have to support from calling code. So this patch fixes this one case by manually upgrading the element inside the constructor before anything accesses the node. In Bug 1470242 we are planning to make this happen behind the scenes so we don't need to do this for every CE inside of <content>. MozReview-Commit-ID: 3D0QbOOJvDI
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1286,16 +1286,20 @@
         ]]></getter>
       </property>
 
       <!-- When a context menu is opened on a one-off button, this is set to the
            engine of that button for use with the context menu actions. -->
       <field name="_contextEngine">null</field>
 
       <constructor><![CDATA[
+        // Force the <deck> Custom Element to be constructed. This can be removed
+        // once Bug 1470242 makes this happen behind the scenes.
+        customElements.upgrade(this.header);
+
         // Prevent popup events from the context menu from reaching the autocomplete
         // binding (or other listeners).
         let menu = document.getAnonymousElementByAttribute(this, "anonid", "search-one-offs-context-menu");
         let listener = aEvent => aEvent.stopPropagation();
         menu.addEventListener("popupshowing", listener);
         menu.addEventListener("popuphiding", listener);
         menu.addEventListener("popupshown", aEvent => {
           this._ignoreMouseEvents = true;