commit d19af0f64f5a734b92608a18544a17fb00af13fa
parent e2d9d33fcdf713a919dab02dd82c4cd56d2d6ed7
Author: Lorenz A <me@lorenzackermann.xyz>
Date: Wed, 17 Dec 2025 17:10:06 +0000
Bug 2004251 - [devtools] Remove unused class Item from devtools/client/shared/widgets/view-helpers.js. r=devtools-reviewers,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D276859
Diffstat:
1 file changed, 0 insertions(+), 154 deletions(-)
diff --git a/devtools/client/shared/widgets/view-helpers.js b/devtools/client/shared/widgets/view-helpers.js
@@ -276,157 +276,3 @@ exports.ViewHelpers = {
}
},
};
-
-/**
- * A generic Item is used to describe children present in a Widget.
- *
- * This is basically a very thin wrapper around a Node, with a few
- * characteristics, like a `value` and an `attachment`.
- *
- * The characteristics are optional, and their meaning is entirely up to you.
- * - The `value` should be a string, passed as an argument.
- * - The `attachment` is any kind of primitive or object, passed as an argument.
- *
- * Iterable via "for (let childItem of parentItem) { }".
- *
- * @param object ownerView
- * The owner view creating this item.
- * @param Node element
- * A prebuilt node to be wrapped.
- * @param string value
- * A string identifying the node.
- * @param any attachment
- * Some attached primitive/object.
- */
-function Item(ownerView, element, value, attachment) {
- this.ownerView = ownerView;
- this.attachment = attachment;
- this._value = value + "";
- this._prebuiltNode = element;
- this._itemsByElement = new Map();
-}
-
-Item.prototype = {
- get value() {
- return this._value;
- },
- get target() {
- return this._target;
- },
- get prebuiltNode() {
- return this._prebuiltNode;
- },
-
- /**
- * Immediately appends a child item to this item.
- *
- * @param Node element
- * A Node representing the child element to append.
- * @param object options [optional]
- * Additional options or flags supported by this operation:
- * - attachment: some attached primitive/object for the item
- * - attributes: a batch of attributes set to the displayed element
- * - finalize: function invoked when the child item is removed
- * @return Item
- * The item associated with the displayed element.
- */
- append(element, options = {}) {
- const item = new Item(this, element, "", options.attachment);
-
- // Entangle the item with the newly inserted child node.
- // Make sure this is done with the value returned by appendChild(),
- // to avoid storing a potential DocumentFragment.
- this._entangleItem(item, this._target.appendChild(element));
-
- // Handle any additional options after entangling the item.
- if (options.attributes) {
- options.attributes.forEach(e => item._target.setAttribute(e[0], e[1]));
- }
- if (options.finalize) {
- item.finalize = options.finalize;
- }
-
- // Return the item associated with the displayed element.
- return item;
- },
-
- /**
- * Immediately removes the specified child item from this item.
- *
- * @param Item item
- * The item associated with the element to remove.
- */
- remove(item) {
- if (!item) {
- return;
- }
- this._target.removeChild(item._target);
- this._untangleItem(item);
- },
-
- /**
- * Entangles an item (model) with a displayed node element (view).
- *
- * @param Item item
- * The item describing a target element.
- * @param Node element
- * The element displaying the item.
- */
- _entangleItem(item, element) {
- this._itemsByElement.set(element, item);
- item._target = element;
- },
-
- /**
- * Untangles an item (model) from a displayed node element (view).
- *
- * @param Item item
- * The item describing a target element.
- */
- _untangleItem(item) {
- if (item.finalize) {
- item.finalize(item);
- }
- for (const childItem of item) {
- item.remove(childItem);
- }
-
- this._unlinkItem(item);
- item._target = null;
- },
-
- /**
- * Deletes an item from the its parent's storage maps.
- *
- * @param Item item
- * The item describing a target element.
- */
- _unlinkItem(item) {
- this._itemsByElement.delete(item._target);
- },
-
- /**
- * Returns a string representing the object.
- * Avoid using `toString` to avoid accidental JSONification.
- *
- * @return string
- */
- stringify() {
- return JSON.stringify(
- {
- value: this._value,
- target: this._target + "",
- prebuiltNode: this._prebuiltNode + "",
- attachment: this.attachment,
- },
- null,
- 2
- );
- },
-
- _value: "",
- _target: null,
- _prebuiltNode: null,
- finalize: null,
- attachment: null,
-};