Description
🐞 bug report
Affected Package
The issue is caused by package @angular/elements
Is this a regression?
No
Description
When an Angular Element is detached from the DOM and then re-attached, none of the event bindings work (see minimal reproduction for demo). I am a Google engineer and this is causing issues for us (internal bug filed here: http://b/168062117).
I talked to @kseamon about this and he thinks the issue is located in either of these 2 places:
angular/packages/elements/src/component-factory-strategy.ts
Lines 109 to 125 in a69507a
Specifically, this.scheduledDestroyFn
in not set to null
in the scheduled destroy and so may be called again upon connect. I'm testing adding one line to see if it fixes the immediate issue.
However, even with this fix, there will still exist a tiny race condition that occurs when an element is scheduled to be destroyed and then connects before the destroy executes.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-ovchwr?file=src%2Findex.html
🔥 Exception or Error
No user-visible exception
🌍 Your Environment
Angular Version:
I'm running it against the latest Angular in google3.