Skip to content

fix(compiler): match directives on ng-template inside SVG - #70475

Closed
splincode wants to merge 1 commit into
angular:mainfrom
splincode:splincode/fix-svg-ng-template-unused-import
Closed

splincode wants to merge 1 commit into
angular:mainfrom
splincode:splincode/fix-svg-ng-template-unused-import

Conversation

@splincode

@splincode splincode commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • The commit message follows the Angular commit guidelines.
  • Tests for the changes have been added.
  • Documentation is not applicable to this compiler bug fix.

PR Type

  • Bugfix

What is the current behavior?

Explicit ng-template elements nested inside SVG are represented with a namespaced tag name. Attribute collection for directive matching compares the tag name directly with ng-template, so these nodes are treated like structural templates. As a result, directives such as NgTemplateOutlet do not match and can be incorrectly reported as unused by NG8113.

Fixes #70471.

What is the new behavior?

Recognize ng-template elements independently of their namespace when collecting attributes for directive matching. Directives applied to ng-template inside SVG now match and are included in the component's used directives.

The regression test covers the minimized reproduction from the issue.

Does this PR introduce a breaking change?

  • No

Treat explicitly namespaced ng-template elements like their HTML counterparts when collecting attributes for directive matching. This prevents used standalone directives from being reported as unused.

Fixes angular#70471
@pullapprove
pullapprove Bot requested a review from JoostK August 30, 2026 16:57
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Aug 30, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 30, 2026
@JeanMeche

Copy link
Copy Markdown
Member

Dupe #70474

@JeanMeche JeanMeche closed this Aug 30, 2026
@splincode
splincode deleted the splincode/fix-svg-ng-template-unused-import branch August 30, 2026 17:04
@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: compiler Issues related to `ngc`, Angular's template compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning for directive not used within the template, when it actually is

2 participants