Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

refactor(compiler): support interpolation and encoded entities when lexing markup #42062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented May 12, 2021

The lexer now splits interpolation and encoded entity tokens out from the string it is tokenizing.

See individual commits...

Fixes #41034

@google-cla google-cla bot added the cla: yes label May 12, 2021
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch 6 times, most recently from 049effb to c54d3dd Compare May 13, 2021 17:29
@atscott atscott added the area: compiler Issues related to `ngc`, Angular's template compiler label May 13, 2021
@ngbot ngbot bot added this to the Backlog milestone May 13, 2021
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch 2 times, most recently from 6f94cb4 to ef6198e Compare May 15, 2021 21:06
@petebacondarwin petebacondarwin changed the title refactor(compiler): support interpolation tokens when lexing markup refactor(compiler): support interpolation and encoded entities when lexing markup May 15, 2021
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch 2 times, most recently from 67eab89 to fd33222 Compare May 19, 2021 09:58
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch 3 times, most recently from aa344d9 to bd5a087 Compare June 9, 2021 15:11
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jun 9, 2021
@petebacondarwin petebacondarwin marked this pull request as ready for review June 9, 2021 15:11
@pullapprove pullapprove bot requested review from jelbourn and JoostK June 9, 2021 15:11
@petebacondarwin petebacondarwin requested review from alxhub and removed request for jelbourn June 9, 2021 20:06
@pullapprove pullapprove bot requested a review from jelbourn June 9, 2021 20:06
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: fw-playground

Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

I left a bunch of comments. I would be curious to know how this would behave in TGP run, as that would give us a better feeling for how breaky this might be and/or which cases this doesn't handle correctly.


There's two typos in "refactor(compiler): support encoded entity tokens when lexing markup":

The lexer now splits encoded entity tokens out from text and attribute value tokens.
Previously encoded entities would be decoded and there their decoded value would be
included as part of the text token of the surrounding text. Now the entities will have
their own tokens. There are two scenarios: text and attribute values.

The HTML parser has been modified to recombined recombine these tokens to allow this
refactoring to have limited effect in this commit. Further refactorings
to use these new tokens will follow in subsequent commits.

@@ -1,6 +1,6 @@
<div class="zippy">
<div (click)="toggle()" class="zippy__title">
{{ visible ? '&#x25BE;' : '&#x25B8;' }} {{title}}
{{ visible ? '\u25BE' : '\u25B8' }} {{title}}
Copy link
Member

Choose a reason for hiding this comment

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

I think this change also means this would technically be a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One person's bug fix is another person's breaking change... but perhaps you are right 😞

No doubt there will be loads of these in G3...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this was a refactoring commit. I wonder how I can get this BREAKING CHANGE into the change log...
Perhaps I should rename this commit to a fix? Where I am "fixing" the fact that interpolated blocks should not be decoding HTML entities??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alxhub @JoostK - thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a commit that ensures this breaking change does not happen.

Copy link
Member

Choose a reason for hiding this comment

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

Rather than make this change here, and revert it later, can we squash the fix commit (I'm guessing refactor(compiler): ensure that HTML entities in interpolations are decoded) into this one?

In general I'm a huge proponent of commits being independent - merging only half the commits from this PR shouldn't leave the repo in a broken state, for example.

packages/compiler/src/ml_parser/lexer.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/lexer.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/lexer.ts Show resolved Hide resolved
packages/compiler/src/ml_parser/parser.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/html_whitespaces.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/html_whitespaces.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/parser.ts Outdated Show resolved Hide resolved
packages/compiler/src/i18n/i18n_parser.ts Outdated Show resolved Hide resolved
packages/compiler/src/i18n/i18n_parser.ts Show resolved Hide resolved
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch from bd5a087 to 7bca035 Compare June 11, 2021 10:14
packages/compiler/src/ml_parser/lexer.ts Outdated Show resolved Hide resolved
packages/compiler/src/ml_parser/ast.ts Outdated Show resolved Hide resolved
@petebacondarwin petebacondarwin force-pushed the compiler-lex-interpolations branch from 7bca035 to 451e3bf Compare June 12, 2021 18:48
@angular-automatic-lock-bot
Copy link

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 Oct 9, 2021
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 cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extract-i18n with HTML entities and interpolation
6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.