Skip to content

Commit b5ed465

Browse files
authored
Merge branch 'main' into campaign-fix-5-4-3
2 parents 201fdab + ceddf6e commit b5ed465

File tree

13 files changed

+7273
-3164
lines changed

13 files changed

+7273
-3164
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node/.devcontainer/base.Dockerfile
22

33
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
4-
ARG VARIANT="16"
4+
ARG VARIANT="24"
55
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
66

77
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local arm64/Apple Silicon.
10-
"args": { "VARIANT": "16" }
10+
"args": { "VARIANT": "24" }
1111
},
1212

1313
// Set *default* container specific settings.json values on container create.

.github/workflows/lighthouse.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Checkout the project
1313
uses: actions/checkout@v3
1414

15-
- name: Use Node.js 16.x (LTS)
15+
- name: Use Node.js 24.x (LTS)
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: 16.x
18+
node-version: 24.x
1919
cache: 'npm'
2020
- run: npm ci
2121

.github/workflows/nodejs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
steps:
1414
- name: Checkout the project
1515
uses: actions/checkout@v3
16-
- name: Use Node.js 16.x (LTS)
16+
- name: Use Node.js 24.x (LTS)
1717
uses: actions/setup-node@v3
1818
with:
19-
node-version: 16.x
19+
node-version: 24.x
2020
cache: 'npm'
2121
- run: npm ci
2222
- name: Lint Codebase

.github/workflows/publish.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ on:
66
release:
77
types: [created]
88

9+
permissions:
10+
contents: read
11+
id-token: write # for provenance and publish access
12+
913
jobs:
1014
publish-npm:
1115
runs-on: ubuntu-latest
1216
steps:
1317
- name: Checkout the project
1418
uses: actions/checkout@v3
15-
- name: Use Node.js 16.x (LTS)
19+
- name: Use Node.js 24.x (LTS)
1620
uses: actions/setup-node@v3
1721
with:
18-
node-version: 16.x
22+
node-version: 24.x
1923
registry-url: https://registry.npmjs.org/
2024
cache: npm
2125
- run: npm ci
2226
- run: npm test
2327
- run: npm version ${TAG_NAME} --git-tag-version=false
2428
env:
2529
TAG_NAME: ${{ github.event.release.tag_name }}
26-
- run: npm whoami; npm publish
27-
env:
28-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
30+
- run: npm publish --provenance

docs/_guide/your-first-component.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ Catalyst will automatically convert the classes name; removing the trailing `Ele
3131

3232
By convention Catalyst controllers end in `Element`; Catalyst will omit this when generating a tag name. The `Element` suffix is _not_ required - just convention. All examples in this guide use `Element` suffixed names.
3333

34+
### Custom Element Names
35+
36+
If you need to use a specific element name that doesn't match your class name (for example, to support minification), you can pass the element name directly to the `@controller` decorator:
37+
38+
```js
39+
import {controller} from '@github/catalyst'
40+
41+
@controller('hello-widget')
42+
class SomeClass extends HTMLElement {
43+
connectedCallback() {
44+
this.innerHTML = 'Hello from hello-widget!'
45+
}
46+
}
47+
```
48+
<br>
49+
50+
This will register the element as `<hello-widget>` regardless of the class name. This is particularly useful when:
51+
- Your production build minifies class names
52+
- You want explicit control over the element name
53+
- The class name doesn't follow the naming pattern required for automatic naming
54+
3455
{% capture callout %}
3556
Remember! A class name _must_ include at least two CamelCased words (not including the `Element` suffix). One-word elements will raise exceptions. Example of good names: `UserListElement`, `SubTaskElement`, `PagerContainerElement`
3657
{% endcapture %}{% include callout.md %}
@@ -40,8 +61,8 @@ Remember! A class name _must_ include at least two CamelCased words (not includi
4061

4162
The `@controller` decorator ties together the various other decorators within Catalyst, plus a few extra conveniences such as automatically registering the element, which saves you writing some boilerplate that you'd otherwise have to write by hand. Specifically the `@controller` decorator:
4263

43-
- Derives a tag name based on your class name, removing the trailing `Element` suffix and lowercasing all capital letters, separating them with a dash.
44-
- Calls `window.customElements.define` with the newly derived tag name and your class.
64+
- Derives a tag name based on your class name, removing the trailing `Element` suffix and lowercasing all capital letters, separating them with a dash. You can optionally provide a custom element name as a parameter (e.g., `@controller('my-element')`).
65+
- Calls `window.customElements.define` with the newly derived (or provided) tag name and your class.
4566
- Calls `defineObservedAttributes` with the class to add map any `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
4667
- Injects the following code inside of the `connectedCallback()` function of your class:
4768
- `bind(this)`; ensures that as your element connects it picks up any `data-action` handlers. See [actions]({{ site.baseurl }}/guide/actions) for more on this.
@@ -79,4 +100,16 @@ controller(
79100
}
80101
)
81102
```
103+
104+
Or with a custom element name:
105+
106+
```js
107+
import {controller} from '@github/catalyst'
108+
109+
controller('my-custom-name')(
110+
class HelloWorldElement extends HTMLElement {
111+
//...
112+
}
113+
)
114+
```
82115
<br>

0 commit comments

Comments
 (0)