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(
2500
2500
const getNextHostNode : NextFn = vnode => {
2501
2501
if ( vnode . shapeFlag & ShapeFlags . COMPONENT ) {
2502
2502
if ( ( vnode . type as ConcreteComponent ) . __vapor ) {
2503
- return hostNextSibling ( ( vnode . component ! as any ) . block )
2503
+ return hostNextSibling ( vnode . anchor ! )
2504
2504
}
2505
2505
return getNextHostNode ( vnode . component ! . subTree )
2506
2506
}
Original file line number Diff line number Diff line change @@ -214,6 +214,32 @@ describe('vdomInterop', () => {
214
214
describe . todo ( 'dynamic component' , ( ) => { } )
215
215
216
216
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
+
217
243
it ( 'should not fallthrough emit handlers to vdom child' , ( ) => {
218
244
const VDomChild = defineComponent ( {
219
245
emits : [ 'click' ] ,
Original file line number Diff line number Diff line change @@ -156,6 +156,24 @@ export function createComponent(
156
156
resetInsertionState ( )
157
157
}
158
158
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
+
159
177
// vdom interop enabled and component is not an explicit vapor component
160
178
if ( appContext . vapor && ! component . __vapor ) {
161
179
const frag = appContext . vapor . vdomMount (
@@ -175,24 +193,6 @@ export function createComponent(
175
193
return frag
176
194
}
177
195
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
-
196
196
const instance = new VaporComponentInstance (
197
197
component ,
198
198
rawProps as RawProps ,
You can’t perform that action at this time.
0 commit comments