Bug 1427954 - Don't pass child elements into the constructor. r=sfoster
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 14 Mar 2018 18:12:58 -0700
changeset 408634 89a5d0d89c0595fc31ad4ec6edf6e82ba70b60a7
parent 408633 e4c41608a13eeb493af0ba7e73fedf6abf2bc366
child 408635 2f8bd1f13394a18448db08a7b62bf6c8afaabf99
push id100996
push userbtara@mozilla.com
push dateSat, 17 Mar 2018 10:37:43 +0000
treeherdermozilla-inbound@97160a734959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1427954
milestone61.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 1427954 - Don't pass child elements into the constructor. r=sfoster MozReview-Commit-ID: 2iqHks0yD0v
browser/extensions/formautofill/content/editAddress.xhtml
browser/extensions/formautofill/content/editCreditCard.xhtml
browser/extensions/formautofill/content/editDialog.js
--- a/browser/extensions/formautofill/content/editAddress.xhtml
+++ b/browser/extensions/formautofill/content/editAddress.xhtml
@@ -73,18 +73,15 @@
     <button id="save" disabled="disabled" data-localization="saveBtnLabel"/>
   </div>
   <script type="application/javascript"><![CDATA[
     "use strict";
     /* global EditAddress */
     new EditAddress({
       title: document.querySelector("title"),
       form: document.getElementById("form"),
-      addressLevel1Label: document.querySelector("#address-level1-container > span"),
-      postalCodeLabel: document.querySelector("#postal-code-container > span"),
-      country: document.getElementById("country"),
       controlsContainer: document.getElementById("controls-container"),
       cancel: document.getElementById("cancel"),
       save: document.getElementById("save"),
     }, window.arguments && window.arguments[0]);
   ]]></script>
 </body>
 </html>
--- a/browser/extensions/formautofill/content/editCreditCard.xhtml
+++ b/browser/extensions/formautofill/content/editCreditCard.xhtml
@@ -51,17 +51,15 @@
     <button id="save" disabled="disabled" data-localization="saveBtnLabel"/>
   </div>
   <script type="application/javascript"><![CDATA[
     "use strict";
     /* global EditCreditCard */
     new EditCreditCard({
       title: document.querySelector("title"),
       form: document.getElementById("form"),
-      ccNumber: document.getElementById("cc-number"),
-      year: document.getElementById("cc-exp-year"),
       controlsContainer: document.getElementById("controls-container"),
       cancel: document.getElementById("cancel"),
       save: document.getElementById("save"),
     }, window.arguments && window.arguments[0]);
   ]]></script>
 </body>
 </html>
--- a/browser/extensions/formautofill/content/editDialog.js
+++ b/browser/extensions/formautofill/content/editDialog.js
@@ -202,16 +202,22 @@ class EditDialog {
 }
 
 class EditAddress extends EditDialog {
   constructor(elements, record) {
     let country = record ? record.country :
                   FormAutofillUtils.supportedCountries.find(supported => supported == FormAutofillUtils.DEFAULT_REGION);
     super("addresses", elements, record || {country});
 
+    Object.assign(this._elements, {
+      addressLevel1Label: this._elements.form.querySelector("#address-level1-container > span"),
+      postalCodeLabel: this._elements.form.querySelector("#postal-code-container > span"),
+      country: this._elements.form.querySelector("#country"),
+    });
+
     this.formatForm(country);
   }
 
   /**
    * Format the form based on country. The address-level1 and postal-code labels
    * should be specific to the given country.
    * @param  {string} country
    */
@@ -287,16 +293,20 @@ class EditAddress extends EditDialog {
     this._elements.country.removeEventListener("change", this);
     super.detachEventListeners();
   }
 }
 
 class EditCreditCard extends EditDialog {
   constructor(elements, record) {
     super("creditCards", elements, record);
+    Object.assign(this._elements, {
+      ccNumber: this._elements.form.querySelector("#cc-number"),
+      year: this._elements.form.querySelector("#cc-exp-year"),
+    });
     this.generateYears();
   }
 
   generateYears() {
     const count = 11;
     const currentYear = new Date().getFullYear();
     const ccExpYear = this._record && this._record["cc-exp-year"];