commit b4c5b7eb301672683481d4e35a5322ab7316129f
parent 91a14bd0378b66562bc5597690dc21b024075cdd
Author: Nicolas Chevobbe <nchevobbe@mozilla.com>
Date: Fri, 3 Oct 2025 07:56:42 +0000
Bug 1991683 - [devtools] Remove all children of element with replaceChildren in RuleEditor. r=devtools-reviewers,ochameau,bomsy.
We used to remove the elements one by one using a while loop, this looks better.
Differential Revision: https://phabricator.services.mozilla.com/D266824
Diffstat:
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/devtools/client/inspector/rules/views/rule-editor.js b/devtools/client/inspector/rules/views/rule-editor.js
@@ -632,9 +632,7 @@ RuleEditor.prototype = {
*/
populate(reset) {
// Clear out existing viewers.
- while (this.selectorText.hasChildNodes()) {
- this.selectorText.removeChild(this.selectorText.lastChild);
- }
+ this.selectorText.replaceChildren();
// If selector text comes from a css rule, highlight selectors that
// actually match. For custom selector text (such as for the 'element'
@@ -661,9 +659,7 @@ RuleEditor.prototype = {
focusedElSelector = CssLogic.findCssSelector(this.doc.activeElement);
}
- while (this.propertyList.hasChildNodes()) {
- this.propertyList.removeChild(this.propertyList.lastChild);
- }
+ this.propertyList.replaceChildren();
}
for (const prop of this.rule.textProps) {