Skip to content

fix(elements): strip Blazor externalObject from expression tree events - 21.2.x#17252

Open
IMinchev64 wants to merge 1 commit into21.2.xfrom
iminchev/blazor-expression-tree-external-object-21.2.x
Open

fix(elements): strip Blazor externalObject from expression tree events - 21.2.x#17252
IMinchev64 wants to merge 1 commit into21.2.xfrom
iminchev/blazor-expression-tree-external-object-21.2.x

Conversation

@IMinchev64
Copy link
Copy Markdown
Contributor

@IMinchev64 IMinchev64 commented Apr 29, 2026

Closes https://github.com/Infragistics-Developer-Tools/dev-tools/issues/3208

Description

Motivation / Context

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

@IMinchev64 IMinchev64 requested a review from mddragnev April 29, 2026 14:32
Copilot AI review requested due to automatic review settings April 29, 2026 14:32
@IMinchev64 IMinchev64 added ❌ status: awaiting-test PRs awaiting manual verification 💠 grid: elements labels Apr 29, 2026
@IMinchev64 IMinchev64 changed the title fix(elements): strip Blazor externalObject from expression tree events fix(elements): strip Blazor externalObject from expression tree events - 21.2.x Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes interop/serialization issues caused by Blazor-injected externalObject properties leaking into emitted expression tree payloads, ensuring expression-tree-related events and comparisons don’t break when externalObject is present.

Changes:

  • Ignore externalObject during Query Builder tree comparison to prevent unnecessary root group recreation / serialization issues.
  • Sanitize Angular Elements output events for filtering/expression trees by stripping externalObject from emitted trees.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
projects/igniteui-angular/query-builder/src/query-builder/query-builder-tree.component.ts Adds externalObject to the set of ignored properties during JSON-based tree comparisons.
projects/igniteui-angular-elements/src/app/custom-strategy.ts Adds event-specific sanitization for expression-tree outputs and introduces stripExternalObject traversal.

Comment on lines +481 to +492
for (const operand of tree?.filteringOperands ?? []) {
if ('operator' in operand) {
this.stripExternalObject(operand);
continue;
}

delete (operand.condition as any)?.externalObject;

if ((operand as IFilteringExpression).searchTree) {
this.stripExternalObject(operand.searchTree);
}
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripExternalObject currently only deletes externalObject from operand.condition. The Blazor workaround elsewhere in the repo treats externalObject as a generic non-serializable key (e.g. JSON stringify replacers), so this may leave externalObject on other nodes (tree/operands/searchTree) and still break event serialization. Consider stripping externalObject from every visited object in the expression tree (including tree nodes and expressions), ideally using a visited set to avoid potential cycles from wrapper-injected references.

Suggested change
for (const operand of tree?.filteringOperands ?? []) {
if ('operator' in operand) {
this.stripExternalObject(operand);
continue;
}
delete (operand.condition as any)?.externalObject;
if ((operand as IFilteringExpression).searchTree) {
this.stripExternalObject(operand.searchTree);
}
}
this.stripExternalObjectFromNode(tree, new WeakSet<object>());
}
protected stripExternalObjectFromNode(value: unknown, visited: WeakSet<object>): void {
if (!value || typeof value !== 'object') {
return;
}
if (visited.has(value)) {
return;
}
visited.add(value);
delete (value as { externalObject?: unknown }).externalObject;
if (Array.isArray(value)) {
for (const item of value) {
this.stripExternalObjectFromNode(item, visited);
}
return;
}
for (const nestedValue of Object.values(value)) {
this.stripExternalObjectFromNode(nestedValue, visited);
}

Copilot uses AI. Check for mistakes.
Comment thread projects/igniteui-angular-elements/src/app/custom-strategy.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💠 grid: elements ❌ status: awaiting-test PRs awaiting manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants