Skip to content

feat(compiler): Support comments in html element.#67179

Merged
leonsenft merged 1 commit into
angular:mainfrom
JeanMeche:comments-html
Mar 19, 2026
Merged

feat(compiler): Support comments in html element.#67179
leonsenft merged 1 commit into
angular:mainfrom
JeanMeche:comments-html

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Feb 20, 2026

Copy link
Copy Markdown
Member

Let's support comments !

<div
  // comment 0
  /* comment 1 */
  attr1="value1"
  /*
     comment 2
     spanning multiple lines
  */
  attr2="value2"
></div>

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: compiler Issues related to `ngc`, Angular's template compiler labels Feb 20, 2026
@ngbot ngbot Bot added this to the Backlog milestone Feb 20, 2026
@JeanMeche JeanMeche force-pushed the comments-html branch 3 times, most recently from f8ea349 to 38dd529 Compare February 20, 2026 17:37
@JeanMeche JeanMeche marked this pull request as ready for review February 26, 2026 17:40
@JeanMeche JeanMeche requested a review from crisbeto February 26, 2026 17:50
Comment thread packages/compiler/test/ml_parser/inline_comment_spec.ts
Comment thread packages/compiler/test/ml_parser/inline_comment_spec.ts
@JeanMeche JeanMeche force-pushed the comments-html branch 3 times, most recently from de62b79 to d4e467c Compare March 2, 2026 15:29
@JeanMeche JeanMeche modified the milestones: Backlog, v22 candidates Mar 2, 2026
@JeanMeche JeanMeche force-pushed the comments-html branch 2 times, most recently from cd2cd11 to a7d7341 Compare March 3, 2026 01:14
@JeanMeche JeanMeche requested a review from atscott March 3, 2026 01:14
@lacolaco

lacolaco commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

I thought this is an interesting approach, but is there any prior art to similar syntax?
I am concerned that syntax with too few precedents will require more instruction to receive adequate LLM support.

@JeanMeche

Copy link
Copy Markdown
Member Author

That we be indeed a novelty, that LLMs will have to learn.
But it's somehow consistent accross frameworks (svelte is going with it too).

Also we do see potential to support ts compiler directives comments like @ts-ignore, @ts-expect-error etc in the future.

@lacolaco

lacolaco commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

@JeanMeche Thank you Matthieu for clarifying! I didn't know about Svelte's approach. If this could potentially become a new convention for component writing, it would gradually become easier for LLMs to understand as well.

it('should maintain correct source spans with comments', () => {
// 0 1 2 3 4
// 0123456789012345678901234567890123456789012345
// <div attr1="a" /* comment */ attr2="b"></div>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments still relevant?

@JeanMeche JeanMeche removed the request for review from atscott March 19, 2026 18:02
```
      <div
        // comment 0
        /* comment 1 */
        attr1="value1"
        /*
           comment 2
           spanning multiple lines
        */
        attr2="value2"
      ></div>
```
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Mar 19, 2026
@JeanMeche

Copy link
Copy Markdown
Member Author

Presubmit is ok, breakage is unrelated

@leonsenft leonsenft merged commit e850643 into angular:main Mar 19, 2026
23 of 25 checks passed
@leonsenft

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue 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 Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants