René's URL Explorer Experiment


Title: Refactoring of Template Expression Parsing for Stability · Issue #31898 · angular/angular · GitHub

Open Graph Title: Refactoring of Template Expression Parsing for Stability · Issue #31898 · angular/angular

X Title: Refactoring of Template Expression Parsing for Stability · Issue #31898 · angular/angular

Description: 🚀 feature request Relevant Package @angular/compiler @angular/compiler-cli Description The Angular template expression parser, while working well for Angular compilations, has several issues that make the AST it generates difficult to us...

Open Graph Description: 🚀 feature request Relevant Package @angular/compiler @angular/compiler-cli Description The Angular template expression parser, while working well for Angular compilations, has several issues that m...

X Description: 🚀 feature request Relevant Package @angular/compiler @angular/compiler-cli Description The Angular template expression parser, while working well for Angular compilations, has several issues that m...

Opengraph URL: https://github.com/angular/angular/issues/31898

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refactoring of Template Expression Parsing for Stability","articleBody":"# 🚀 feature request\r\n\r\n### Relevant Package\r\n@angular/compiler\r\n@angular/compiler-cli \r\n\r\n### Description\r\n\r\nThe Angular template expression parser, while working well for Angular compilations, has several issues that make the AST it generates difficult to use for other tasks; notably source mapping and indexing. This is because in many cases, the expression ASTs generated by the expression parser are not representative of the raw source code the expression is defined in.\r\n\r\n[Design Doc](https://hackmd.io/@X3ECPVy-RCuVfba-pnvIpw/BkDUxaW84/%2FMA1oxh6jRXqSmZBcLfYdyw?type=book) (with examples of issues)\r\n\r\nThis issue is meant to track development of the parser to better support use cases of source mapping and indexing. An overview of a plan-of-action is available on the design doc, as are examples of the issues currently experienced with expression ASTs.\r\n\r\nWork in this domain has already been started with at least #30181 and #31391.\r\n\r\n### Presentation of issues\r\n\r\n#### Preemptive discarding of whitespace\r\n\r\nThe template parsing pipeline discards whitespace in a template before generating the Render3Ast (the combined markup and expression AST):\r\n\r\nhttps://github.com/angular/angular/blob/376ad9c3cdf5a9432500333bce4a6fc42113210a/packages/compiler/src/render3/view/template.ts#L1942-L1956\r\n\r\nThis leads to a couple issues. The primary one is that the AST is not representative of the source code unless the entire pipeline is run without preserving whitespaces. The second is codes like\r\n\r\n```html\r\n\u003cdiv>{{ '    '.length }}\u003c/div>\r\n```\r\n\r\nare folded and ultimately evaluated to\r\n\r\n```html\r\n\u003cdiv>0\u003c/div>\r\n```\r\n\r\nA proposed solution is to eventually move the whitespace removal step to after the R3Ast is already generated. This involves writing a new tree rewriter.\r\n\r\n#### Overlapping spans with `leadingTriviaChars`\r\n\r\nThis issue has been previously recorded in #30181.\r\nTemplates parsed with leading trivia characters can wind up having overlapping spans between template HTML nodes and template expressions when whitespace discarding is disabled.\r\n\r\n```html\r\n\u003cdiv>  \\n {{foo}}\u003c/div>\r\n^^^^^^^^^                   recorded span of opening `div`\r\n     ^^^^^^^^^^^^           recorded span of node text\r\n```\r\n\r\nA proposed solution is to record the absolute span of such expressions in the source code so that there is no need to add source spans to compute expression spans in a template.\r\n\r\n#### Misleading `AstWithSource` spans\r\n\r\nConsider a template code\r\n\r\n```html\r\n\u003cdiv *ngFor=\"let _ of all\">\u003c/div>\r\n```\r\n\r\nAbbreviated for example, the AST of this template is\r\n\r\n```typescript\r\nBoundAttribute {\r\n    name: 'ngForOf',\r\n    value: AstWithSource {\r\n        source: 'all',\r\n        span: {start: 0, end: 3},\r\n        ast: PropertyRead {\r\n            name: 'all',\r\n            span: {start: 9, end: 12},\r\n        },\r\n    }\r\n}\r\n```\r\n\r\nThe issue here is that `AstWithSource` records the same source the `PropertyRead` does, but in a different context. It's difficult to tell the best way to resolve this:\r\n\r\n- Should we ignore `AstWithSource` and look only at the `PropertyRead` span?\r\n    - This breaks cases where `AstWithSource` is worth looking at, e.g. in most non-template-binding ASTs\r\n- Should `AstWithSource` provide the span for all of `let _ of all`?\r\n    - This is not necessarily the goal of `AstWithSource` and breaks many existing consumers of `AstWithSource`.\r\n- Should `PropertyRead` have a span relative to `AstWithSource`?\r\n    - This requires updating `AstWithSource`'s source span calculation and also breaks many existing consumers.\r\n\r\nThe least ambiguous resolution is to record the source span of `AstWithSource` and the `PropertyRead` relative to the entire source code, so that calculation via span summation is not needed at all.\r\n\r\n### Proposed Plan of Attack\r\n\r\nThese issues can be reconciled by several goals. These goals are ordered by increasing size of impact, not necessarily by linearity.\r\n\r\n1. Record absolute source spans and byte offsets of expressions.\r\n    - Move to expression ASTs recording the absolute location of an expression in a template file, not relative to the HTML node they are contained in as is being done now.\r\n    - Introduce a new `AbsoluteSourceSpan` to represent this.\r\n2. Create a new `ExpressionIdentifier` (name variable) class to augment the name field of an expression AST. This will contain more accurate information about an expression, including\r\n    - Its name\r\n    - Its raw/original form\r\n    - Its logical/computed form\r\n3. Move AST whitespace folding to after the R3 AST has already been created.\r\n    - Create a new tree rewriter that can perform this.\r\n\r\n### Related Issues\r\n\r\nhttps://github.com/angular/vscode-ng-language-service/issues/137","author":{"url":"https://github.com/ayazhafiz","@type":"Person","name":"ayazhafiz"},"datePublished":"2019-07-29T20:45:42Z","url":"https://github.com/angular/angular/issues/31898"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:930cd7eb-3f36-caf6-f1ca-ea8baefd1e57
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id87EC:240CD1:12B712D:17D74EC:6B012202
html-safe-noncecbae4b562ecbb76d497ed4bd7b96973e93f8c0f0b10fbf4f3f510b0bf2be03ce
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0VDOjI0MENEMToxMkI3MTJEOjE3RDc0RUM6NkIwMTIyMDIiLCJ2aXNpdG9yX2lkIjoiNDk1OTY1MDE3MTgwMTY1MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac860b422342ee68e33bdebbfe6f4f07f571baa46e117a867fe652da367ee74b35
hovercard-subject-tagissue:474248311
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/31898/issue_layout
twitter:imagehttps://opengraph.githubassets.com/279abf4284fe7d9854c1b69f81565190f696683fef25e19009e358ba88f3eace/angular/angular/issues/31898
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/279abf4284fe7d9854c1b69f81565190f696683fef25e19009e358ba88f3eace/angular/angular/issues/31898
og:image:alt🚀 feature request Relevant Package @angular/compiler @angular/compiler-cli Description The Angular template expression parser, while working well for Angular compilations, has several issues that m...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameayazhafiz
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/31898#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F31898
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F31898
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/31898
Reloadhttps://github.com/angular/angular/issues/31898
Reloadhttps://github.com/angular/angular/issues/31898
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/31898
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/31898
Refactoring of Template Expression Parsing for Stabilityhttps://github.com/angular/angular/issues/31898#top
https://github.com/ayazhafiz
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
compiler: parserhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22compiler%3A%20parser%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
refactoringIssue that involves refactoring or code-cleanuphttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22refactoring%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/ayazhafiz
ayazhafizhttps://github.com/ayazhafiz
on Jul 29, 2019https://github.com/angular/angular/issues/31898#issue-474248311
Design Dochttps://hackmd.io/@X3ECPVy-RCuVfba-pnvIpw/BkDUxaW84/%2FMA1oxh6jRXqSmZBcLfYdyw?type=book
#30181https://github.com/angular/angular/pull/30181
#31391https://github.com/angular/angular/pull/31391
angular/packages/compiler/src/render3/view/template.tshttps://github.com/angular/angular/blob/376ad9c3cdf5a9432500333bce4a6fc42113210a/packages/compiler/src/render3/view/template.ts#L1942-L1956
376ad9chttps://github.com/angular/angular/commit/376ad9c3cdf5a9432500333bce4a6fc42113210a
#30181https://github.com/angular/angular/pull/30181
angular/vscode-ng-language-service#137https://github.com/angular/vscode-ng-language-service/issues/137
ayazhafizhttps://github.com/ayazhafiz
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
refactoringIssue that involves refactoring or code-cleanuphttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22refactoring%22
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
on Jul 29, 2019https://github.com/angular/angular/issues/31898#event-2517767092
ngbothttps://github.com/apps/ngbot
Backloghttps://github.com/angular/angular/milestone/82
on Jul 29, 2019https://github.com/angular/angular/issues/31898#event-2517767149
ayazhafizhttps://github.com/ayazhafiz
on Aug 25, 2019https://github.com/angular/angular/issues/31898#event-2582153308
ayazhafizhttps://github.com/ayazhafiz
on Oct 11, 2019https://github.com/angular/angular/issues/31898#event-2707078286
feat(compiler): record absolute span of template expressions in parserhttps://github.com/ayazhafiz/angular/commit/c375d46a4b30e7fba94b8ac297951061e6fb544a
c375d46https://github.com/ayazhafiz/angular/commit/c375d46a4b30e7fba94b8ac297951061e6fb544a
mheveryhttps://github.com/mhevery
on Oct 14, 2019https://github.com/angular/angular/issues/31898#event-2711683270
feat(compiler): record absolute span of template expressions in parser (https://github.com/angular/angular/commit/b04488d692ca11c83444da56f51d53c3ac868243
b04488dhttps://github.com/angular/angular/commit/b04488d692ca11c83444da56f51d53c3ac868243
JoostKhttps://github.com/JoostK
compiler: parserhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22compiler%3A%20parser%22
on Nov 7, 2020https://github.com/angular/angular/issues/31898#event-3970236584
angular-robothttps://github.com/apps/angular-robot
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on Jun 4, 2021https://github.com/angular/angular/issues/31898#event-4843634385
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Jun 4, 2021https://github.com/angular/angular/issues/31898#issuecomment-854787732
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
ayazhafizhttps://github.com/ayazhafiz
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 4, 2021https://github.com/angular/angular/issues/31898#event-4844431601
ayazhafizhttps://github.com/ayazhafiz
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on Jun 4, 2021https://github.com/angular/angular/issues/31898#event-4844432004
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jul 5, 2021https://github.com/angular/angular/issues/31898#issuecomment-874216470
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jul 5, 2021https://github.com/angular/angular/issues/31898#event-4979344491
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/31898
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/31898
ayazhafizhttps://github.com/ayazhafiz
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
compiler: parserhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22compiler%3A%20parser%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
refactoringIssue that involves refactoring or code-cleanuphttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22refactoring%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.