Skip to content

Commit ea5d2b6

Browse files
authored
Merge branch 'main' into allow-hmr-plugins
2 parents 93d4035 + ec24198 commit ea5d2b6

15 files changed

Lines changed: 342 additions & 470 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node/.devcontainer/base.Dockerfile
2+
3+
# [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"
5+
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
6+
7+
# [Optional] Uncomment this section to install additional OS packages.
8+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9+
# && apt-get -y install --no-install-recommends <your-package-list-here>
10+
11+
# [Optional] Uncomment if you want to install an additional version of node using nvm
12+
# ARG EXTRA_NODE_VERSION=10
13+
# RUN su node -c "source/usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
14+
15+
# [Optional] Uncomment if you want to install more global node modules
16+
# RUN su node -c "npm install -g <your-package-list-here>"

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node
3+
{
4+
"name": "Node.js",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
8+
// Append -bullseye or -buster to pin to an OS version.
9+
// Use -bullseye variants on local arm64/Apple Silicon.
10+
"args": { "VARIANT": "16" }
11+
},
12+
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {},
15+
16+
// Add the IDs of extensions you want installed when the container is created.
17+
"extensions": [
18+
"dbaeumer.vscode-eslint"
19+
],
20+
21+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
22+
// "forwardPorts": [],
23+
24+
// Use 'postCreateCommand' to run commands after the container is created.
25+
// "postCreateCommand": "yarn install",
26+
27+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
28+
"remoteUser": "node",
29+
"features": {
30+
"git": "latest"
31+
}
32+
}

.github/workflows/nodejs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ jobs:
2626
node-version: 13.11.0
2727
- name: Install dependencies
2828
run: npm i
29+
- name: Lint Codebase
30+
run: npm run lint
2931
- name: Run Node.js Tests
3032
run: npm run test
33+
- name: Check Bundle Size
34+
run: npm run size

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @github/ui-frameworks-reviewers
1+
* @github/web-systems-reviewers

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'",
3131
"presize": "npm run build",
3232
"size": "size-limit",
33-
"pretest": "npm run size && npm run lint",
3433
"test": "web-test-runner test/* --node-resolve"
3534
},
3635
"prettier": "@github/prettier-config",

src/attr.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {CustomElement} from './custom-element.js'
2+
import {dasherize} from './dasherize.js'
23
import {meta} from './core.js'
34

45
const attrKey = 'attr'
@@ -79,9 +80,7 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
7980
}
8081
}
8182

82-
function attrToAttributeName(name: string): string {
83-
return `data-${name.replace(/([A-Z]($|[a-z]))/g, '-$1')}`.replace(/--/g, '-').toLowerCase()
84-
}
83+
const attrToAttributeName = (name: string) => `data-${dasherize(name)}`
8584

8685
export function defineObservedAttributes(classObject: CustomElement): void {
8786
let observed = classObject.observedAttributes || []

src/dasherize.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const dasherize = (str: unknown): string =>
2+
String(str)
3+
.replace(/([A-Z]($|[a-z]))/g, '-$1')
4+
.replace(/--/g, '-')
5+
.replace(/^-|-$/, '')
6+
.toLowerCase()

src/register.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {CustomElement} from './custom-element.js'
2+
import {dasherize} from './dasherize.js'
23

34
/**
45
* Register the controller as a custom element.
@@ -8,10 +9,7 @@ import type {CustomElement} from './custom-element.js'
89
* Example: HelloController => hello-controller
910
*/
1011
export function register(classObject: CustomElement): void {
11-
const name = classObject.name
12-
.replace(/([A-Z]($|[a-z]))/g, '-$1')
13-
.replace(/(^-|-Element$)/g, '')
14-
.toLowerCase()
12+
const name = dasherize(classObject.name).replace(/-element$/, '')
1513

1614
try {
1715
window.customElements.define(name, classObject)

0 commit comments

Comments
 (0)