Bug 1497599 - Only run re-initialize moz-input-box during attributeChangedCallback if the attribute actually changed;r=paolo
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 10 Oct 2018 17:12:01 +0000
changeset 488941 8f52497c3d96f9f193a82ab2e715230ea77528db
parent 488940 8ca368cb3bbfdc279c11fc706ee4b799208b33a7
child 488942 b2afdca1a42f8f1014e88a009cbaf7ca39d09711
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewerspaolo
bugs1497599
milestone64.0a1
Bug 1497599 - Only run re-initialize moz-input-box during attributeChangedCallback if the attribute actually changed;r=paolo This is unrelated to the other changesets in the bug, just a cleanup based on patterns that have emerged in other attributeChangedCallbacks like in progressmeter Differential Revision: https://phabricator.services.mozilla.com/D8174
toolkit/content/widgets/textbox.js
--- a/toolkit/content/widgets/textbox.js
+++ b/toolkit/content/widgets/textbox.js
@@ -56,28 +56,27 @@ const cachedFragments = {
 };
 
 class MozInputBox extends MozXULElement {
   static get observedAttributes() {
     return ["spellcheck"];
   }
 
   attributeChangedCallback(name, oldValue, newValue) {
-    if (name === "spellcheck") {
-      this.spellcheck = newValue;
+    if (name === "spellcheck" && oldValue != newValue) {
       this._initUI();
     }
   }
 
   connectedCallback() {
-    this.spellcheck = this.hasAttribute("spellcheck");
     this._initUI();
   }
 
   _initUI() {
+    this.spellcheck = this.hasAttribute("spellcheck");
     if (this.menupopup) {
       this.menupopup.remove();
     }
 
     this.setAttribute("context", "_child");
     this.appendChild(this.spellcheck ? cachedFragments.spellcheck.cloneNode(true) :
                                        cachedFragments.normal.cloneNode(true));
     this.menupopup = this.querySelector(".textbox-contextmenu");