1
1
import type { CreateElement } from 'vue'
2
- import { getVueConstructor , getCurrentInstance } from '../runtimeContext'
2
+ import {
3
+ getVueConstructor ,
4
+ getCurrentInstance ,
5
+ ComponentInternalInstance ,
6
+ } from '../runtimeContext'
3
7
import { defineComponentInstance } from '../utils/helper'
4
8
import { warn } from '../utils'
9
+ import { AsyncComponent , Component } from 'vue/types/options'
10
+ import { VNode , VNodeChildren , VNodeData } from 'vue/types/vnode'
11
+
12
+ export interface H extends CreateElement {
13
+ (
14
+ this : ComponentInternalInstance | null ,
15
+ tag ?:
16
+ | string
17
+ | Component < any , any , any , any >
18
+ | AsyncComponent < any , any , any , any >
19
+ | ( ( ) => Component ) ,
20
+ children ?: VNodeChildren
21
+ ) : VNode
22
+ (
23
+ this : ComponentInternalInstance | null ,
24
+ tag ?:
25
+ | string
26
+ | Component < any , any , any , any >
27
+ | AsyncComponent < any , any , any , any >
28
+ | ( ( ) => Component ) ,
29
+ data ?: VNodeData ,
30
+ children ?: VNodeChildren
31
+ ) : VNode
32
+ }
5
33
6
34
let fallbackCreateElement : CreateElement
7
35
8
- export const createElement = function createElement ( ...args : any ) {
9
- const instance = getCurrentInstance ( ) ?. proxy
36
+ export const createElement = function createElement ( this , ...args : any ) {
37
+ const instance = this ? this . proxy : getCurrentInstance ( ) ?. proxy
10
38
if ( ! instance ) {
11
39
__DEV__ &&
12
40
warn ( '`createElement()` has been called outside of render function.' )
@@ -20,4 +48,4 @@ export const createElement = function createElement(...args: any) {
20
48
}
21
49
22
50
return instance . $createElement . apply ( instance , args )
23
- } as CreateElement
51
+ } as H
0 commit comments