Commit 9076b5fa authored by Nicolas Chevobbe's avatar Nicolas Chevobbe
Browse files

Bug 1765748 - [devtools] Remove unncessary complex SplitView#setItemClassName. r=jdescottes.

The function was setting extra classes on both
the summary and the detail, running extra checks
to not remove the base classes.
It's only called from one place, and we only care
about adding classes to the summary element, which
we have access to directly.
We're switching to classList.(add|remove) , which
allows us to get rid of the SplitView method.

Differential Revision: https://phabricator.services.mozilla.com/D144427
parent 8578d222
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -208,27 +208,4 @@ class SplitView {
      this.removeItem(this._nav.firstChild);
    }
  }

  /**
   * Set the item's CSS class name.
   * This sets the class on both the summary and details elements, retaining
   * any SplitView-specific classes.
   *
   * @param DOMElement summary
   *        Summary element of the item to set.
   * @param string className
   *        One or more space-separated CSS classes.
   */
  setItemClassName(summary, className) {
    const binding = bindings.get(summary);
    let viewSpecific;

    viewSpecific = summary.className.match(/(splitview\-[\w-]+)/g);
    viewSpecific = viewSpecific ? viewSpecific.join(" ") : "";
    summary.className = viewSpecific + " " + className;

    viewSpecific = binding._details.className.match(/(splitview\-[\w-]+)/g);
    viewSpecific = viewSpecific ? viewSpecific.join(" ") : "";
    binding._details.className = viewSpecific + " " + className;
  }
}
+3 −11
Original line number Diff line number Diff line
@@ -934,17 +934,9 @@ StyleEditorUI.prototype = {
      ruleCount = "-";
    }

    const flags = [];
    if (editor.styleSheet.disabled) {
      flags.push("disabled");
    }
    if (editor.unsaved) {
      flags.push("unsaved");
    }
    if (editor.linkedCSSFileError) {
      flags.push("linked-file-error");
    }
    this._view.setItemClassName(summary, flags.join(" "));
    summary.classList.toggle("disabled", !!editor.styleSheet.disabled);
    summary.classList.toggle("unsaved", !!editor.unsaved);
    summary.classList.toggle("linked-file-error", !!editor.linkedCSSFileError);

    const label = summary.querySelector(".stylesheet-name > label");
    label.setAttribute("value", editor.friendlyName);