angular / angular/angular

ViewEncapsulation.Emulated is not working for dynamically created components

オープン
#12,215 コメント 9 件 リアクション 18 件 担当者 0 名 GitHub で見る
area: core core: CSS encapsulation core: dynamic view creation freq1: low P3 state: confirmed type: bug/fix
主要言語
TypeScript
スター
101k
フォーク
27.5k
平均マージ
1日 19時間
マージ済み PR(30日)
288

説明

**I'm submitting a ...** (check one with "x")

```
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
```

**Current behavior**

Angular 2 doesn't set `_ngcontent-*` attribute on the components created using `ViewContainerRef.createComponent()` when `ViewEncapsulation.Emulated` is used.

**Expected behavior**

Angular 2 sets `_ngcontent-*` attribute on the components created using `ViewContainerRef.createComponent()` when `ViewEncapsulation.Emulated` is used.

**Minimal reproduction of the problem with instructions**

~See reproduction example: http://plnkr.co/edit/0HF3A2muRlAVOEonJvs7~
Updated reproduction for Angular 6: https://stackblitz.com/edit/angular-uzjtlp

If you change view encapsulation to native (in browser supporting it) `my-dynamic-comp` will become red (which is expected behaviour). But with emulated view encapsulation it stays green. It's because `_ngcontent-*` attribute is not set on the dynamically created component's host element.

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

Emulated behaviour works different from native, so I assume it is a bug.

**Please tell us about your environment:**

- **Angular version:** 2.0.2
- **Browser:** all
- **Language:** TypeScript (but it may be relevant for others as well)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by reproducing the issue with ViewContainerRef.createComponent() using the linked StackBlitz example, then trace how dynamically created components receive their host attributes under ViewEncapsulation.Emulated. Done means the dynamic component's host element receives the expected _ngcontent-* attribute and the reproduction applies the same styling as native encapsulation.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。