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'
22import type { App } from '@vue/runtime-dom'
33import type { VaporComponent , VaporComponentInstance } from '../src/component'
44import type { RawProps } from '../src/componentProps'
@@ -36,7 +36,8 @@ export function makeRender<C = VaporComponent>(
3636 } )
3737
3838 function define ( comp : C ) {
39- const component = defineVaporComponent ( comp as any )
39+ const component = comp as any
40+ component . __vapor = true
4041 let instance : VaporComponentInstance | undefined
4142 let app : App
4243
Original file line number Diff line number Diff line change @@ -127,6 +127,27 @@ describe('component: props', () => {
127127 expect ( props ) . toBe ( attrs )
128128 } )
129129
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+
130151 test ( 'boolean casting' , ( ) => {
131152 let props : any
132153 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'
23
34/*! #__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+ }
518 // TODO type inference
619 comp . __vapor = true
720 return comp
You can’t perform that action at this time.
0 commit comments