Title: Attrs initialization without `@attr` decorator · Issue #207 · github/catalyst · GitHub
Open Graph Title: Attrs initialization without `@attr` decorator · Issue #207 · github/catalyst
X Title: Attrs initialization without `@attr` decorator · Issue #207 · github/catalyst
Description: Hi there 😄 After upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by initializeAttrs(). I started digging and stumbled upon this piece of logic introduced in #191: catalyst/src/attr.ts Line 39 in a8fb...
Open Graph Description: Hi there 😄 After upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by initializeAttrs(). I started digging and stumbled upon this piece of logic introduced in #1...
X Description: Hi there 😄 After upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by initializeAttrs(). I started digging and stumbled upon this piece of logic introduced in #1...
Opengraph URL: https://github.com/github/catalyst/issues/207
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Attrs initialization without `@attr` decorator","articleBody":"Hi there 😄 \r\n\r\nAfter upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by `initializeAttrs()`. I started digging and stumbled upon this piece of logic introduced in #191:\r\n\r\nhttps://github.com/github/catalyst/blob/a8fb3ba59a4ac258d0fe64a50ecd3b6997f5f016/src/attr.ts#L39\r\n\r\nIt prevents `initializeAttrs()` from doing anything the second time around, thus skipping the manual initialization of attributes. Also, it seems like this change was one of the main things addressed by the above-mentioned PR.\r\n\r\nSo, what would be the correct way now to initialize the attributes without the `@attr` decorator?\r\n\r\nThanks!\r\n\r\n---\r\n\r\n**Example**\r\n\r\n```html\r\n\u003cscript\u003e\r\n class InfoMessage extends HTMLElement {\r\n open = true\r\n\r\n connectedCallback() {\r\n initializeAttrs(this, ['open'])\r\n }\r\n }\r\n\r\n controller(InfoMessage)\r\n\u003c/script\u003e\r\n\r\n\u003cinfo-message data-open=\"false\"\u003e\u003c/info-message\u003e\r\n```\r\n\r\n1. `controller(InfoMessage)` wraps original `connectedCallback()` and calls:\r\n\r\nhttps://github.com/github/catalyst/blob/a8fb3ba59a4ac258d0fe64a50ecd3b6997f5f016/src/core.ts#L14\r\n\r\n2. `InfoMessage` is marked as `initialized` (`attrs.ts`):\r\n\r\nhttps://github.com/github/catalyst/blob/a8fb3ba59a4ac258d0fe64a50ecd3b6997f5f016/src/attr.ts#L40\r\n\r\n3. The original `connectedCallback()` is executed, but `initializeAttrs()` would hit that early-return condition.\r\n4. `this.open` is stuck in its default state (`true`) 😔","author":{"url":"https://github.com/kristoforsalmin","@type":"Person","name":"kristoforsalmin"},"datePublished":"2022-04-29T11:50:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/207/catalyst/issues/207"}
| 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:8387fe57-ca48-8d91-dcce-ef2e426e0117 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB90:3BEA31:1891C50:214FCDA:6A62EB70 |
| html-safe-nonce | 1f07e50ca8e149f2a26fd4c0ca66e09043e79c79a06e749f1f0b8fa98a9a73c4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjkwOjNCRUEzMToxODkxQzUwOjIxNEZDREE6NkE2MkVCNzAiLCJ2aXNpdG9yX2lkIjoiODA4OTU2NDEzMzgxNjM0OTI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8d3d17353e337f0dfc1ea45e49446507f8dcd8cc14458d94d4b58c7299a08841 |
| hovercard-subject-tag | issue:1220626131 |
| 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/github/catalyst/207/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f7fe3431e1fb296f5ea45c7bc04f07192880f6112ff2cf1e43b67d03df684d33/github/catalyst/issues/207 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f7fe3431e1fb296f5ea45c7bc04f07192880f6112ff2cf1e43b67d03df684d33/github/catalyst/issues/207 |
| og:image:alt | Hi there 😄 After upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by initializeAttrs(). I started digging and stumbled upon this piece of logic introduced in #1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kristoforsalmin |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| go-import | github.com/github/catalyst git https://github.com/github/catalyst.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 240087376 |
| octolytics-dimension-repository_nwo | github/catalyst |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 240087376 |
| octolytics-dimension-repository_network_root_nwo | github/catalyst |
| 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 | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width