Bug 1593954 - Port bug 1593051: Remove usage of parseXULToFragment from applicationManager.js. r=Paenglab
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Tue, 05 Nov 2019 15:47:02 +0200
changeset 37449 6b80c8cc614c8e8cd734ab86245dc3caee8a33b1
parent 37448 9c3fdd4aaf21a4ff8062a0f4dd3b56cfbbdb455a
child 37450 0563cab603a733479ab16c4f0455b01803b1b099
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewersPaenglab
bugs1593954, 1593051, 1484496
Bug 1593954 - Port bug 1593051: Remove usage of parseXULToFragment from applicationManager.js. r=Paenglab Some parts of bug 1484496 also adapted to align applicationManager.js with its M-C counterpart.
mail/components/preferences/applicationManager.js
--- a/mail/components/preferences/applicationManager.js
+++ b/mail/components/preferences/applicationManager.js
@@ -18,41 +18,38 @@ var gAppManagerDialog = {
         ? "handleFile"
         : "handleProtocol";
     var contentText = bundle.getFormattedString(key, [description]);
     contentText = bundle.getFormattedString("descriptionApplications", [
       contentText,
     ]);
     document.getElementById("appDescription").textContent = contentText;
 
-    var list = document.getElementById("appList");
-    var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
-    while (apps.hasMoreElements()) {
-      let app = apps.getNext();
+    let list = document.getElementById("appList");
+    let listFragment = document.createDocumentFragment();
+    for (let app of this.handlerInfo.possibleApplicationHandlers.enumerate()) {
       if (!gGeneralPane.isValidHandlerApp(app)) {
         continue;
       }
 
-      app.QueryInterface(Ci.nsIHandlerApp);
-
-      // Ensure the XBL binding is created eagerly.
-      // eslint-disable-next-line no-undef
-      list.appendChild(MozXULElement.parseXULToFragment("<richlistitem/>"));
-      let item = list.lastElementChild;
+      let item = document.createXULElement("richlistitem");
+      listFragment.append(item);
       item.app = app;
 
       let image = document.createXULElement("image");
       image.setAttribute("src", gGeneralPane._getIconURLForHandlerApp(app));
       item.appendChild(image);
 
       let label = document.createXULElement("label");
       label.setAttribute("value", app.name);
       item.appendChild(label);
     }
+    list.append(listFragment);
 
+    // Triggers onSelect which populates label.
     list.selectedIndex = 0;
   },
 
   onOK() {
     if (!this._removed.length) {
       // return early to avoid calling the |store| method.
       return;
     }