Files
nothoughts/node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.mjs
2025-08-04 18:57:35 +02:00

92 lines
2.8 KiB
JavaScript

import { deprecation, v8_0_0 } from '../../../utils/logging/deprecation.mjs';
"use strict";
const findMixin = {
/**
* The instance label of the object.
* @memberof scene.Container#
* @member {string} label
*/
label: null,
/**
* The instance name of the object.
* @deprecated since 8.0.0
* @see scene.Container#label
* @member {string} name
* @memberof scene.Container#
*/
get name() {
deprecation(v8_0_0, "Container.name property has been removed, use Container.label instead");
return this.label;
},
set name(value) {
deprecation(v8_0_0, "Container.name property has been removed, use Container.label instead");
this.label = value;
},
/**
* @method getChildByName
* @deprecated since 8.0.0
* @param {string} name - Instance name.
* @param {boolean}[deep=false] - Whether to search recursively
* @returns {Container} The child with the specified name.
* @see scene.Container#getChildByLabel
* @memberof scene.Container#
*/
getChildByName(name, deep = false) {
return this.getChildByLabel(name, deep);
},
/**
* Returns the first child in the container with the specified label.
*
* Recursive searches are done in a pre-order traversal.
* @memberof scene.Container#
* @param {string|RegExp} label - Instance label.
* @param {boolean}[deep=false] - Whether to search recursively
* @returns {Container} The child with the specified label.
*/
getChildByLabel(label, deep = false) {
const children = this.children;
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (child.label === label || label instanceof RegExp && label.test(child.label))
return child;
}
if (deep) {
for (let i = 0; i < children.length; i++) {
const child = children[i];
const found = child.getChildByLabel(label, true);
if (found) {
return found;
}
}
}
return null;
},
/**
* Returns all children in the container with the specified label.
* @memberof scene.Container#
* @param {string|RegExp} label - Instance label.
* @param {boolean}[deep=false] - Whether to search recursively
* @param {Container[]} [out=[]] - The array to store matching children in.
* @returns {Container[]} An array of children with the specified label.
*/
getChildrenByLabel(label, deep = false, out = []) {
const children = this.children;
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (child.label === label || label instanceof RegExp && label.test(child.label)) {
out.push(child);
}
}
if (deep) {
for (let i = 0; i < children.length; i++) {
children[i].getChildrenByLabel(label, true, out);
}
}
return out;
}
};
export { findMixin };
//# sourceMappingURL=findMixin.mjs.map