mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
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
This commit is contained in:
parent
8578d2224f
commit
9076b5fa2f
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user