Bug 1323600 - Some fields have been converted to properties and won't reset anymore when the binding is recreated. r=mossop a=jcristau
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 15 Dec 2016 00:58:21 +0100
changeset 353050 7a9e103be35066bd7c06e770a73b7401ce1e2620
parent 353049 2c7ec3a0c9643f03d81c353a21ad3ee3c72392fa
child 353051 4d428919f82ffdab4943ffe7055f739423e0793b
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, jcristau
bugs1323600
milestone52.0a2
Bug 1323600 - Some fields have been converted to properties and won't reset anymore when the binding is recreated. r=mossop a=jcristau MozReview-Commit-ID: CHxBFpbW6aS
toolkit/content/widgets/autocomplete.xml
toolkit/content/widgets/tabbox.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -64,41 +64,41 @@
       ]]></constructor>
 
       <destructor><![CDATA[
         this.inputField.controllers.removeController(this._pasteController);
       ]]></destructor>
 
       <!-- =================== nsIAutoCompleteInput =================== -->
 
+      <field name="_popup">null</field>
       <property name="popup" readonly="true">
         <getter><![CDATA[
+          // Memoize the result in a field rather than replacing this property,
+          // so that it can be reset along with the binding.
+          if (this._popup) {
+            return this._popup;
+          }
+
           let popup = null;
           let popupId = this.getAttribute("autocompletepopup");
           if (popupId) {
             popup = document.getElementById(popupId);
           }
           if (!popup) {
             popup = document.createElement("panel");
             popup.setAttribute("type", "autocomplete");
             popup.setAttribute("noautofocus", "true");
 
             let popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
             popupset.appendChild(popup);
           }
           popup.mInput = this;
 
-          // Avoid having to recalculate the popup property each time
-          Object.defineProperty(this, "popup", {
-            configurable: true,
-            enumerable: true,
-            writable: true,
-            value: popup
-          });
-          return popup;
+          return this._popup = popup;
         ]]></getter>
       </property>
 
       <property name="controller" onget="return this.mController;" readonly="true"/>
 
       <property name="popupOpen"
                 onget="return this.popup.popupOpen;"
                 onset="if (val) this.openPopup(); else this.closePopup();"/>
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -344,34 +344,34 @@
                 break;
               }
             }
             return val;
           ]]>
         </setter>
       </property>
 
+      <field name="_tabbox">null</field>
       <property name="tabbox" readonly="true">
         <getter><![CDATA[
+          // Memoize the result in a field rather than replacing this property,
+          // so that it can be reset along with the binding.
+          if (this._tabbox) {
+            return this._tabbox;
+          }
+
           let parent = this.parentNode;
           while (parent) {
             if (parent.localName == "tabbox") {
               break;
             }
             parent = parent.parentNode;
           }
 
-          // Avoid having to recalculate the tabbox property each time
-          Object.defineProperty(this, "tabbox", {
-            configurable: true,
-            enumerable: true,
-            writable: true,
-            value: parent
-          });
-          return parent;
+          return this._tabbox = parent;
         ]]></getter>
       </property>
 
       <!-- _tabbox is deprecated, it exists only for backwards compatibility. -->
       <field name="_tabbox" readonly="true"><![CDATA[
         this.tabbox;
       ]]></field>
 
@@ -639,34 +639,34 @@
           }
 
           return tabElmFromIndex;
         ]]>
         </body>
       </method>
 
       <!-- public -->
+      <field name="_tabbox">null</field>
       <property name="tabbox" readonly="true">
         <getter><![CDATA[
+          // Memoize the result in a field rather than replacing this property,
+          // so that it can be reset along with the binding.
+          if (this._tabbox) {
+            return this._tabbox;
+          }
+
           let parent = this.parentNode;
           while (parent) {
             if (parent.localName == "tabbox") {
               break;
             }
             parent = parent.parentNode;
           }
 
-          // Avoid having to recalculate the tabbox property each time
-          Object.defineProperty(this, "tabbox", {
-            configurable: true,
-            enumerable: true,
-            writable: true,
-            value: parent
-          });
-          return parent;
+          return this._tabbox = parent;
         ]]></getter>
       </property>
 
       <field name="_selectedPanel">this.childNodes.item(this.selectedIndex)</field>
 
       <property name="selectedIndex">
         <getter>
         <![CDATA[