File tree Expand file tree Collapse file tree 3 files changed +45
-19
lines changed Expand file tree Collapse file tree 3 files changed +45
-19
lines changed Original file line number Diff line number Diff line change @@ -2500,7 +2500,7 @@ function baseCreateRenderer(
25002500 const getNextHostNode : NextFn = vnode => {
25012501 if ( vnode . shapeFlag & ShapeFlags . COMPONENT ) {
25022502 if ( ( vnode . type as ConcreteComponent ) . __vapor ) {
2503- return hostNextSibling ( ( vnode . component ! as any ) . block )
2503+ return hostNextSibling ( vnode . anchor ! )
25042504 }
25052505 return getNextHostNode ( vnode . component ! . subTree )
25062506 }
Original file line number Diff line number Diff line change @@ -214,6 +214,32 @@ describe('vdomInterop', () => {
214214 describe . todo ( 'dynamic component' , ( ) => { } )
215215
216216 describe ( 'attribute fallthrough' , ( ) => {
217+ it ( 'should fallthrough attrs to vdom child' , ( ) => {
218+ const VDomChild = defineComponent ( {
219+ setup ( ) {
220+ return ( ) => h ( 'div' )
221+ } ,
222+ } )
223+
224+ const VaporChild = defineVaporComponent ( {
225+ setup ( ) {
226+ return createComponent (
227+ VDomChild as any ,
228+ { foo : ( ) => 'vapor foo' } ,
229+ null ,
230+ true ,
231+ )
232+ } ,
233+ } )
234+
235+ const { html } = define ( {
236+ setup ( ) {
237+ return ( ) => h ( VaporChild as any , { foo : 'foo' , bar : 'bar' } )
238+ } ,
239+ } ) . render ( )
240+ expect ( html ( ) ) . toBe ( '<div foo="foo" bar="bar"></div>' )
241+ } )
242+
217243 it ( 'should not fallthrough emit handlers to vdom child' , ( ) => {
218244 const VDomChild = defineComponent ( {
219245 emits : [ 'click' ] ,
Original file line number Diff line number Diff line change @@ -156,6 +156,24 @@ export function createComponent(
156156 resetInsertionState ( )
157157 }
158158
159+ if (
160+ isSingleRoot &&
161+ component . inheritAttrs !== false &&
162+ isVaporComponent ( currentInstance ) &&
163+ currentInstance . hasFallthrough
164+ ) {
165+ // check if we are the single root of the parent
166+ // if yes, inject parent attrs as dynamic props source
167+ const attrs = currentInstance . attrs
168+ if ( rawProps ) {
169+ ; ( ( rawProps as RawProps ) . $ || ( ( rawProps as RawProps ) . $ = [ ] ) ) . push (
170+ ( ) => attrs ,
171+ )
172+ } else {
173+ rawProps = { $ : [ ( ) => attrs ] } as RawProps
174+ }
175+ }
176+
159177 // vdom interop enabled and component is not an explicit vapor component
160178 if ( appContext . vapor && ! component . __vapor ) {
161179 const frag = appContext . vapor . vdomMount (
@@ -175,24 +193,6 @@ export function createComponent(
175193 return frag
176194 }
177195
178- if (
179- isSingleRoot &&
180- component . inheritAttrs !== false &&
181- isVaporComponent ( currentInstance ) &&
182- currentInstance . hasFallthrough
183- ) {
184- // check if we are the single root of the parent
185- // if yes, inject parent attrs as dynamic props source
186- const attrs = currentInstance . attrs
187- if ( rawProps ) {
188- ; ( ( rawProps as RawProps ) . $ || ( ( rawProps as RawProps ) . $ = [ ] ) ) . push (
189- ( ) => attrs ,
190- )
191- } else {
192- rawProps = { $ : [ ( ) => attrs ] } as RawProps
193- }
194- }
195-
196196 const instance = new VaporComponentInstance (
197197 component ,
198198 rawProps as RawProps ,
You can’t perform that action at this time.
0 commit comments