angular-cn/packages/elements/test
George Kalpakas 2a330a60ed fix(elements): fire custom element output events during component initialization (#36161)
Previously, event listeners for component output events attached on an
Angular custom element before inserting it into the DOM (i.e. before
instantiating the underlying component) didn't fire for events emitted
during initialization lifecycle hooks, such as `ngAfterContentInit`,
`ngAfterViewInit`, `ngOnChanges` (initial call) and `ngOnInit`.
The reason was that that `NgElementImpl` [subscribed to events][1]
_after_ calling [ngElementStrategy#connect()][2], which is where the
[initial change detection][3] takes place (running the initialization
lifecycle hooks).

This commit fixes this by:
1. Ensuring `ComponentNgElementStrategy#events` is defined and available
   for subscribing to, even before instantiating the component.
2. Ensuring `NgElementImpl` subscribes to `NgElementStrategy#events`
   before calling `NgElementStrategy#connect()` (which initializes the
   component instance).

Jira issue: [FW-2010](https://angular-team.atlassian.net/browse/FW-2010)

[1]: c0143cb2ab/packages/elements/src/create-custom-element.ts (L167-L170)
[2]: c0143cb2ab/packages/elements/src/create-custom-element.ts (L164)
[3]: c0143cb2ab/packages/elements/src/component-factory-strategy.ts (L158)

Fixes #36141

PR Close #36161
2020-06-05 10:36:39 -07:00
..
BUILD.bazel build: fix and re-enable elements tests on saucelabs (#36929) 2020-05-05 12:04:48 -07:00
component-factory-strategy_spec.ts fix(elements): fire custom element output events during component initialization (#36161) 2020-06-05 10:36:39 -07:00
create-custom-element_spec.ts fix(elements): fire custom element output events during component initialization (#36161) 2020-06-05 10:36:39 -07:00
extract-projectable-nodes_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
slots_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
utils_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00