File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 1
- import { createVaporApp , defineVaporComponent } from '../src'
1
+ import { createVaporApp } from '../src'
2
2
import type { App } from '@vue/runtime-dom'
3
3
import type { VaporComponent , VaporComponentInstance } from '../src/component'
4
4
import type { RawProps } from '../src/componentProps'
@@ -36,7 +36,8 @@ export function makeRender<C = VaporComponent>(
36
36
} )
37
37
38
38
function define ( comp : C ) {
39
- const component = defineVaporComponent ( comp as any )
39
+ const component = comp as any
40
+ component . __vapor = true
40
41
let instance : VaporComponentInstance | undefined
41
42
let app : App
42
43
Original file line number Diff line number Diff line change @@ -127,6 +127,27 @@ describe('component: props', () => {
127
127
expect ( props ) . toBe ( attrs )
128
128
} )
129
129
130
+ test ( 'functional defineVaporComponent without declaration' , ( ) => {
131
+ let props : any
132
+ let attrs : any
133
+
134
+ const { render } = define (
135
+ defineVaporComponent ( ( _props : any , { attrs : _attrs } : any ) => {
136
+ props = _props
137
+ attrs = _attrs
138
+ return [ ]
139
+ } ) ,
140
+ )
141
+
142
+ render ( { foo : ( ) => 1 } )
143
+ expect ( props ) . toEqual ( { } )
144
+ expect ( attrs ) . toEqual ( { foo : 1 } )
145
+
146
+ render ( { bar : ( ) => 2 } )
147
+ expect ( props ) . toEqual ( { } )
148
+ expect ( attrs ) . toEqual ( { bar : 2 } )
149
+ } )
150
+
130
151
test ( 'boolean casting' , ( ) => {
131
152
let props : any
132
153
const { render } = define ( {
Original file line number Diff line number Diff line change 1
- import type { VaporComponent } from './component'
1
+ import type { ObjectVaporComponent , VaporComponent } from './component'
2
+ import { extend , isFunction } from '@vue/shared'
2
3
3
4
/*! #__NO_SIDE_EFFECTS__ */
4
- export function defineVaporComponent ( comp : VaporComponent ) : VaporComponent {
5
+ export function defineVaporComponent (
6
+ comp : VaporComponent ,
7
+ extraOptions ?: Omit < ObjectVaporComponent , 'setup' > ,
8
+ ) : VaporComponent {
9
+ if ( isFunction ( comp ) ) {
10
+ // #8236: extend call and options.name access are considered side-effects
11
+ // by Rollup, so we have to wrap it in a pure-annotated IIFE.
12
+ return /*@__PURE__ */ ( ( ) =>
13
+ extend ( { name : comp . name } , extraOptions , {
14
+ setup : comp ,
15
+ __vapor : true ,
16
+ } ) ) ( )
17
+ }
5
18
// TODO type inference
6
19
comp . __vapor = true
7
20
return comp
You can’t perform that action at this time.
0 commit comments