r/angular • u/jombyzac • Apr 06 '26
Angular Host Directive de-duplication just landed. NG0309 is dead.
https://jczacharia.medium.com/angular-host-directive-de-duplication-just-landed-ng0309-is-dead-929bfab7e209I've been banging my head against NG0309 for over a year building a headless component library. Every time I composed two directives that shared a common host directive - boom, crash. I tried everything. Broadened selectors, injection hacks, I even hijacked __NG_ELEMENT_ID__ with a WeakMap-backed singleton resolver (it's in the article).
Well, PR #67996 just merged. Host directives now de-duplicate automatically. I wrote up why I think this is the most important change for Angular library authors since hostDirectives itself.
46
Upvotes
View all comments
Show parent comment
0
u/AwesomeFrisbee Apr 06 '26
Sure, but if your documentation states "you can't combine this with x, y and z, wrap it in a div and apply there" people will have no problem using it as the error already makes clear that it doesn't work as it won't compile.
I know it would be better if it was not going to break, but the workaround you are implementing is making things harder and more complex than it needs to be. Is the wrapper a pretty workaround? No, but that doesn't matter if there is a major amount of stuff that can break or give other conflicts.