Skip to content

ngTemplateOutlet modifies its initial context when getting a new context whose shape is the same #24515

@divdavem

Description

@divdavem

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

ngTemplateOutlet modifies the previous context when getting a new context whose shape is the same.

Expected behavior

ngTemplateOutlet should not change its context parameters in any case.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-ymixqh?file=src%2Fapp%2Fapp.component.ts

Click on "Swap". The contexts of the ngTemplateOutlets directives are swapped.
We should see "name = context 2" on the first line and "name = context 1" on the second line, but both lines show "name = context 2". The first ngTemplateOutlet has changed the name property of the first context when receiving the second context.

Note that the problem does not happen if the contexts do not have exactly the same set of properties (for example, when adding "foo: true" in the first context but not in the second, the behavior of ngTemplateOutlet is correct).

What is the motivation / use case for changing the behavior?

It is clearly a bug. It is confusing.

Environment


Angular version: 6.0.0

Browser: all

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: commonIssues related to APIs in the @angular/common packagefreq1: lowstate: confirmedstate: has PRtype: bug/fix

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions