Skip to content

Commit 369bc0e

Browse files
authored
docs: consist usage of in-DOM template (#2487)
* docs: consist usage of in-DOM template * docs: consist usage of in-DOM template
1 parent 1ab68f6 commit 369bc0e

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

src/api/built-in-special-attributes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Used for binding [dynamic components](/guide/essentials/component-basics#dynamic
9595

9696
When the `is` attribute is used on a native HTML element, it will be interpreted as a [Customized built-in element](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-customized-builtin-example), which is a native web platform feature.
9797

98-
There is, however, a use case where you may need Vue to replace a native element with a Vue component, as explained in [DOM Template Parsing Caveats](/guide/essentials/component-basics#dom-template-parsing-caveats). You can prefix the value of the `is` attribute with `vue:` so that Vue will render the element as a Vue component instead:
98+
There is, however, a use case where you may need Vue to replace a native element with a Vue component, as explained in [in-DOM Template Parsing Caveats](/guide/essentials/component-basics#in-dom-template-parsing-caveats). You can prefix the value of the `is` attribute with `vue:` so that Vue will render the element as a Vue component instead:
9999

100100
```vue-html
101101
<table>

src/glossary/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Typically, an in-DOM template starts off as HTML markup written directly in the
168168

169169
For more details see:
170170
- [Guide - Creating an Application - In-DOM Root Component Template](/guide/essentials/application.html#in-dom-root-component-template)
171-
- [Guide - Component Basics - DOM Template Parsing Caveats](/guide/essentials/component-basics.html#dom-template-parsing-caveats)
171+
- [Guide - Component Basics - in-DOM Template Parsing Caveats](/guide/essentials/component-basics.html#in-dom-template-parsing-caveats)
172172
- [Options: Rendering - template](/api/options-rendering.html#template)
173173

174174
## inject {#inject}

src/guide/built-ins/keep-alive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Now, the state will be persisted across component switches:
4747
</div>
4848

4949
:::tip
50-
When used in [DOM templates](/guide/essentials/component-basics#dom-template-parsing-caveats), it should be referenced as `<keep-alive>`.
50+
When used in [in-DOM templates](/guide/essentials/component-basics#in-dom-template-parsing-caveats), it should be referenced as `<keep-alive>`.
5151
:::
5252

5353
## Include / Exclude {#include-exclude}

src/guide/built-ins/transition-group.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import ListStagger from './transition-demos/ListStagger.vue'
2121
- CSS transition classes will be applied to individual elements in the list, **not** to the group / container itself.
2222

2323
:::tip
24-
When used in [DOM templates](/guide/essentials/component-basics#dom-template-parsing-caveats), it should be referenced as `<transition-group>`.
24+
When used in [in-DOM templates](/guide/essentials/component-basics#in-dom-template-parsing-caveats), it should be referenced as `<transition-group>`.
2525
:::
2626

2727
## Enter / Leave Transitions {#enter-leave-transitions}

src/guide/components/props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default {
148148
<span>{{ greetingMessage }}</span>
149149
```
150150

151-
Technically, you can also use camelCase when passing props to a child component (except in [DOM templates](/guide/essentials/component-basics#dom-template-parsing-caveats)). However, the convention is using kebab-case in all cases to align with HTML attributes:
151+
Technically, you can also use camelCase when passing props to a child component (except in [in-DOM templates](/guide/essentials/component-basics#in-dom-template-parsing-caveats)). However, the convention is using kebab-case in all cases to align with HTML attributes:
152152

153153
```vue-html
154154
<MyComponent greeting-message="hello" />

src/guide/components/registration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,6 @@ Throughout the guide, we are using PascalCase names when registering components.
136136

137137
2. `<PascalCase />` makes it more obvious that this is a Vue component instead of a native HTML element in templates. It also differentiates Vue components from custom elements (web components).
138138

139-
This is the recommended style when working with SFC or string templates. However, as discussed in [DOM Template Parsing Caveats](/guide/essentials/component-basics#dom-template-parsing-caveats), PascalCase tags are not usable in DOM templates.
139+
This is the recommended style when working with SFC or string templates. However, as discussed in [in-DOM Template Parsing Caveats](/guide/essentials/component-basics#in-dom-template-parsing-caveats), PascalCase tags are not usable in DOM templates.
140140

141141
Luckily, Vue supports resolving kebab-case tags to components registered using PascalCase. This means a component registered as `MyComponent` can be referenced in the template via both `<MyComponent>` and `<my-component>`. This allows us to use the same JavaScript component registration code regardless of template source.

src/guide/essentials/component-basics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ If you are authoring your templates directly in a DOM (e.g. as the content of a
174174
<button-counter></button-counter>
175175
```
176176

177-
See [DOM template parsing caveats](#dom-template-parsing-caveats) for more details.
177+
See [in-DOM template parsing caveats](#in-dom-template-parsing-caveats) for more details.
178178

179179
## Passing Props {#passing-props}
180180

@@ -541,7 +541,7 @@ You can also use the `is` attribute to create regular HTML elements.
541541

542542
When switching between multiple components with `<component :is="...">`, a component will be unmounted when it is switched away from. We can force the inactive components to stay "alive" with the built-in [`<KeepAlive>` component](/guide/built-ins/keep-alive).
543543

544-
## DOM Template Parsing Caveats {#dom-template-parsing-caveats}
544+
## in-DOM Template Parsing Caveats {#in-dom-template-parsing-caveats}
545545

546546
If you are writing your Vue templates directly in the DOM, Vue will have to retrieve the template string from the DOM. This leads to some caveats due to browsers' native HTML parsing behavior.
547547

@@ -583,7 +583,7 @@ We have been using self-closing tags for components in previous code samples:
583583

584584
This is because Vue's template parser respects `/>` as an indication to end any tag, regardless of its type.
585585

586-
In DOM templates, however, we must always include explicit closing tags:
586+
In in-DOM templates, however, we must always include explicit closing tags:
587587

588588
```vue-html
589589
<my-component></my-component>
@@ -628,6 +628,6 @@ The custom component `<blog-post-row>` will be hoisted out as invalid content, c
628628
When used on native HTML elements, the value of `is` must be prefixed with `vue:` in order to be interpreted as a Vue component. This is required to avoid confusion with native [customized built-in elements](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-customized-builtin-example).
629629
:::
630630

631-
That's all you need to know about DOM template parsing caveats for now - and actually, the end of Vue's _Essentials_. Congratulations! There's still more to learn, but first, we recommend taking a break to play with Vue yourself - build something fun, or check out some of the [Examples](/examples/) if you haven't already.
631+
That's all you need to know about in-DOM template parsing caveats for now - and actually, the end of Vue's _Essentials_. Congratulations! There's still more to learn, but first, we recommend taking a break to play with Vue yourself - build something fun, or check out some of the [Examples](/examples/) if you haven't already.
632632

633633
Once you feel comfortable with the knowledge you've just digested, move on with the guide to learn more about components in depth.

src/style-guide/rules-strongly-recommended.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ components/
337337

338338
## Self-closing components {#self-closing-components}
339339

340-
**Components with no content should be self-closing in [Single-File Components](/guide/scaling-up/sfc), string templates, and [JSX](/guide/extras/render-function#jsx-tsx) - but never in DOM templates.**
340+
**Components with no content should be self-closing in [Single-File Components](/guide/scaling-up/sfc), string templates, and [JSX](/guide/extras/render-function#jsx-tsx) - but never in in-DOM templates.**
341341

342342
Components that self-close communicate that they not only have no content, but are **meant** to have no content. It's the difference between a blank page in a book and one labeled "This page intentionally left blank." Your code is also cleaner without the unnecessary closing tag.
343343

@@ -375,15 +375,15 @@ Unfortunately, HTML doesn't allow custom elements to be self-closing - only [off
375375

376376
## Component name casing in templates {#component-name-casing-in-templates}
377377

378-
**In most projects, component names should always be PascalCase in [Single-File Components](/guide/scaling-up/sfc) and string templates - but kebab-case in DOM templates.**
378+
**In most projects, component names should always be PascalCase in [Single-File Components](/guide/scaling-up/sfc) and string templates - but kebab-case in in-DOM templates.**
379379

380380
PascalCase has a few advantages over kebab-case:
381381

382382
- Editors can autocomplete component names in templates, because PascalCase is also used in JavaScript.
383383
- `<MyComponent>` is more visually distinct from a single-word HTML element than `<my-component>`, because there are two character differences (the two capitals), rather than just one (a hyphen).
384384
- If you use any non-Vue custom elements in your templates, such as a web component, PascalCase ensures that your Vue components remain distinctly visible.
385385

386-
Unfortunately, due to HTML's case insensitivity, DOM templates must still use kebab-case.
386+
Unfortunately, due to HTML's case insensitivity, in-DOM templates must still use kebab-case.
387387

388388
Also note that if you've already invested heavily in kebab-case, consistency with HTML conventions and being able to use the same casing across all your projects may be more important than the advantages listed above. In those cases, **using kebab-case everywhere is also acceptable.**
389389

@@ -401,7 +401,7 @@ Also note that if you've already invested heavily in kebab-case, consistency wit
401401
```
402402

403403
```vue-html
404-
<!-- In DOM templates -->
404+
<!-- In in-DOM templates -->
405405
<MyComponent></MyComponent>
406406
```
407407

@@ -416,7 +416,7 @@ Also note that if you've already invested heavily in kebab-case, consistency wit
416416
```
417417

418418
```vue-html
419-
<!-- In DOM templates -->
419+
<!-- In in-DOM templates -->
420420
<my-component></my-component>
421421
```
422422

0 commit comments

Comments
 (0)