You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b61ba08
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/_guide/attrs.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,7 @@ When an element gets connected to the DOM, the attr is initialized. During this
151
151
- When connected, if the element _does not_ have a matching attribute, the default _is_ applied.
152
152
- When connected, if the element _does_ have a matching attribute, the default _is not_ applied, the property will be assigned to the value of the attribute instead.
153
153
- Field and `accessor` attrs are initialized first, in the order they're registered. Getter and setter attrs come next, starting with those that have a matching attribute, so a getter's default can read the other attrs' values.
154
+
- With legacy decorators, Catalyst can't tell an `accessor` from a getter and setter you wrote, so only a getter without a setter counts as a getter attr. Any attr with a setter initializes in registration order, as in earlier versions.
154
155
- Standard decorators register `accessor` attrs before field attrs, whatever order they're declared in. To initialize attrs in declaration order, as legacy decorators do, decorate fields, not accessors: `@attr name!: string`.
Copy file name to clipboardExpand all lines: docs/_guide/decorators.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,9 @@ TypeScript 5.0+ and SWC (`decoratorVersion: "2023-11"`) compile standard (TC39)
102
102
103
103
Catalyst's member decorators only support public, non-static members. `@controller` (and `@register`) define the element once static fields such as `observedAttributes` and `attrPrefix` are assigned, the same as with legacy decorators.
104
104
105
-
Withoutanexplicitname, `@controller`derivestheelementnamefromtheclassname, sotheclassnamemustsurviveyourbuild. Forexample, ifTypeScriptemitsstandarddecoratorsasES2022andesbuildthenlowersthatoutputtoanoldertarget, esbuildrenamestheclassunlessyouturnon [`keepNames`](https://esbuild.github.io/api/#keep-names). Passing the tag name, as in `@controller('hello-world')`, avoids this. See [build considerations]({{ site.baseurl }}/guide/you-will-need#build-considerations).
105
+
Withoutanexplicitname, `@controller`derivestheelementnamefromtheclassname, sotheclassnamemustsurviveyourbuild. Withstandarddecorators, TypeScript'soutputdeclarestheclasstwiceunderthesamename, andesbuildrenamesoneoftheminanytransformorbundle, evenatthesametarget. `HelloWorldElement` thenbecomes `HelloWorldElement2`, andtheelementisdefinedas `hello-world-element2` withoutanerror. esbuild's [`keepNames`](https://esbuild.github.io/api/#keep-names) keeps the name from version 0.18.2. Before that, `@controller` sees an empty or internal name, such as `_this`, and defining the element throws. Minifiers rename classes too.
106
+
107
+
Passingthetagname, asin `@controller('hello-world')`, avoidsallofthis, andwerecommenditwithstandarddecorators. See [buildconsiderations]({{ site.baseurl }}/guide/you-will-need#build-considerations).
Copy file name to clipboardExpand all lines: docs/_guide/you-will-need.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ The preferred way to handle this is to disable renaming class names in your buil
32
32
33
33
When using ESBuild you can turn off all class and function name minification with the [`keep_names`](https://esbuild.github.io/api/#keep-names) option. Setting this to `true` in your build will opt-out all classes and all functions from minification.
34
34
35
+
With [standard decorators]({{ site.baseurl }}/guide/decorators#standard-decorators), esbuild renames classes in TypeScript's output even without minification, and `keep_names` only prevents it from esbuild 0.18.2. Passing a tag name to `@controller` works with every build tool.
0 commit comments