Title: Using multiple Angular Elements, ngDoBootstrap runs twice, breaking with CustomElementRegistry · Issue #23732 · angular/angular · GitHub
Open Graph Title: Using multiple Angular Elements, ngDoBootstrap runs twice, breaking with CustomElementRegistry · Issue #23732 · angular/angular
X Title: Using multiple Angular Elements, ngDoBootstrap runs twice, breaking with CustomElementRegistry · Issue #23732 · angular/angular
Description: I'm submitting a bug report. Edit: screenshots of this issue are posted below, here Using multiple Web Components built from Angular Elements breaks the consuming application. I have the following three repositories: example-angular-elme...
Open Graph Description: I'm submitting a bug report. Edit: screenshots of this issue are posted below, here Using multiple Web Components built from Angular Elements breaks the consuming application. I have the following ...
X Description: I'm submitting a bug report. Edit: screenshots of this issue are posted below, here Using multiple Web Components built from Angular Elements breaks the consuming application. I have the follow...
Opengraph URL: https://github.com/angular/angular/issues/23732
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using multiple Angular Elements, ngDoBootstrap runs twice, breaking with CustomElementRegistry","articleBody":"## I'm submitting a bug report.\r\n\r\nEdit: [screenshots of this issue are posted below, here](https://github.com/angular/angular/issues/23732#issuecomment-387915011)\r\n\r\nUsing multiple Web Components built from Angular Elements breaks the consuming application.\r\n\r\nI have the following three repositories:\r\n1. [example-angular-elments-app](https://github.com/METACEO/example-angular-elments-app) - the consuming application\r\n2. [example-angular-elments-component-box](https://github.com/METACEO/example-angular-elments-component-box) - outputs the box WebComponent\r\n3. [example-angular-elments-component-button](https://github.com/METACEO/example-angular-elments-component-button) - outputs the button WebComponent\r\n\r\nBoth components (2 and 3) build the files found in the consuming app's [src/assets/elements](https://github.com/METACEO/example-angular-elments-app/tree/master/src/assets/elements) folder.\r\n\r\nYou should receive the same error in your console (or something similar, depending on which component you load dynamically first) after following the reproduction steps further below.\r\n```\r\nexample-angular-elements-component-box.js:4 ngDoBootstrap example-angular-elements-component-box\r\nexample-angular-elements-component-box.js:4 ngDoBootstrap example-angular-elements-component-box\r\nexample-angular-elements-component-box.js:4 ERROR DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry\r\n at ze.define (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:1:12582)\r\n at ze.value (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:3:33689)\r\n at ze.define (http://localhost:4200/assets/elements/example-angular-elements-component-button.js:1:12582)\r\n at ze.value (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:3:33689)\r\n at e.ngDoBootstrap (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:4:121355)\r\n at e._moduleDoBootstrap (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:4:37688)\r\n at http://localhost:4200/assets/elements/example-angular-elements-component-box.js:4:36842\r\n at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:4200/polyfills.js:2704:26)\r\n at Object.onInvoke (http://localhost:4200/assets/elements/example-angular-elements-component-box.js:4:30158)\r\n at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:4200/polyfills.js:2703:32)\r\n```\r\nAfter including the second Angular Element WebComponent, you'll see a line like `example-angular-elements-component-box.js:4 ngDoBootstrap example-angular-elements-component-box` logged twice, illustrating that component bootstrapping twice, likely causing the `CustomElementRegistry` error.\r\n\r\n## Expected behavior\r\nThe consuming application does not break when consuming multiple WebComponents built from Angular Elements.\r\nThe `ngDoBoostrap` method is not called twice, or at least checks for component registration.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n1. Clone the [example-angular-elments-app](https://github.com/METACEO/example-angular-elments-app) Angular 6 project.\r\n2. Run `npm i`\r\n3. Run `npm start`\r\n4. Open `http://localhost:4200` and open the developer console.\r\n5. Click on one of the buttons to load a component.\r\n6. Click on the other button to load the other component.\r\n7. View the console and see how the component that was loaded first runs its' ngDoBootstrap method again, before breaking the page.\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\n[xxx example-angular-elments-app]$ npm run ng -- -v\r\n\r\n> example-angular-elments-app@0.0.0 ng /home/xxx/WebstormProjects/example-angular-elments-app\r\n> ng \"-v\"\r\n\r\n\r\n _ _ ____ _ ___\r\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\r\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\r\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\r\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\r\n |___/\r\n \r\n\r\nAngular CLI: 6.0.0\r\nNode: 8.11.1\r\nOS: linux x64\r\nAngular: 6.0.0\r\n... animations, cdk, cli, common, compiler, compiler-cli, core\r\n... forms, http, language-service, material, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.6.0\r\n@angular-devkit/build-angular 0.6.0\r\n@angular-devkit/build-optimizer 0.6.0\r\n@angular-devkit/core 0.6.0\r\n@angular-devkit/schematics 0.6.0\r\n@ngtools/webpack 6.0.0\r\n@schematics/angular 0.6.0\r\n@schematics/update 0.6.0\r\nrxjs 6.1.0\r\ntypescript 2.7.2\r\nwebpack 4.6.0\r\n\r\nBrowser:\r\n- [x] Chromium Web Browser (desktop) Version 65.0.3325.181 (Developer Build) Fedora Project (64-bit)\r\n \r\nFor Tooling issues:\r\n- Node version: 5.6.0\r\n- NPM version: 5.6.0\r\n- Platform: Linux\r\n\u003c/code>\u003c/pre>","author":{"url":"https://github.com/TheSpiciestDev","@type":"Person","name":"TheSpiciestDev"},"datePublished":"2018-05-07T00:07:03Z","url":"https://github.com/angular/angular/issues/23732"}
| 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:5fe14b60-1df2-6196-53d1-10c6e898d99e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7B4:399E4B:158FC7D:1CA1358:6B0130A4 |
| html-safe-nonce | 8d5d8f7b6e69bbccf30a269bf01f92064f2244ad929eef75465dccab1f090b19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0I0OjM5OUU0QjoxNThGQzdEOjFDQTEzNTg6NkIwMTMwQTQiLCJ2aXNpdG9yX2lkIjoiOTEyMTgzNzE4MjExNjUwNzgxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4a957c207201076b39bb381e0024eb5d151dbe2a3a1ce202b12cb1b319466c20 |
| hovercard-subject-tag | issue:320641313 |
| 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/23732/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f7161c80bd5f5e5d2f4863a01cf5060d10f8c0a4f0c0d85f87c9bc60f5fdea4d/angular/angular/issues/23732 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f7161c80bd5f5e5d2f4863a01cf5060d10f8c0a4f0c0d85f87c9bc60f5fdea4d/angular/angular/issues/23732 |
| og:image:alt | I'm submitting a bug report. Edit: screenshots of this issue are posted below, here Using multiple Web Components built from Angular Elements breaks the consuming application. I have the following ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TheSpiciestDev |
| 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