Skip to content

Commit fb11b66

Browse files
authored
h -> createElement
#19 (comment)
1 parent bc528ae commit fb11b66

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

active-rfcs/0000-render-function-api-change.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# Basic example
1313

1414
``` js
15-
// globally imported `h`
16-
import { h } from 'vue'
15+
// globally imported `createElement`
16+
import { createElement as h } from 'vue'
1717

1818
export default {
1919
// adjusted render function arguments
@@ -30,7 +30,7 @@ export default {
3030

3131
# Motivation
3232

33-
In 2.x, VNodes are context-specific - which means every VNode created is bound to the component instance that created it (the "context"). This is because we need to support the following use cases:
33+
In 2.x, VNodes are context-specific - which means every VNode created is bound to the component instance that created it (the "context"). This is because we need to support the following use cases (`h` is a conventional alias for `createElement`):
3434

3535
``` js
3636
// looking up a component based on a string ID
@@ -46,7 +46,7 @@ h('div', {
4646
})
4747
```
4848

49-
In order to look up locally/globally registered components and directives, we need to know the context component instance that "owns" the VNode. This is why in 2.x `h` is passed in as an argument, because the `h` passed into each render function is a curried version that is pre-bound to the context instance.
49+
In order to look up locally/globally registered components and directives, we need to know the context component instance that "owns" the VNode. This is why in 2.x `h` is passed in as an argument, because the `h` passed into each render function is a curried version that is pre-bound to the context instance (as is `this.$createElement`).
5050

5151
This has created a number of inconveniences, for example when trying to extract part of the render logic into a separate function, `h` needs to be passed along:
5252

@@ -95,12 +95,12 @@ In 3.x, we are moving towards a flat VNode data structure to address these probl
9595

9696
# Detailed design
9797

98-
## Globally imported `h` function
98+
## Globally imported `createElement / h` function
9999

100-
`h` is now globally imported:
100+
`createElement` is now globally imported (and can be renamed to `h` as before):
101101

102102
``` js
103-
import { h } from 'vue'
103+
import { createElement as h } from 'vue'
104104

105105
export default {
106106
render() {

0 commit comments

Comments
 (0)