Skip to content

Commit 2069db9

Browse files
committed
util.Logger: ensure component parent paths do not contain duplicate items #6191
1 parent 4dd905a commit 2069db9

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

src/collection/Base.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class Collection extends Base {
811811
/**
812812
* Returns the first item which matches the property and value
813813
* @param {Object|String} property
814-
* @param {String|Number} [value] Only required in case the first param is a string
814+
* @param {Number|String} [value] Only required in case the first param is a string
815815
* @returns {Object} Returns the first found item or null
816816
*/
817817
findFirst(property, value) {
@@ -828,7 +828,7 @@ class Collection extends Base {
828828

829829
/**
830830
* Returns the object associated to the key, or null if there is none.
831-
* @param key
831+
* @param {Number|String} key
832832
* @returns {Object|null}
833833
*/
834834
get(key) {

src/manager/Component.mjs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Component extends Manager {
3535
let me = this;
3636

3737
Neo.first = me.getFirst.bind(me); // alias
38-
Neo.getComponent = me.getById.bind(me) // alias
38+
Neo.getComponent = me.get .bind(me) // alias
3939
}
4040

4141
/**
@@ -157,7 +157,7 @@ class Component extends Manager {
157157
}
158158

159159
/**
160-
* @param {Array} path
160+
* @param {Object[]} path
161161
* @returns {String|null} the component id in case there is a match
162162
*/
163163
findParentComponent(path) {
@@ -179,11 +179,20 @@ class Component extends Manager {
179179

180180
/**
181181
* Returns the object associated to the key, or null if there is none.
182-
* @param key
182+
* @param {Number|String} key
183+
* @param {Boolean} [includeWrapperNodes=true]
183184
* @returns {Neo.component.Base|null}
184185
*/
185-
get(key) {
186-
return this.wrapperNodes.get(key) || super.get(key)
186+
get(key, includeWrapperNodes=true) {
187+
if (includeWrapperNodes) {
188+
let wrapperNode = this.wrapperNodes.get(key);
189+
190+
if (wrapperNode) {
191+
return wrapperNode
192+
}
193+
}
194+
195+
return super.get(key)
187196
}
188197

189198
/**
@@ -333,7 +342,7 @@ class Component extends Manager {
333342
let parentIds = [];
334343

335344
while (component?.parentId) {
336-
component = this.getById(component.parentId);
345+
component = this.get(component.parentId);
337346

338347
if (component) {
339348
parentIds.push(component.id)
@@ -369,13 +378,13 @@ class Component extends Manager {
369378
*/
370379
getParents(component) {
371380
if (Neo.isString(component)) {
372-
component = this.getById(component)
381+
component = this.get(component)
373382
}
374383

375384
let parents = [];
376385

377386
while (component?.parentId) {
378-
component = this.getById(component.parentId);
387+
component = this.get(component.parentId);
379388

380389
if (component) {
381390
parents.push(component)
@@ -509,7 +518,7 @@ class Component extends Manager {
509518
* @returns {Neo.component.Base|Neo.component.Base[]|null}
510519
*/
511520
up(componentId, config, returnFirstMatch=true) {
512-
let component = this.getById(componentId),
521+
let component = this.get(componentId),
513522
returnArray = [],
514523
configArray, configLength, matchArray;
515524

@@ -525,7 +534,7 @@ class Component extends Manager {
525534
configLength = configArray.length;
526535

527536
while (component?.parentId) {
528-
component = this.getById(component.parentId);
537+
component = this.get(component.parentId);
529538

530539
if (!component) {
531540
return returnFirstMatch ? null : returnArray

src/util/Logger.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class Logger extends Base {
163163
component;
164164

165165
data.path.forEach(item => {
166-
component = Neo.getComponent(item.id);
166+
component = Neo.getComponent(item.id, false);
167167

168168
if (component) {
169169
if (!isGroupSet) {

0 commit comments

Comments
 (0)