Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NgTemplateOutlet] _updateExistingContext causes side effects #40493

Closed
konossow opened this issue Jan 20, 2021 · 2 comments
Closed

[NgTemplateOutlet] _updateExistingContext causes side effects #40493

konossow opened this issue Jan 20, 2021 · 2 comments

Comments

@konossow
Copy link

馃悶 bug report

Affected Package

The issue is caused by package @angular/common

Is this a regression?

I don't know, but I'm sure it occurs also in version 9.

Description

  1. Prepare a template that has an object passed by $implicit (cannot be a primitive value).
  2. Change 2 times context value of ngTemplateOutlet.
  3. After second change origin object was changed.

馃敩 Minimal Reproduction

https://stackblitz.com/edit/angular-fvm7oz?file=src/app/app.component.html

  1. Select 0.
  2. Inspect selected item - has changed.
  3. Select 1.
  4. Inspect selected item - has changed.
  5. Inspect contents of contexts array - value at index 0 was replaced with value at index 1.
  6. Select 0.
  7. Inspect selected item - has not changed.

馃敟 Exception or Error

No error is presented, but if objects inside contexts array are freezed (uncomment line 28 and 31) error is shown:


ERROR TypeError: Cannot assign to read only property '$implicit' of object '[object Object]'
    at NgTemplateOutlet._updateExistingContext (ng_template_outlet.ts:104)
    at NgTemplateOutlet.ngOnChanges (ng_template_outlet.ts:68)
    at checkAndUpdateDirectiveInline (provider.ts:213)
    at checkAndUpdateNodeInline (view.ts:440)
    at checkAndUpdateNode (view.ts:400)
    at debugCheckAndUpdateNode (services.ts:435)
    at debugCheckDirectivesFn (services.ts:396)
    at Object.eval [as updateDirectives] (AppComponent.html:6)
    at Object.debugUpdateDirectives [as updateDirectives] (services.ts:390)
    at checkAndUpdateView (view.ts:370)

馃實 Your Environment

Angular Version:


11.0.8

Anything else relevant?
The reason why I use an object in $implicit is that I don't know the structure of object - it's created dynamically. Therefore I cannot separate properties through additional properties.

@JoostK
Copy link
Member

JoostK commented Jan 20, 2021

Heya, this is a known issue as reported in #24515. There has been recent activity in #40360 to fix this, but it proved to be a breaking change so it needs coordination to land.

I'll close this as a duplicate of #24515; please follow the aforementioned issues for future updates.

@JoostK JoostK closed this as completed Jan 20, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants