Skip to content

fix(icon): use plain Map in BroadcastChannel messages to fix Safari DataCloneError#2127

Closed
desig9stein wants to merge 2 commits intomasterfrom
mpopov/fix-safari-DataCloneError
Closed

fix(icon): use plain Map in BroadcastChannel messages to fix Safari DataCloneError#2127
desig9stein wants to merge 2 commits intomasterfrom
mpopov/fix-safari-DataCloneError

Conversation

@desig9stein
Copy link
Contributor

@desig9stein desig9stein commented Mar 6, 2026

closes: #2126

DefaultMap instances contain a non-cloneable _factoryFn function property. When passed to BroadcastChannel.postMessage(), Safari throws DataCloneError since functions are not structured-cloneable (Chrome silently tolerates it).

Replace DefaultMap with plain Map objects in all broadcast payloads:

  • _getUserRefsCollection and _getUserSetCollection in icon-state.broadcast.ts
  • register and setIconRef broadcast calls in icon.registry.ts

Description

Provide a clear and concise summary of the changes in this PR and the motivation behind them

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to change)
  • Documentation update
  • Refactoring (code improvements without functional changes)

Related Issues

Closes #

Testing

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have updated documentation if needed
  • Breaking changes are documented in the description

…ataCloneError

DefaultMap instances contain a non-cloneable _factoryFn function property.
When passed to BroadcastChannel.postMessage(), Safari throws DataCloneError
since functions are not structured-cloneable (Chrome silently tolerates it).

Replace DefaultMap with plain Map objects in all broadcast payloads:
- _getUserRefsCollection and _getUserSetCollection in icon-state.broadcast.ts
- register and setIconRef broadcast calls in icon.registry.ts
Copy link
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 Safari DataCloneError when syncing icon registry state across contexts by ensuring BroadcastChannel messages only contain structured-cloneable data.

Changes:

  • Replaced DefaultMap with plain Map instances in icon registration and icon reference update broadcast payloads.
  • Updated IconsStateBroadcast sync-state payload building to return plain Map collections for user-set icons and external references.

Reviewed changes

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

File Description
src/components/icon/icon.registry.ts Builds BroadcastChannel payloads for RegisterIcon / UpdateIconReference using plain nested Maps.
src/components/icon/icon-state.broadcast.ts Constructs sync-state collections / references payloads with plain nested Maps (no DefaultMap in messages).

Copy link
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@rkaraivanov
Copy link
Member

Closing in favour of #2128

@rkaraivanov rkaraivanov closed this Mar 6, 2026
@rkaraivanov rkaraivanov deleted the mpopov/fix-safari-DataCloneError branch March 6, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

igniteui-angular dev demos are not working in safari

4 participants