Title: Regression Ivy with ComponentFactory · Issue #31785 · angular/angular · GitHub
Open Graph Title: Regression Ivy with ComponentFactory · Issue #31785 · angular/angular
X Title: Regression Ivy with ComponentFactory · Issue #31785 · angular/angular
Description: 🐞 bug report Tbh: I didn't search if this was already known (no idea how I would have found it 😅) Affected Package The issue is caused by package @angular/core Is this a regression? This works without Ivy enabled. Description I was tryin...
Open Graph Description: 🐞 bug report Tbh: I didn't search if this was already known (no idea how I would have found it 😅) Affected Package The issue is caused by package @angular/core Is this a regression? This works with...
X Description: 🐞 bug report Tbh: I didn't search if this was already known (no idea how I would have found it 😅) Affected Package The issue is caused by package @angular/core Is this a regression? This works ...
Opengraph URL: https://github.com/angular/angular/issues/31785
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression Ivy with ComponentFactory","articleBody":"# 🐞 bug report\r\n\r\nTbh: I didn't search if this was already known (no idea how I would have found it 😅)\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/core\r\n\r\n### Is this a regression?\r\n\r\nThis works without Ivy enabled.\r\n\r\n### Description\r\n\r\nI was trying out Angular Ivy in our codebase. One of the last 'problems' that is really blocking seems to be ['ngx-toastr'](https://github.com/scttcper/ngx-toastr).\r\n\r\nThey dynamically add the [toastr component](https://github.com/scttcper/ngx-toastr/blob/master/src/lib/toastr/toast.component.ts) on runtime in the DOM.\r\n\r\n[Link to code that is responsible for this](https://github.com/scttcper/ngx-toastr/blob/db3e8fefe79dd66f2610b057a762bb0e668ab417/src/lib/portal/dom-portal-host.ts#L32)\r\n\r\nWhen switching to Ivy this code doesn't work anymore:\r\n\r\n```\r\nERROR DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name. at DefaultDomRenderer2.createElement\r\n```\r\n\r\nAfter some debugging I found out that it's because the code that's responsible for retrieving the selector of a component in Ivy doesn't work: [Link](https://github.com/angular/angular/blob/c845a7b887d1a85a89acfe5c62b8829079130af3/packages/core/src/render3/component_ref.ts#L124)\r\n\r\nIn case of the toast component (see link above) it's ['', 'toast-component', '']. As a result the tag name becomes ''. And that explains the error above.\r\n\r\nI cloned ngx-toastr, changed the component name from `[toast-component]` to `toast-component` (removed the brackets). And everything seems to be working. This of course changes the result from a div with as attribute 'toast-component' to a custom component with as selector 'toast-component'.\r\n\r\nTL;DR: Dynamically generating components on runtime with Ivy doesn't work when using attribute notation.\r\n\r\n## 🔬 Minimal Reproduction\r\n\r\nUse ngx-toastr with Ivy enabled.\r\nIf more time, I'll create a stackblitz.\r\n\r\n## 🔥 Exception or Error\r\n\r\n```\r\nERROR DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name. \r\nat DefaultDomRenderer2.createElement (http://localhost:4200/vendor.js:82322:25) \r\nat elementCreate (http://localhost:4200/vendor.js:53703:32) \r\nat ComponentFactory$1.create (http://localhost:4200/vendor.js:67815:13) \r\nat DomPortalHost.attachComponentPortal (http://localhost:4200/vendor.js:94547:41) \r\nat DomPortalHost.attach (http://localhost:4200/vendor.js:94505:21) at OverlayRef.attach (http://localhost:4200/vendor.js:94629:33) \r\nat ToastrService._buildNotification (http://localhost:4200/vendor.js:94955:35) \r\nat ToastrService._preBuildNotification (http://localhost:4200/vendor.js:94921:21) \r\nat ToastrService.success\r\n```\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\nAngular CLI: 8.2.0-next.1\r\nNode: 12.6.0\r\nOS: win32 x64\r\nAngular:\r\n...\r\n\r\nPackage Version\r\n------------------------------------------------------\r\n@angular-devkit/architect 0.802.0-next.1\r\n@angular-devkit/core 8.2.0-next.1\r\n@angular-devkit/schematics 8.2.0-next.1\r\n@schematics/angular 8.2.0-next.1\r\n@schematics/update 0.802.0-next.1\r\nrxjs 6.4.0\r\n\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\nCauses https://github.com/scttcper/ngx-toastr/issues/686\r\n","author":{"url":"https://github.com/ErazerBrecht","@type":"Person","name":"ErazerBrecht"},"datePublished":"2019-07-22T19:11:06Z","url":"https://github.com/angular/angular/issues/31785"}
| 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:6643aa94-3554-2504-45b2-27aded9149da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C19C:361639:164115C:1DAC484:6B013F04 |
| html-safe-nonce | d2a059b5ead0c8a78841c131d1716ccc2371903adf27355e70f4f5aa629122bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTlDOjM2MTYzOToxNjQxMTVDOjFEQUM0ODQ6NkIwMTNGMDQiLCJ2aXNpdG9yX2lkIjoiNTkyMzgxMDcxMzk3Mjg1MDQzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 86fb68c71b2c9239a5142c084a34c41bfca1cec809162fcd3d10e4f636ae508c |
| hovercard-subject-tag | issue:471264900 |
| 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/31785/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e059d8d099576dce9ecdcf9d4ee9e3262d56f9b4fdf76c75929863f99609540/angular/angular/issues/31785 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e059d8d099576dce9ecdcf9d4ee9e3262d56f9b4fdf76c75929863f99609540/angular/angular/issues/31785 |
| og:image:alt | 🐞 bug report Tbh: I didn't search if this was already known (no idea how I would have found it 😅) Affected Package The issue is caused by package @angular/core Is this a regression? This works with... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ErazerBrecht |
| 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