11import type { CreateElement } from 'vue'
2- import { getVueConstructor , getCurrentInstance } from '../runtimeContext'
2+ import {
3+ getVueConstructor ,
4+ getCurrentInstance ,
5+ ComponentInternalInstance ,
6+ } from '../runtimeContext'
37import { defineComponentInstance } from '../utils/helper'
48import { 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+ }
533
634let fallbackCreateElement : CreateElement
735
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
1038 if ( ! instance ) {
1139 __DEV__ &&
1240 warn ( '`createElement()` has been called outside of render function.' )
@@ -20,4 +48,4 @@ export const createElement = function createElement(...args: any) {
2048 }
2149
2250 return instance . $createElement . apply ( instance , args )
23- } as CreateElement
51+ } as H
0 commit comments