Title: [feature][@angular/elements] Expose ComponentNgElementStrategy · Issue #33490 · angular/angular · GitHub
Open Graph Title: [feature][@angular/elements] Expose ComponentNgElementStrategy · Issue #33490 · angular/angular
X Title: [feature][@angular/elements] Expose ComponentNgElementStrategy · Issue #33490 · angular/angular
Description: 🚀 feature request Relevant Package @angular/elements Description There is no "easy" way to pass custom lifecycle callbacks for CustomElements. We may pass a custom NgElementStrategyFactory to createCustomElement, but when looking at Comp...
Open Graph Description: 🚀 feature request Relevant Package @angular/elements Description There is no "easy" way to pass custom lifecycle callbacks for CustomElements. We may pass a custom NgElementStrategyFactory to creat...
X Description: 🚀 feature request Relevant Package @angular/elements Description There is no "easy" way to pass custom lifecycle callbacks for CustomElements. We may pass a custom NgElementStrategyFactor...
Opengraph URL: https://github.com/angular/angular/issues/33490
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[feature][@angular/elements] Expose ComponentNgElementStrategy","articleBody":"# 🚀 feature request\r\n\r\n### Relevant Package\r\n@angular/elements\r\n\r\n\r\n### Description\r\nThere is no \"easy\" way to pass custom [lifecycle callbacks](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions) for CustomElements.\r\nWe may pass a custom **NgElementStrategyFactory** to `createCustomElement`, but when looking at [ComponentNgElementStrategy](https://github.com/angular/angular/blob/master/packages/elements/src/component-factory-strategy.ts#L45), this is not something that should be done by the average angular developer.\r\n\r\n### Describe the solution you'd like\r\n1. Suggestion: You may expose **ComponentNgElementStrategy**. That way we could extend it and override the methods + call the super methods.\r\n2. Suggestion: Extend `createCustomElement` to directly pass the **optional** custom callbacks, which in turn are called internally. Maybe an object of: \r\n```ts\r\nexport interface CustomElementCallbacks {\r\n /** When upgraded, its constructor is run, with no arguments */\r\n constructedCallback()?: void;\r\n /** When it becomes connected, its connectedCallback is called, with no arguments */\r\n connectedCallback()?: void;\r\n /** When it becomes disconnected, its disconnectedCallback is called, with no arguments */\r\n disconnectedCallback()?: void;\r\n /** When it is adopted into a new document, its adoptedCallback is called, given the old document and new document as arguments */\r\n adoptedCallback()?: void;\r\n /** \r\n * When any of its attributes are changed, appended, removed, or replaced, \r\n * its attributeChangedCallback is called, given \r\n * the attribute's local name, old value, new value \r\n */\r\n attributeChangedCallback(attrName: string, oldVal?: any, newVal?: any)?: void;\r\n}\r\n```\r\n### Describe alternatives you've considered\r\nJust copy the code from [here](https://github.com/angular/angular/blob/master/packages/elements/src/component-factory-strategy.ts)? (Not thinking about compatibility on version changes, though....)\r\n","author":{"url":"https://github.com/flash-me","@type":"Person","name":"flash-me"},"datePublished":"2019-10-30T09:49:11Z","url":"https://github.com/angular/angular/issues/33490"}
| 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:e92e0332-1e9e-956c-8b72-43134c8f6bfb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9B6:1F2D:BD53B9:EEA936:6B013147 |
| html-safe-nonce | bca092c2648d3498996e6049040f3e0be88d1bf250c4a988e109eb1e5c62a349 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUI2OjFGMkQ6QkQ1M0I5OkVFQTkzNjo2QjAxMzE0NyIsInZpc2l0b3JfaWQiOiIyMzEyNzUxMTQzNzgyMDAzMDE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4d1cb67344bdafa59612c1f8531366a0b8f49401508b4ba2883bfbf397ba2e91 |
| hovercard-subject-tag | issue:514526129 |
| 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/33490/issue_layout |
| twitter:image | https://opengraph.githubassets.com/00239b041cc86f40e722e14f94490a3afba58ebfb113566ac9770e3fdb9c22fa/angular/angular/issues/33490 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/00239b041cc86f40e722e14f94490a3afba58ebfb113566ac9770e3fdb9c22fa/angular/angular/issues/33490 |
| og:image:alt | 🚀 feature request Relevant Package @angular/elements Description There is no "easy" way to pass custom lifecycle callbacks for CustomElements. We may pass a custom NgElementStrategyFactory to creat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | flash-me |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width