René's URL Explorer Experiment


Title: Support for dynamic Angular Elements / Webcomponents (with Renderers) · Issue #35328 · angular/angular · GitHub

Open Graph Title: Support for dynamic Angular Elements / Webcomponents (with Renderers) · Issue #35328 · angular/angular

X Title: Support for dynamic Angular Elements / Webcomponents (with Renderers) · Issue #35328 · angular/angular

Description: 🚀 feature request Relevant Package The functionality relates to the @angular/platform-browser package as this is the package which implements DomRendererFactory2 and DefaultDomRenderer2 Description Angular Elements and Webcomponents in g...

Open Graph Description: 🚀 feature request Relevant Package The functionality relates to the @angular/platform-browser package as this is the package which implements DomRendererFactory2 and DefaultDomRenderer2 Description...

X Description: 🚀 feature request Relevant Package The functionality relates to the @angular/platform-browser package as this is the package which implements DomRendererFactory2 and DefaultDomRenderer2 Description...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support for dynamic Angular Elements / Webcomponents (with Renderers)","articleBody":"# 🚀 feature request\r\n\r\n### Relevant Package\r\nThe functionality relates to the `@angular/platform-browser` package as this is the package which implements `DomRendererFactory2` and `DefaultDomRenderer2`\r\n\r\n\r\n### Description\r\nAngular Elements and Webcomponents in general represent great solution for various [real world use cases](https://angular-extensions.github.io/elements/#/docs/use-cases#sub-applications) like...\r\n* sub-applications - ability to deploy library  independently which will update all consumers without need to rebuild these consumer SPAs because lib is only referenced by url (as Angular Element bundle)\r\n* microfrontends ( runtime-configurable )\r\n\r\nUsual approach to consuming Angular Elements and Web components leaves us with 2 options:\r\n1. eager loading + standard Angular template binding `\u003csome-element [prop]=\"value\">`\r\n2. lazy loading + imperative component creation and props / event binding `document.createElement('some-element');` ...\r\n\r\nThe library `@angular-extensions/elements` solves this by enabling both **lazy loading** and **standard Angular template binding** `\u003csome-element *axLazyElement=\"bundle.js\" [prop]=\"value\">` and this works with both ViewEngine and IVY...\r\n\r\n### Dynamic element use case\r\nIn previous section we're committing to element being `\u003csome-element>` by hard-coding it into template of the consumer Angular component. What if we wanted to support loading element configuration at runtime (eg from backend) to enable fully dynamic microfrontends?\r\n\r\nAs it turns out this works too (at least for the ViewEngine) so it is possible to write `\u003cax-lazy-element *axLazyElementDynamic=\"'some-element'; url: 'bundle.js'\" [prop]=\"value\">\u003c/ax-lazy-element>`.\r\nThe bundle will be lazy loaded, and then the element will be rendered as `\u003csome-element>`.\r\nThe only thing needed to do that is to override value of the `tagName` in the `TemplateRef` of the `*axLazyElemendDynamic` directive and Angular will render desired element supporting our use case.\r\n\r\nNow this does NOT work with IVY since in IVY template is an function. \r\nRob @robwormald gave me hint that it should be possible to override `Renderer` (or use custom) to hook into rendering and override element there.\r\n\r\n### The Issue\r\nIt is possible to achieve that with render BUT:\r\n* currently both `DomRendererFactory2` and `DefaultDomRenderer2` are private so it is NOT possible to extend them and hence I would need to re-implement the whole renderer which sounds pretty excessive and hard to maintain\r\n* PLUS as far as I am aware the render API changed [older NRWL article](https://blog.nrwl.io/experiments-with-angular-renderers-c5f647d4fd9e) so there is no more `RootRenderer` ?\r\n\r\n### Current [solution](https://github.com/angular-extensions/elements/blob/master/projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.ts#L71-L80)\r\nPlay around with **live demo** (which serves both lib and demo and rebuilds on changes to any of them) using this one liner `git clone https://github.com/angular-extensions/elements.git elements && cd elements && npm ci && npm start` once it runs, please navigate to `Examples > Dynamic` to see it in action.\r\n\r\n\r\n```typescript\r\n@Directive({\r\n  selector: '[axLazyElementDynamic]'\r\n})\r\nexport class LazyElementDynamicDirective implements OnInit {\r\n  @Input('axLazyElementDynamic') tag: string;\r\n  @Input('axLazyElementDynamicUrl') url: string;\r\n\r\n  constructor(\r\n    @Inject(DOCUMENT) private document: Document,\r\n    private renderer: Renderer2,\r\n    private cdr: ChangeDetectorRef,\r\n    private template: TemplateRef\u003cany>,\r\n    private elementsLoaderService: LazyElementsLoaderService\r\n  ) {}\r\n\r\n  ngOnInit() {\r\n    this.elementsLoaderService\r\n      .loadElement(this.url)\r\n      .then(() => {\r\n        this.vcr.clear();\r\n        const originalCreateElement = this.renderer.createElement;\r\n        this.renderer.createElement = (name: string, namespace: string) => { // temporary override \r\n          if (name === 'ax-lazy-element') {\r\n            name = this.tag;\r\n          }\r\n          return this.document.createElement(name);\r\n        };\r\n        this.vcr.createEmbeddedView(this.template);\r\n        this.renderer.createElement = originalCreateElement;\r\n        this.cdr.markForCheck();\r\n      })\r\n  }\r\n}\r\n```\r\n \r\n\r\n\r\n### Describe the solution you'd like\r\nProbably being able to easily extend default renderer and being able to register it like we're used to with interceptors or control value accessors.\r\n\r\nI would like to give people option (or do it for them behind the scenes) to do\r\n```typescript\r\n@NgModule({\r\n   import: [LazyElementsModule],\r\n  providers: [{ provide: Renderer, useClass: LazyElementsRenderer }]\r\n})\r\nexport class AppModule {}\r\n\r\nexport class LazyElementsRenderer  extends DefaultDomRenderer2  {\r\n  \r\n constructor(...args) {\r\n     this.super(...args);\r\n  }\r\n\r\n  createElement() {\r\n      // override logic and change tag name if necessary\r\n  }\r\n}\r\n```\r\n\r\n\r\n### Describe alternatives you've considered\r\nI spent quite some time trying to override tag inside of template function without success \r\n","author":{"url":"https://github.com/tomastrajan","@type":"Person","name":"tomastrajan"},"datePublished":"2020-02-11T09:33:50Z","url":"https://github.com/angular/angular/issues/35328"}

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:c167493b-f2fb-9365-b4a2-21a2f8603267
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDF7E:29FFA9:166EFC8:1C71A24:6B0133C5
html-safe-nonce282796e40a4407c8f3aa7e19e5a705b3cc335dc90204b800c8b7f8d581b543ab
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjdFOjI5RkZBOToxNjZFRkM4OjFDNzFBMjQ6NkIwMTMzQzUiLCJ2aXNpdG9yX2lkIjoiNDY0MzIwMjE5ODE4MjkwMDY3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2ba4cf61c53bbf52a2d7954454b9be047c14663964f1cdde54f6dfa7f1baeb71
hovercard-subject-tagissue:563075887
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/35328/issue_layout
twitter:imagehttps://opengraph.githubassets.com/90b04e8916eb0cddd604802448480acd6236946ad5d5bd0e8b645ee9bca14202/angular/angular/issues/35328
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/90b04e8916eb0cddd604802448480acd6236946ad5d5bd0e8b645ee9bca14202/angular/angular/issues/35328
og:image:alt🚀 feature request Relevant Package The functionality relates to the @angular/platform-browser package as this is the package which implements DomRendererFactory2 and DefaultDomRenderer2 Description...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametomastrajan
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/35328#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F35328
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%2F35328
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/35328
Reloadhttps://github.com/angular/angular/issues/35328
Reloadhttps://github.com/angular/angular/issues/35328
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues836 (836)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/35328
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/35328
Support for dynamic Angular Elements / Webcomponents (with Renderers)https://github.com/angular/angular/issues/35328#top
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 11, 2020https://github.com/angular/angular/issues/35328#issue-563075887
real world use caseshttps://angular-extensions.github.io/elements/#/docs/use-cases#sub-applications
@robwormaldhttps://github.com/robwormald
older NRWL articlehttps://blog.nrwl.io/experiments-with-angular-renderers-c5f647d4fd9e
solutionhttps://github.com/angular-extensions/elements/blob/master/projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.ts#L71-L80
https://github.com/flash-me
flash-mehttps://github.com/flash-me
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585103900
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585106571
@flash-mehttps://github.com/flash-me
https://github.com/flash-me
flash-mehttps://github.com/flash-me
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585108465
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585111385
@flash-mehttps://github.com/flash-me
https://github.com/flash-me
flash-mehttps://github.com/flash-me
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585113080
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585114719
@flash-mehttps://github.com/flash-me
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585117150
@flash-mehttps://github.com/flash-me
https://github.com/flash-me
flash-mehttps://github.com/flash-me
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585359867
And really performant by the way.https://mobile.twitter.com/simsek_dev/status/1168163228574277639
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 12, 2020https://github.com/angular/angular/issues/35328#issuecomment-585378111
@flash-mehttps://github.com/flash-me
karahttps://github.com/kara
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
on Feb 13, 2020https://github.com/angular/angular/issues/35328#event-3033015953
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Feb 13, 2020https://github.com/angular/angular/issues/35328#event-3033016001
mheveryhttps://github.com/mhevery
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
on Mar 5, 2020https://github.com/angular/angular/issues/35328#event-3103230585
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Mar 5, 2020https://github.com/angular/angular/issues/35328#event-3103230637
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/35328#event-4843655328
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Jun 4, 2021https://github.com/angular/angular/issues/35328#issuecomment-854790978
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Jun 4, 2021https://github.com/angular/angular/issues/35328#issuecomment-854811406
current implhttps://github.com/angular-extensions/elements/blob/master/projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.ts#L80-L87
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Jun 25, 2021https://github.com/angular/angular/issues/35328#issuecomment-868527704
communityhttps://angular.io/resources?category=community
packagehttps://angular.io/guide/creating-libraries
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
angular-robothttps://github.com/apps/angular-robot
insufficient voteshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22insufficient%20votes%22
on Jun 25, 2021https://github.com/angular/angular/issues/35328#event-4940273130
https://github.com/jpzwarte
jpzwartehttps://github.com/jpzwarte
on Nov 8, 2021https://github.com/angular/angular/issues/35328#issuecomment-963085614
@tomastrajanhttps://github.com/tomastrajan
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Nov 8, 2021https://github.com/angular/angular/issues/35328#issuecomment-963088480
@jpzwartehttps://github.com/jpzwarte
https://github.com/jpzwarte
jpzwartehttps://github.com/jpzwarte
on Nov 8, 2021https://github.com/angular/angular/issues/35328#issuecomment-963091962
https://github.com/jpzwarte
jpzwartehttps://github.com/jpzwarte
on Nov 8, 2021https://github.com/angular/angular/issues/35328#issuecomment-963092746
https://github.com/jpzwarte
jpzwartehttps://github.com/jpzwarte
on Nov 8, 2021https://github.com/angular/angular/issues/35328#issuecomment-963101044
dylhunnhttps://github.com/dylhunn
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
insufficient voteshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22insufficient%20votes%22
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on Sep 29, 2022https://github.com/angular/angular/issues/35328#event-7491010015
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/35328
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/35328
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%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.