From b0efe5a918fa2a54666030effbbc2f9c55ba2b3f Mon Sep 17 00:00:00 2001
From: skirtle <65301168+skirtles-code@users.noreply.github.com>
Date: Wed, 1 Feb 2023 18:49:41 +0000
Subject: [PATCH 01/10] Initial draft of a glossary page
---
src/glossary/index.md | 318 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 318 insertions(+)
create mode 100644 src/glossary/index.md
diff --git a/src/glossary/index.md b/src/glossary/index.md
new file mode 100644
index 0000000000..71fb6b4f89
--- /dev/null
+++ b/src/glossary/index.md
@@ -0,0 +1,318 @@
+# Glossary
+
+This glossary is intended to provide some rough guidance about the meanings of technical terms that are in common usage when talking about Vue. It is intended to be *descriptive* of how terms are commonly used, not a *prescriptive* specification of how they must be used. Some terms may have slightly different meanings or nuances depending on the surrounding context.
+
+[[TOC]]
+
+## compiler macro
+
+A *compiler macro* is special code that is processed by a compiler and converted into something else. They are effectively just a clever form of string replacement.
+
+Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions, but they aren't functions at all. These are special strings that the compiler detects and replaces with the real JavaScript code that will run in the browser.
+
+Macros have limitations on their use that don't apply to normal JavaScript code. For example, you might think that `const dp = defineProps` would allow you to create an alias for `defineProps`, but it'll actually result in an error. There are also limitations on what values can be passed to `defineProps()`, as the 'arguments' have to be processed by the compiler and not at runtime.
+
+These macros are conceptually similar to dynamic imports using `import()`. While `import()` looks a lot like a function call, it's actually special syntax that gets processed by the bundler as part of the build. Like with `defineProps()`, we can't create an alias using `const myImport = import`. There are also restrictions on exactly what syntax can be used to pass values to the 'function', so that the compiler can understand the values.
+
+## composable
+
+The term *composable* describes a common usage pattern in Vue. It isn't a separate feature of Vue, it's just a way of using the framework's Composition API. As with many patterns, there can be some disagreement about whether specific code qualifies for the label.
+
+* A composable is a function.
+* The function name usually begins with `use` so that other developers know it's a composable.
+* The function is typically expected to be called from inside a component's `setup()` function (or within a `
+```
+
+```vue
+
+```
+
+In some cases it may be necessary to use functions from the Composition API within the Options API, for example:
+
+```js
+import { computed } from 'vue'
+
+export default {
+ data() {
+ return {
+ message: 'hello!'
+ }
+ },
+ provide() {
+ return {
+ // explicitly provide a computed property
+ message: computed(() => this.message)
+ }
+ }
+}
+```
+
+Even though `computed()` is part of the Composition API, the component above would usually be described as being an Options API component, not a Composition API component.
+
+## effect
+
+See [reactive effect](#reactive-effect) and [side effect](#side-effect).
+
+## fragment
+
+The term *fragment* refers to a VNode that is used as a parent for other VNodes, but which doesn't render any elements itself.
+
+The name comes from the similar concept of a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) in the standard DOM.
+
+Fragments are used to support components with multiple root nodes. While such components might appear to have multiple roots, behind the scenes they actually use a fragment node as a single root, as a parent of the 'root' nodes.
+
+Fragments are also used by the template compiler as a way to wrap multiple dynamic nodes, e.g. those created via `v-for` or `v-if`. This allows for extra hints to be passed to the VDOM patching algorithm. Much of this is handled internally, but one place you'll encounter this directly is using a `key` on a `` tag with `v-for`. In that scenario, the `key` is added as a prop to the fragment VNode.
+
+Fragment nodes are currently rendered to the DOM as empty text nodes, though that is an implementation detail. You may encounter that node if you use `$el` or attempt to walk the DOM with built-in browser APIs.
+
+## functional component
+
+A component definition is usually an object containing options. Even if you're using `
```
-In some cases it may be necessary to use functions from the Composition API within the Options API, for example:
+In some cases it may be necessary to use functions from the Composition API within the [Options API](#options-api), for example:
```js
import { computed } from 'vue'
@@ -124,7 +126,7 @@ A *custom element* is a feature of the [Web Components](#web-components) standar
Vue has built-in support for rendering custom elements and allows them to be used directly in Vue component templates.
-Custom elements should not be confused with the ability to include Vue components as tags within another component's template. Custom elements are used to create Web Components, not Vue components.
+Custom elements should not be confused with the ability to include Vue components as tags within another Vue component's template. Custom elements are used to create Web Components, not Vue components.
For more details see:
- [Guide - Vue and Web Components](/guide/extras/web-components.html)
@@ -170,7 +172,7 @@ The name comes from the similar concept of a [`DocumentFragment`](https://develo
Fragments are used to support components with multiple root nodes. While such components might appear to have multiple roots, behind the scenes they use a fragment node as a single root, as a parent of the 'root' nodes.
-Fragments are also used by the template compiler as a way to wrap multiple dynamic nodes, e.g. those created via `v-for` or `v-if`. This allows for extra hints to be passed to the VDOM patching algorithm. Much of this is handled internally, but one place you may encounter this directly is using a `key` on a `` tag with `v-for`. In that scenario, the `key` is added as a prop to the fragment VNode.
+Fragments are also used by the template compiler as a way to wrap multiple dynamic nodes, e.g. those created via `v-for` or `v-if`. This allows for extra hints to be passed to the [VDOM](#virtual-dom) patching algorithm. Much of this is handled internally, but one place you may encounter this directly is using a `key` on a `` tag with `v-for`. In that scenario, the `key` is added as a [prop](#prop) to the fragment VNode.
Fragment nodes are currently rendered to the DOM as empty text nodes, though that is an implementation detail. You may encounter those text nodes if you use `$el` or attempt to walk the DOM with built-in browser APIs.
@@ -243,7 +245,7 @@ Components can be written in two styles. One style uses the [Composition API](#c
The Options API includes options such as `data()`, `computed`, `methods` and `created()`.
-Some options, such as `props`, `emits` and `inheritAttrs`, can be used when authoring components with either API. As they are component options, they can be considered part of the Options API. However, as these options are also used in conjunction with `setup()`, it is usually more useful to think of them as shared between the two component styles.
+Some options, such as `props`, `emits` and `inheritAttrs`, can be used when authoring components with either API. As they are component options, they could be considered part of the Options API. However, as these options are also used in conjunction with `setup()`, it is usually more useful to think of them as shared between the two component styles.
The `setup()` function itself is a component option, so it *could* be described as part of the Options API. However, this is not how the term 'Options API' is normally used. Instead, the `setup()` function is considered to be part of Composition API.
@@ -287,14 +289,14 @@ When a component *provides* a value, all descendants of that component can then
`provide` and `inject` are sometimes used to avoid *prop drilling*. They can also be used as an implicit way for a component to communicate with its slot contents.
-`provide` can also be used as the application level, making a value available to all components within that application.
+`provide` can also be used at the application level, making a value available to all components within that application.
For more details see:
- [Guide - provide / inject](/guide/components/provide-inject.html)
## reactive effect {#reactive-effect}
-A *reactive effect* is part of Vue's reactivity system. It refers to the process of tracking the dependencies of a function and re-running that function when those dependencies change.
+A *reactive effect* is part of Vue's reactivity system. It refers to the process of tracking the dependencies of a function and re-running that function when the values of those dependencies change.
`watchEffect()` is the most direct way to create an effect. Various other parts of Vue use effects internally. e.g. component rendering updates, `computed()` and `watch()`.
@@ -357,9 +359,9 @@ The *scheduler* is the part of Vue's internals that controls the timing of when
When reactive state changes, Vue doesn't immediately trigger rendering updates. Instead, it batches them together using a queue. This ensures that a component only re-renders once, even if multiple changes are made to the underlying data.
-There are two other queues inside the scheduler. The `flush: 'pre'` queue is processed prior to the rendering queue. The `flush: 'post'` queue runs after the rendering queue. These two queues are used by watchers, with `flush: 'pre'` being the default.
+[Watchers](/guide/essentials/watchers.html) are also batched using the scheduler queue. Watchers with `flush: 'pre'` (the default) will run before component rendering, whereas those with `flush: 'post'` will run after component rendering.
-Jobs in the scheduler queues are also used to perform various other internal tasks, such as triggering some [lifecycle hooks](#lifecycle-hooks) and updating [template refs](#template-refs).
+Jobs in the scheduler are also used to perform various other internal tasks, such as triggering some [lifecycle hooks](#lifecycle-hooks) and updating [template refs](#template-refs).
## scoped slot {#scoped-slot}
@@ -369,7 +371,7 @@ Historically, Vue made a much greater distinction between scoped and non-scoped
In Vue 3, the slot APIs were simplified to make all slots behave like scoped slots. However, the use cases for scoped and non-scoped slots often differ, so the term still proves useful as a way to refer to slots with props.
-The props passed to a slot can only be used within a specific region of the parent template, responsible for defining the slot's contents. This region of the template behaves as a variable scope for the props, hence 'scoped slot'.
+The props passed to a slot can only be used within a specific region of the parent template, responsible for defining the slot's contents. This region of the template behaves as a variable scope for the props, hence the name 'scoped slot'.
For more details see:
- [Guide - Slots - Scoped Slots](/guide/components/slots.html#scoped-slots)
@@ -422,7 +424,7 @@ See [virtual DOM](#virtual-dom).
## virtual DOM {#virtual-dom}
-The term *virtual DOM* is not unique to Vue. It is a common approach used by several UI frameworks for managing updates to the UI.
+The term *virtual DOM* (VDOM) is not unique to Vue. It is a common approach used by several web frameworks for managing updates to the UI.
Browsers use a tree of nodes to represent the current state of the page. That tree, and the JavaScript APIs used to interact with it, are referred to as the *document object model*, or *DOM*.
From 810a701fe3f6a0ce21cd37d60fcbba21250ca3eb Mon Sep 17 00:00:00 2001
From: skirtle <65301168+skirtles-code@users.noreply.github.com>
Date: Mon, 20 Mar 2023 15:01:16 +0000
Subject: [PATCH 07/10] Update src/glossary/index.md
Co-authored-by: Evan You
---
src/glossary/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/glossary/index.md b/src/glossary/index.md
index 9eef8ae37c..05feccf048 100644
--- a/src/glossary/index.md
+++ b/src/glossary/index.md
@@ -15,7 +15,7 @@ For more details see:
## compiler macro {#compiler-macro}
-A *compiler macro* is special code that is processed by a compiler and converted into something else. They are effectively just a clever form of string replacement.
+A *compiler macro* is special code that is processed by a compiler and converted into something else. They are effectively a clever form of string replacement.
Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions, but they aren't functions at all. These are special strings that the compiler detects and replaces with the real JavaScript code that will run in the browser.
From c6968b16e63f65964ccd55d6a7ce384a5cbcea14 Mon Sep 17 00:00:00 2001
From: skirtle <65301168+skirtles-code@users.noreply.github.com>
Date: Mon, 20 Mar 2023 15:03:46 +0000
Subject: [PATCH 08/10] Update src/glossary/index.md
Co-authored-by: Evan You
---
src/glossary/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/glossary/index.md b/src/glossary/index.md
index 05feccf048..4ad7473e25 100644
--- a/src/glossary/index.md
+++ b/src/glossary/index.md
@@ -17,7 +17,7 @@ For more details see:
A *compiler macro* is special code that is processed by a compiler and converted into something else. They are effectively a clever form of string replacement.
-Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions, but they aren't functions at all. These are special strings that the compiler detects and replaces with the real JavaScript code that will run in the browser.
+Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions so that they can leverage the same parser and type inference tooling around JavaScript / TypeScript. However they are not actual functions that are run in the browser. These are special strings that the compiler detects and replaces with the real JavaScript code that will actually be run.
Macros have limitations on their use that don't apply to normal JavaScript code. For example, you might think that `const dp = defineProps` would allow you to create an alias for `defineProps`, but it'll actually result in an error. There are also limitations on what values can be passed to `defineProps()`, as the 'arguments' have to be processed by the compiler and not at runtime.
From 2d5428c0edb4dac4d1dcca44a6b8d5070d5c9201 Mon Sep 17 00:00:00 2001
From: skirtle <65301168+skirtles-code@users.noreply.github.com>
Date: Mon, 20 Mar 2023 15:08:24 +0000
Subject: [PATCH 09/10] Update src/glossary/index.md
Co-authored-by: Evan You
---
src/glossary/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/glossary/index.md b/src/glossary/index.md
index 4ad7473e25..bf26e42239 100644
--- a/src/glossary/index.md
+++ b/src/glossary/index.md
@@ -168,7 +168,7 @@ For more details see:
The term *fragment* refers to a special type of [VNode](#vnode) that is used as a parent for other VNodes, but which doesn't render any elements itself.
-The name comes from the similar concept of a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) in the standard DOM.
+The name comes from the similar concept of a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) in the native DOM API.
Fragments are used to support components with multiple root nodes. While such components might appear to have multiple roots, behind the scenes they use a fragment node as a single root, as a parent of the 'root' nodes.
From bd1b7380e426afaace8d9879e5213a7a896ebe73 Mon Sep 17 00:00:00 2001
From: skirtle <65301168+skirtles-code@users.noreply.github.com>
Date: Thu, 23 Mar 2023 00:35:09 +0000
Subject: [PATCH 10/10] Integrate review feedback to the glossary
---
src/glossary/index.md | 56 +++++++------------------------------------
1 file changed, 9 insertions(+), 47 deletions(-)
diff --git a/src/glossary/index.md b/src/glossary/index.md
index bf26e42239..102017d80b 100644
--- a/src/glossary/index.md
+++ b/src/glossary/index.md
@@ -17,12 +17,10 @@ For more details see:
A *compiler macro* is special code that is processed by a compiler and converted into something else. They are effectively a clever form of string replacement.
-Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions so that they can leverage the same parser and type inference tooling around JavaScript / TypeScript. However they are not actual functions that are run in the browser. These are special strings that the compiler detects and replaces with the real JavaScript code that will actually be run.
+Vue's [SFC](#single-file-component) compiler supports various macros, such as `defineProps()`, `defineEmits()` and `defineExpose()`. These macros are intentionally designed to look like normal JavaScript functions so that they can leverage the same parser and type inference tooling around JavaScript / TypeScript. However, they are not actual functions that are run in the browser. These are special strings that the compiler detects and replaces with the real JavaScript code that will actually be run.
Macros have limitations on their use that don't apply to normal JavaScript code. For example, you might think that `const dp = defineProps` would allow you to create an alias for `defineProps`, but it'll actually result in an error. There are also limitations on what values can be passed to `defineProps()`, as the 'arguments' have to be processed by the compiler and not at runtime.
-These macros are conceptually similar to dynamic imports using `import()`. While `import()` looks a lot like a function call, it's actually special syntax that gets processed by the bundler as part of the build. Like with `defineProps()`, we can't create an alias using `const myImport = import`. There are also restrictions on exactly what syntax can be used to pass values to the `import()` 'function', so that the bundler can understand the values.
-
For more details see:
- [`
-```
-
-```vue
-
-```
-
-In some cases it may be necessary to use functions from the Composition API within the [Options API](#options-api), for example:
-
-```js
-import { computed } from 'vue'
-
-export default {
- data() {
- return {
- message: 'hello!'
- }
- },
- provide() {
- return {
- // explicitly provide a computed property
- message: computed(() => this.message)
- }
- }
-}
-```
-
-Even though `computed()` is part of the Composition API, the component above would usually be described as being an Options API component, not a Composition API component.
+See the [Composition API FAQ](/guide/extras/composition-api-faq) for more details.
## custom element {#custom-element}
@@ -351,7 +311,7 @@ For more details see:
A *render function* is the part of a component that generates the VNodes used during rendering. Templates are compiled down into render functions.
For more details see:
-- [Guide - Render Functions & JSX - Functional Components](/guide/extras/render-function.html#functional-components)
+- [Guide - Render Functions & JSX](/guide/extras/render-function.html)
## scheduler {#scheduler}
@@ -434,9 +394,11 @@ Rather than creating DOM nodes directly, Vue components generate a description o
Every time a component re-renders, the new tree of VNodes is compared to the previous tree of VNodes and any differences are then applied to the real DOM. If nothing has changed then the DOM doesn't need to be touched.
+Vue uses a hybrid approach that we call [Compiler-Informed Virtual DOM](/guide/extras/rendering-mechanism.html#compiler-informed-virtual-dom). Vue's template compiler is able to apply performance optimizations based on static analysis of the template. Rather than performing a full comparison of a component's old and new VNode trees at runtime, Vue can use information extracted by the compiler to reduce the comparison to just the parts of the tree that can actually change.
+
For more details see:
- [Guide - Rendering Mechanism](/guide/extras/rendering-mechanism.html)
-- [Guide - Render Functions & JSX - Functional Components](/guide/extras/render-function.html#functional-components)
+- [Guide - Render Functions & JSX](/guide/extras/render-function.html)
## VNode {#vnode}