Skip to content

Commit

Permalink
add more callouts for the custom element naming reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsender authored and macdonst committed Jun 20, 2023
1 parent dddfea0 commit 0f28b0a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/docs/md/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Your project should now look like this:

```
app
├── elements .......... custom element pure functions
├── elements .......... HTML custom element pure functions
└── pages ............. file-based routing
├── about.html
└── index.html
Expand All @@ -75,7 +75,7 @@ app
Add a [pure function](https://en.wikipedia.org/wiki/Pure_function) that returns an HTML string.
Your function will be passed an object containing an `html` render function for expanding custom elements.

Add a `my-header.mjs` file in the `app/elements/` folder.
Add a `my-header.mjs` file in the `app/elements/` folder. Notice that we're using a two-word-or-more name for our custom element.

The contents of `my-header.mjs` should look like this:

Expand Down
2 changes: 1 addition & 1 deletion app/docs/md/learn/concepts/html/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Enhance single-file components are designed to be used without needing to import

## Naming convention

Per the [spec](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname), custom element tag names are two or more words separated by a dash.
Per the [spec](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname), custom element tag names have two or more words separated by a dash ([MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Web_Components/Using_custom_elements)). So your elements need to look like `<foo-bar>`. `<foo>` won't work.
In your Enhance project the names of the files in your project's `app/elements` file correspond to the tag name of your custom element. Meaning `my-header.mjs` will be authored as `<my-header></my-header>` in your HTML page.

## Expansion
Expand Down
2 changes: 1 addition & 1 deletion app/docs/md/learn/starter-project/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Elements are the reusable building blocks of your Enhance application. They are

## Naming

The file name of your element will be the tag name you author with. Meaning `app/elements/my-message.mjs` will be authored as `<my-message></my-message>` in your HTML page.
The file name of your element will be the tag name you author with. Meaning `app/elements/my-message.mjs` will be authored as `<my-message></my-message>` in your HTML page. Enhance elements are HTML custom elements, so they [require two or more words separated by a dash](/docs/learn/concepts/html/elements).

```
app/elements/my-message → <my-message></my-message>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f28b0a

Please sign in to comment.