Title: Add support for indexing template elements · Issue #31299 · angular/angular · GitHub
Open Graph Title: Add support for indexing template elements · Issue #31299 · angular/angular
X Title: Add support for indexing template elements · Issue #31299 · angular/angular
Description: @alxhub and I recently discussed how best to implement indexing template elements in the Ngtsc indexing module. I'm dumping the key points of that discussion here for future reference and discussion. 🚀 feature request Relevant Package Fo...
Open Graph Description: @alxhub and I recently discussed how best to implement indexing template elements in the Ngtsc indexing module. I'm dumping the key points of that discussion here for future reference and discussio...
X Description: @alxhub and I recently discussed how best to implement indexing template elements in the Ngtsc indexing module. I'm dumping the key points of that discussion here for future reference and discu...
Opengraph URL: https://github.com/angular/angular/issues/31299
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for indexing template elements","articleBody":"@alxhub and I recently discussed how best to implement indexing template elements in the [`Ngtsc` indexing module](./packages/compiler-cli/src/ngtsc/indexer). I'm dumping the key points of that discussion here for future reference and discussion.\r\n\r\n# 🚀 feature request\r\n\r\n### Relevant Package\r\n\r\nFor @angular/compiler-cli, `Ngtsc` indexer module.\r\n\r\n### Description\r\n\r\nThe compiler's indexing module does not currently support indexing HTML elements in templates. We want to add support for that. Initially, the scope of this was\r\n\r\n- Record element selectors used in the template\r\n- Record used directives in the template\r\n\r\nsuch that an indexer could link an element selector to the directive it references, if any. This approach is quite limiting, however, because directive selectors can match on many things beside element selectors, including matching on attributes and implicitly matching on the absence of an attribute. A better approach is\r\n\r\n- Record element selectors used in the template\r\n - each selector record also includes a record of attributes on the element\r\n - each selector record also includes a record of used directives on the element\r\n\r\nTo consider the usefulness of this, consider a template like `\u003cmy-comp applied-dir>` that uses the directives `MyComp`, `AppliedDir`, and an implicitly loaded directive `ImplicitDir`. The compiler's indexer module will index the template and record an element identifier that looks something like\r\n\r\n```typescript\r\n{\r\n name: 'my-comp',\r\n span: ...,\r\n attributes: [ { name: 'applied-dir', span: ... } ],\r\n usedDirectives: [ MyComp, AppliedDir, ImplicitDir ],\r\n}\r\n```\r\n\r\nA source code indexer implementation can then use this information to generate useful references, like xreferencing `my-comp` to the `MyComp` class declaration, `applied-dir` to the `AppliedDir` class declaration, and adding an implicit reference of all three used directives on `my-comp`.\r\n\r\n### Alternatives\r\n\r\n- Do not record attributes separately; pass the entire element tag source code as the element identifier name instead.\r\n - __advantages__: less work for the compiler's indexing module.\r\n - __disadvantages__: an indexer implementation now has to write an HTML parser to discern attributes on the element.\r\n- Perform the linking of attributes to the directives that match it in the compiler.\r\n - __advantages__: less work for an indexer implementation\r\n - __disadvantages__: directives are applied to an element, not an attribute, so such an implementation would be needlessly complicated. Furthermore, it is not necessarily the job of the compiler's semantic analysis API to make decisions about what spans of text reference one another, especially in ambiguous cases like the one presented here - that should be on the indexer implementation.","author":{"url":"https://github.com/ayazhafiz","@type":"Person","name":"ayazhafiz"},"datePublished":"2019-06-26T21:09:38Z","url":"https://github.com/angular/angular/issues/31299"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:26e721f1-bfea-de11-3c6f-9acd2009cca0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B562:96DDF:172AA9D:1D58158:6B013523 |
| html-safe-nonce | e44b3924a015757d5b11ea292882e37f172a5b52a129c4010e41c3c4179ee779 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTYyOjk2RERGOjE3MkFBOUQ6MUQ1ODE1ODo2QjAxMzUyMyIsInZpc2l0b3JfaWQiOiI2NTQ5NjkyMzA2MzMxNjEyNDUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 632ec9d007a6cc77adef00468ca6770d7078663becf944130ee949fa3908ad45 |
| hovercard-subject-tag | issue:461182837 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/31299/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36833a9f74a8e1615c11f231c7e22c966cc54b04ba5bffc388e309248128fd99/angular/angular/issues/31299 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36833a9f74a8e1615c11f231c7e22c966cc54b04ba5bffc388e309248128fd99/angular/angular/issues/31299 |
| og:image:alt | @alxhub and I recently discussed how best to implement indexing template elements in the Ngtsc indexing module. I'm dumping the key points of that discussion here for future reference and discussio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ayazhafiz |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width