Skip to content

Commit

Permalink
filter earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Jun 6, 2024
1 parent eb58594 commit 1e6afd3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/clients/walkerjs/src/lib/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ export function getEntities(
filter = Object.keys(filter || {}).length !== 0 ? filter : undefined;

while (element) {
const entity = getEntity(prefix, element, target);

if (entity && (!filter || filter[entity.type])) entities.push(entity);
const entity = getEntity(prefix, element, target, filter);
if (entity) entities.push(entity);

element = getParent(prefix, element);
}
Expand All @@ -243,10 +242,12 @@ function getEntity(
prefix: string,
element: Element,
origin?: Element,
filter?: Walker.Filter,
): WalkerOS.Entity | null {
const type = getAttribute(element, getElbAttributeName(prefix));

if (!type) return null; // It's not a (valid) entity element
// It's not a (valid) entity element or should be filtered
if (!type || (filter && !filter[type])) return null;

const scopeElems = [element]; // All related elements
const dataSelector = `[${getElbAttributeName(
Expand Down

0 comments on commit 1e6afd3

Please sign in to comment.